The code is assigning jobs with the same group to pre-scheduled time-window. The domain of groups is {1, 2, 3, 4} and there is transitional time when we switch groups.
tTimes= {<1 1 2> <2 2 2> <3 3 2> <4 4 2>}; //fromGroup toGroup Penalty
Now, I got the following error in State function, "Exception in presolve: Transition matrix for state function does not satisfy the triangle inequality (path 1->
0->1).."
I could not understand this error since there is no group of "0" in the domain. Can you please tell me what are my mistakes?
stateFunction MachineGroup with tTimes;
forall(pt in GroupClock) alwaysEqual(MachineGroup, pt.s, pt.e, pt.g);
forall(j in Jobs) alwaysEqual(MachineGroup, tasks[j], j.g);
using CP;
range Groups = 1..4;
int nj = ...;
int GroupTimes[Groups] = ...;
tuple JobT {
int j;
int g;
int ea;
int la;
};
{JobT} Job=...;
tuple JobsT {
int j;
int g;
int ea;
int la;
};
{JobsT} Jobs={ <j.j, j.g, j.ea,j.la > | j in Job};
tuple GroupClockT {
int g;//Group
int s;//start
int e;//end
};
{GroupClockT} GroupClock ;
execute {
var s=0;var e=0;
for(var i=1;i<=5;i++)
for(var p in Groups) {
e=s+GroupTimes[p];
GroupClock.add(p, s, e);
s=e;
}
};
tuple TTimeT {
key int p1;
key int p2;
int t;
};
{TTimeT} tTimes;
execute {
for(var p1 in Groups) for(var p2 in Groups){
if(p1!=p2) tTimes.add(p1, p1, 2);
}
writeln(tTimes);
};
dvar interval tasks[t in Jobs] in t.ea..9999 size 1;
stateFunction MachineGroup with tTimes;
cumulFunction BatchSize= sum(t in Jobs) pulse(tasks[t], 1);
dexpr int totalDelay= sum(j in Jobs) (endOf(tasks[j])-j.ea);
execute{
cp.param.TimeMode = "ElapsedTime";
cp.param.timeLimit=5;
}
minimize totalDelay;
constraints {
BatchSize <= 4;
forall(pt in GroupClock) alwaysEqual(MachineGroup, pt.s,pt.e,pt.g);
forall(j in Jobs) alwaysEqual(MachineGroup, tasks[j], j.g);
}
nj=20;
Job = {
< 1 4 11 11 >
< 2 3 12 13 >
< 3 3 2 2 >
< 4 1 6 6 >
< 5 2 9 9 >
< 6 1 10 10 >
< 7 3 7 7 >
< 8 2 2 2 >
< 9 4 3 3 >
< 10 2 5 5 >
< 11 3 5 5 >
< 12 1 9 9 >
< 13 1 5 5 >
< 14 4 10 10 >
< 15 3 0 0 >
< 16 4 2 2 >
< 17 4 1 1 >
< 18 3 9 9 >
< 19 2 9 9 >
< 20 3 5 5 >
};
GroupTimes =[2,2,2,2];
------------------------------
Thanks,
Andy
------------------------------
#DecisionOptimization