Originally posted by: Ahlem
Yes my question is when we have sums in the constraints influences on the writing of the code and the final result?
To better understand me, take the constraint 4 does this code below give the same result?
// the first possibility
for (int i2 = 0; i2 < job; i2++) {
IloLinearNumExpr[][][] expr = new IloLinearNumExpr[job][MG.get(m).get(i2).getX()][ressource];
IloLinearNumExpr[][][] expr1 = new IloLinearNumExpr[job][MG.get(m).get(i2).getX()][ressource];
for (int j2 = 0; j2 < MG.get(m).get(i2).getX(); j2++) {
for (int k = 0; k < ressource; k++) {
expr[i2][j2][k] = cplex.linearNumExpr();
expr1[i2][j2][k] = cplex.linearNumExpr();
for (int i1 = 0; i1 < job; i1++) {
for (int j1 = 0; j1 < MG.get(m).get(i1).getX(); j1++) {
expr[i2][j2][k].addTerm(1.0, y[i1][j1][i2][j2][k]);
expr1[i2][j2][k].addTerm(1.0, y[i2][j2][i1][j1][k]);
}
}
cplex.addLe(expr[i2][j2][k], 1); //Constraint3
cplex.addLe(expr[i2][j2][k], expr1[i2][j2][k]); //Constaint4
}
}
}
// the second possibility
for (int i1 = 0; i1 < job; i1++) {
for (int j1 = 0; j1 < MG.get(m).get(i1).getX(); j1++) {
for (int i2 = 0; i2 < job; i2++) {
for (int j2 = 0; j2 < MG.get(m).get(i2).getX(); j2++) {
for (int k = 0; k < ressource; k++) {
IloLinearNumExpr expr = cplex.linearNumExpr(); // constraint3
expr.addTerm(1.0, y[i1][j1][i2][j2][k]);
cplex.addLe(expr, 1);
IloLinearNumExpr expr1 = cplex.linearNumExpr(); // constraint4
expr1.addTerm(1.0, y[i2][j2][i1][j1][k]);
cplex.addLe(expr, expr1);
}
}
}
}
}
#CPLEXOptimizers#DecisionOptimization