Originally posted by: Petr Vilím
Hello Hadi,
If I understand right, given task has only two modes. In mode 1 it use resource A, it mode 2 it uses resource B and C. In this case alternatives and optional intervals is the best approach. Optional interval variable T1 can model mode 1 and another optional interval variable can model mode 2. The task itself is then model by non-optional interval T and there's constraint alternative(T, [T1, T2]).
If there's too many modes then the number of alternatives can be very high. In this case, just to save the memory, there's another way to model the problem. Let say that a task requires 2 units of capacity from any of the 18 resources. It could be 2 capacity units from a single resource or a split: 1 capacity unit from one resource and another 1 capacity unit from another one. This problem can be modeled by pulses with variable height: pulse(T, 0, 2). The task can require such a pulse from all the resources and then total height of those pulses can be constrained using heightAtStart expression:
resourceA = ... + pulse(T, 0, 2) + ...;
resourceB = ... + pulse(T, 0, 2) + ...;
...
heightAtStart(T, resourceA) + heightAtStart(T, resourceB) + ... == 2;
Petr
#CPOptimizer#DecisionOptimization