I have n tasks to be scheduled. The time horizon is 0..T periods. Each task consumes a resources when executed. A resources are limited and could be of different types. I use the following decision variables in choco 2.1.5:
IntegerVariable[][] x = new IntegerVariable[n][m]; // decision variables
int i, j;
for (i = 0; i < n; i++){
for (j = 0; j < T; j++){
x[i][j] = Choco.makeIntVar("x_" + i +"_" + j, 0, 1,Options.V_ENUM);
model.addVariable(x[i][j]);
}
}
The variable x[i][j] equals 1 if the task i starts in period j, equals 0 otherwise. If a number of tasks may run in the same period they have to satisfy resources capacity limits. In case of a given task before a solver find in which period a task should start I have to add additional constraints for a resources. So, in a given period I have to count all usage of resources by running tasks. And I have to somehow know when they start and finish before the model is solved.
In different worrds how to implement the constraint consisting of the following sum:
BigSigma {i | start[i]≤t<start[i]+duration[i]} resourcesRequiredByTask[i] ≤ capacity, (∀ time t)
, where index i is a task number.