From: coletta <co...@li...> - 2004-10-26 16:03:39
|
Le lun, 25/10/2004 =E0 14:08 +0200, Hadrien Cambazard a =E9crit : > The api concerning minization and maximization in not yet available on = the > Problem object. However, you can look at the following code which give = you > an example of minimization. You only need to use the Solver object and > specify a couple of options : >=20 > public static void main(String[] args) { > Problem pb =3D new Problem(); > IntVar fctObj =3D pb.makeBoundIntVar("objectif",-10,1000); > IntVar v1 =3D pb.makeEnumIntVar("v1",1,10); > IntVar v2 =3D pb.makeEnumIntVar("v2",-3,10); > IntVar v3 =3D pb.makeEnumIntVar("v3",1,10); >=20 > pb.post(pb.eq(pb.sum(new IntVar[]{v1,v2,v3}),fctObj)); >=20 >=20 > Solver solver =3D pb.getSolver(); > solver.setDoMaximize(false); > solver.setObjective(fctObj); > solver.setRestart(false); > solver.setFirstSolution(true); > solver.generateSearchSolver(pb); > solver.launch(); > } Hello guys, I'm sorry, but i don't seem to work :-( By selecting another Value Ordering, for instance: inserting the line "solver.setValIterator(new DecreasingDomain());", i obtain: $ java Test ... solution with cost objectif:30 Pb[4 vars, 1 cons] objectif[30, 30] v1{10} v2{10} v3{10} Do i miss something ? -- R=E9mi=20 |