Topic
  • 2 replies
  • Latest Post - ‏2014-06-19T10:21:58Z by davidoff
davidoff
davidoff
51 Posts

Pinned topic maximum of a cumulative function

‏2014-06-17T21:53:53Z |

Given a cumulative function f, is it possible to define an integer expression that would maintain the maximum of f ?

I do not see how to do that using expressions such as

dexpr int h = heightAtStart(a,f[,dval]);

since this would maintain h as the value of the cumulative function at the start of interval a

The only trick I can see would to define a set of consecutive intervals of size 1, let's say a[1..100] and using dexpr  int h[i in 1..100] = heightAtStart(a[i],f), we could then compute dexpr int maxh = max(i in 1..100) h[i] , but that is probably not efficient since we discretize time...

  • AlexFleischer
    AlexFleischer
    110 Posts
    ACCEPTED ANSWER

    Re: maximum of a cumulative function

    ‏2014-06-18T06:16:25Z  

    Hi

     

    let me give you an example with the shed_cumul example.

     

    You could turn

    workersUsage <= NbWorkers;;

    into

    workersUsage <= NbWorkers+x;;

    with something like dvar int x in 0..100;

    To bind x, you simply try to minimize it

    Could that help ?

    regards

     

  • AlexFleischer
    AlexFleischer
    110 Posts

    Re: maximum of a cumulative function

    ‏2014-06-18T06:16:25Z  

    Hi

     

    let me give you an example with the shed_cumul example.

     

    You could turn

    workersUsage <= NbWorkers;;

    into

    workersUsage <= NbWorkers+x;;

    with something like dvar int x in 0..100;

    To bind x, you simply try to minimize it

    Could that help ?

    regards

     

  • davidoff
    davidoff
    51 Posts

    Re: maximum of a cumulative function

    ‏2014-06-19T10:21:58Z  

    Thanks, it works fine. Is the documentation uncomplete then ? Indeed , it stands that

    " These are the constraints available on cumulative function expressions:

    • f <= hmax;

    • hmin <= f;

    • alwaysIn(f, u, v, hmin, hmax)

    • alwaysIn(f, a, hmin, hmax)

    "