From: Arnaud G. <ar...@im...> - 2010-06-22 16:08:34
|
Hi list, (first post) I would like to minimize something like : min Sum(i=1:p,j=1:c,l=0:d)X(i,j,l) and I don't know if I need to create an Array for my OBJECTIVE variable... this is what I did: 1/ => I have created my Variables, set up and add it to the model... IntegerVariable[][][] X = new IntegerVariable[p][c][d]; ... X[i][j][k] = Choco.makeIntVar("X[" + i + "," + j + "," + k + "]", 0, 1); cp.addVariable(X[i][j][k]); 2/ I then add my constraints ... 3/ I don't know how to create my objective variable... since it is a sum, do I have to create an array ? IntegerVariable[][][] Z = new IntegerVariable[p][c][d]; for (i) { for (j) { for (l) { Z[i][j][l] = Choco.makeIntVar("Z[" + i + "," + j + "," + l + "]", Options.V_OBJECTIVE); cp.addVariable(Z[i][j][l]); } } } for (i) { for (j) { for (l) { cp.addConstraint(eq(Z[i][j][l],X[i][j][l])); } } } Solver s = new CPSolver(); s.read(cp); s.minimize(true); |