Originally posted by: rdumeur
Dear Sergei,
I think you could use two optional interval vars (One with size 10 and another with size 5).
Each interval var would be associated with a pulse (with height 10 and 5 respectively).
You can then use the 'alternative' constraint to represent such a choice, and then use presenceOf(resource_10) instead of having an additional variable x as in the following example:
dvar interval resource_5 optional size 5;
dvar interval resource_10 optional size 10;
dvar interval resource_choice;
cumulFunction c = pulse(resource_5, 5) + pulse(resource_10, 10);
dexpr int x = presenceOf(resource_10);
subject to {
alternative(resource_choice, append(resource_5, resource_10));
}
execute {
writeln("resource_5 " + resource_5);
writeln("resource_10 " + resource_10);
writeln("x " + x);
writeln("c " + c);
}
Cheers,
#CPOptimizer#DecisionOptimization