Originally posted by: ChrisBr
Hello Jie,
A way is to model using cumul-functions and state-functions.
For example you would define:
For the sake of simplicity, the samples are given here in OPL; of course, every features are available in other APIs (C++, Java, .Net, Python).
cumulFunction machineM = sum (s in SubTasks) pulse(subTask[s], 1);
where subTasks is an array of interval variables.
stateFunction state;
a state function used to manage the synchronization.
Then the constraints would look like:
machineM <= machineCapacity
This constraint is used to confine the values of the cumulFunction machineM to a non-negative range [0, machineCapacity].
forall(s in SubTasks)
alwaysEqual(state, subTask[s], States[s], 1, 1);
This constraint specifies that the state function state must be defined, constant and equal to non-negative value States[s] everywhere between the start and end of interval subTasks[s], if the interval is present.
The two last parameters 1,1 mean that interval subTasks[s] is start-aligned with state function state, so interval subTasks[s] must start at the beginning of the interval where state is maintained. And interval subTasks[s] is end-aligned with state function state, so it must end at the end of the interval where state is maintained.
You might have a look at the distributed sample Wood cutting problem.
I hope this helps,
Chris.
#CPOptimizer#DecisionOptimization