Originally posted by: user1234567
Hello, I'm a beginner in cplex.
I'm trying to solve Milp model of FJSP problem. I referred to sched_jobshop_flex example for the FJSP problem. The code is not running after adding the two variable constraints X and Y:
forall (m in Mchs, j in Jobs,o in Ops, o1 in Ops, o2 in Ops, m1 in Modes, m2 in Modes: m1.mch==m && m2.mch==m){
(o2.pos==1+o1.pos) =>
(Y[o1,o2,m] == 1);
}
forall (j in Jobs, p in Modes, o in Ops, m in Mchs){
(p.pt != 0) =>
(X[m,j,o] == 1);
}
//Also it is not running after adding the other constraints of the Milp model (attached).
//This is the current code.
using CP;
tuple paramsT{
int nbJobs;
int nbMchs;
};
paramsT Params = ...;
int nbJobs = Params.nbJobs;
int nbMchs = Params.nbMchs;
range Jobs = 1..nbJobs;
range Mchs = 1..nbMchs;
tuple Operation {
int id; // Operation id
int jobId; // Job id
int pos; // Position in job
};
tuple Mode {
int opId; // Operation id
int mch; // Machine
int pt; // Processing time
};
{Operation} Ops = ...;
{Mode} Modes = ...;
// Position of last operation of job j
int jlast[j in Jobs] = max(o in Ops: o.jobId==j) o.pos;
dvar interval ops [Ops];
dvar interval modes[md in Modes] optional size md.pt;
dvar sequence mchs[m in Mchs] in all(md in Modes: md.mch == m) modes[md];
dvar int Y[o1 in Ops, o2 in Ops, m in Mchs];
dvar int X[m in Mchs, j in Jobs, o in Ops];
execute {
cp.param.FailLimit = 10000;
}
minimize max(j in Jobs, o in Ops: o.pos==jlast[j]) endOf(ops[o]);
subject to {
// Precedence constraints between consecutive operations o1,o2 of a job j
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 (m in Mchs, j in Jobs,o in Ops, o1 in Ops, o2 in Ops, m1 in Modes, m2 in Modes: m1.mch==m && m2.mch==m){
(o2.pos==1+o1.pos) =>
(Y[o1,o2,m] == 1);
}
forall (j in Jobs, p in Modes, o in Ops, m in Mchs){
(p.pt != 0) =>
(X[m,j,o] == 1);
}
// Alternative machines for a given operation o
forall (o in Ops)
alternative(ops[o], all(md in Modes: md.opId==o.id) modes[md]);
// Operations on a given machine m cannot overlap
forall (m in Mchs)
noOverlap(mchs[m]);
}
execute {
for (var m in Modes) {
if (modes[m].present)
writeln("Operation " + m.opId + " on machine " + m.mch + " starting at " + modes[m].start);
}
}
tuple solutionT{
int operation;
int machine;
int start;
};
{solutionT} solution = {<m.opId, m.mch, startOf(modes[m])> | m in Modes : startOf(modes[m]) != 0};
//Attached you can find the variables used in this problem, and the constraints of the milp model.
Thank you.
#DecisionOptimization#OPLusingCPLEXOptimizer