Originally posted by: ChrisBr
Hello Matt,
I'm not sure I understand your model, but anyway I'll try to help you with syntax.
First of all it is necessary to pay attention on any possible confusion between constants, ranges, arrays of data and so on.
To make things clearer it would be a nice idea to rename a few elements (but of course you are free to keep yours if you are more comfortable with)
//Define intervals: number of shifts and number of timeslots
int NbShiftTypes = ...;
int NumberOfSlots=...;
//Range of number of slots and number of shifts
range Slots=1..NumberOfSlots;
range ShiftTypes = 1..NbShiftTypes;
More important: you cannot declare
int worker[i];
Because you use worker in expressions like "i in worker" I think you wanted to define something like:
int NbWorkers = ...;
range worker = 1..NbWorkers;
Be careful to always use the right index.
For example, the use of "itvs" which is define as
dvar interval itvs [i in worker][s in Shifts] optional size Duration[s];
and used as:
sum(n in NumberOfSlots, i in worker) pulse(itvs[n][i],1);
This cannot work.
Whatever you wanted to state, the indices must match the definition.
Here we could have
sum(i in worker, s in Shift) pulse(itvs[i][s],1);
presenceOf is an expression which requires an interval-var as argument.
Do you need one cumulFunction or an array of cumulFunctions?
You define one
cumulFunction workersUsage =
and try to use an array
workerUsage[n] >= Required[n];
I hope these few tips help.
Chris.
#DecisionOptimization#OPLusingCPOptimizer