Search code examples
schedulingmodelingconstraint-programmingminizinc

Is there a MiniZinc Predicate to model time-dependant resource bounds (like cumulative)?


I want to find an optimal code to model certain events with duration that consume certain resources (like cumulative) but this resources can change over time (array of resource count per time slot).

I'm trying to model the typical scheduling problem with some events happening at certain times that consume an amount of limited resources that cannot be exceeded. Resources can change across time, so predicates like cumulative don't fit. I have tried to check that resources are not exceeded for every time slot, but it is incredibly slow compared to the built-in cumulative predicate, and I was wondering if there's something like:

%ensures that resources never exceed the time-dependant bound b.
predicate desired_cumulative(array[int] of var int: s, array[int] of var int: d, array[int] of var int: r, array[int] of var int: b)

Solution

  • You can model a varying resource availability by using the maximum possible resource availability as the cumulative limit, and adding extra fixed tasks that remove some of that available resource.

    For example, say that you have a resource that starts out at 13 at time 0, and goes to 15 at time 5, and then goes down to 12 from time 10 until the end of times (say 100). To model this, use a cumulative with a fixed capacity of 15 (the maximum) and add two tasks, on in the time-span 0 to 5 with resource usage 2 (15-13), and one task in the time span 10 to 100 that has resource usage 3 (15-12).