Originally posted by: Ahlem
This is my code in cplex :
forall (j in Jobs, o1 in Ops, o2 in Ops: o1.jobId==j && o2.jobId==j && o2.pos==1+o1.pos)
endBeforeStart(ops[o1],ops[o2]);
forall (o in Ops)
alternative(ops[o], all(md in Modes: md.opId==o.id) modes[md]);
with my data is:
Ops = {
<1,1,0>,
<2,1,1>,
<3,1,2>,
<4,1,3>,
<5,1,4>,
<6,2,0>,
<7,2,1>,
<8,2,2>,
<9,2,3>,
<10,2,4>,
<11,3,0>,
<12,3,1>,
<13,3,2>,
<14,3,3>,
<15,3,4>,
<16,4,0>,
<17,4,1>,
<18,4,2>,
<19,4,3>,
<20,4,4>,
<21,5,0>,
<22,5,1>,
<23,5,2>,
<24,5,3>,
<25,5,4>,
<26,6,0>,
<27,6,1>,
<28,6,2>,
<29,6,3>,
<30,6,4>,
<31,7,0>,
<32,7,1>,
<33,7,2>,
<34,7,3>,
<35,7,4>,
<36,8,0>,
<37,8,1>,
<38,8,2>,
<39,8,3>,
<40,8,4>,
<41,9,0>,
<42,9,1>,
<43,9,2>,
<44,9,3>,
<45,9,4>,
<46,10,0>,
<47,10,1>,
<48,10,2>,
<49,10,3>,
<50,10,4>
};
Modes = {
//job 1
<1,1,2,21>,
<2,1,1,53>,
<3,1,5,95>,
<4,1,4,55>,
<5,1,3,34>,
<5,1,5,34>,
//job 2
<6,2,1,21>,
<7,2,4,52>,
<8,2,5,16>,
<9,2,3,26>,
<10,2,2,71>,
//job 3
<11,3,4,39>,
<12,3,5,98>,
<13,3,2,42>,
<13,3,4,42>,
<14,3,3,31>,
<15,3,1,12>,
//job 4
<16,4,2,77>,
<16,4,5,77>,
<17,4,1,55>,
<18,4,5,79>,
<19,4,3,66>,
<20,4,4,77>,
//job 5
<21,5,1,83>,
<22,5,4,34>,
<22,5,3,34>,
<23,5,3,64>,
<24,5,2,19>,
<25,5,5,37>,
//job 6
<26,6,2,54>,
<27,6,3,43>,
<28,6,5,79>,
<28,6,4,79>,
<29,6,1,92>,
<30,6,4,62>,
//job 7
<31,7,4,69>,
<31,7,3,69>,
<32,7,5,77>,
<33,7,2,87>,
<34,7,3,87>,
<35,7,1,93>,
//job 8
<36,8,3,38>,
<37,8,1,60>,
<38,8,2,41>,
<39,8,4,24>,
<40,8,5,83>,
//job 9
<41,9,4,17>,
<42,9,2,49>,
<42,9,1,49>,
<43,9,5,25>,
<44,9,1,44>,
<45,9,3,98>,
<45,9,1,98>,
//job 10
<46,10,5,77>,
<47,10,4,79>,
<47,10,1,79>,
<48,10,3,43>,
<48,10,2,43>,
<49,10,2,75>,
<50,10,1,96>
};
And now i try to convert this in java using cplex and I do not know how to do it
when i use endBeforeStart in java this command takes as type of parameters IloIntervalVar.
I try this :
//Precedence constraints
ArrayList<IloIntervalVar> allTasks = new ArrayList<IloIntervalVar>();
IloIntervalVar[][] information = new IloIntervalVar[job][operation];
for (int i = 0; i < job; i++) {
for (int j = 0; j < MG.get(m).get(i).getX(); j++) { //operation by job
IloIntervalVar task = cp.intervalVar(i,j);
information[i][j]=task;
allTasks.add(task);
}
}
for (int i = 0; i < job; i++) {
for (int j1 = 0; j1 < MG.get(m).get(i).getX(); j1++) {
for (int j2 = 1; j2 < MG.get(m).get(i).getX(); j2++) {
cp.endBeforeStart(information[i][j1], information[i][j2]);
}
}
}
Do you think my code is correct ?
Any one can help me?
#CPLEXOptimizers#DecisionOptimization