From: Hadrien C. <had...@em...> - 2005-06-17 13:02:30
|
Hi, You can see here an example of code where we ask for all solution one by one (values are directly accessible in variables, no need of s.getSearchSolver().solutions.get(0) anymore) for a problem only stating that 2*x + 3*y <= 10 as you requested : (It uses the method scalar that takes coefficients and variables in argument to express a scalar product and leq means "less than equal") public static void main(String[] args) { Problem pb = new Problem(); IntVar x = pb.makeEnumIntVar("x",0,10); IntVar y = pb.makeEnumIntVar("y",0,10); pb.post(pb.leq(pb.scalar(new int[]{2,3},new IntVar[]{x,y}),10)); pb.solve(); if (pb.isFeasible() == Boolean.TRUE) { do { System.out.println("x : " + x.getVal() + " y : " + y.getVal()); } while(pb.nextSolution() == Boolean.TRUE); } } Hope ot helps Hadrien ----- Original Message ----- From: "Matthieu Pichaud" <ma...@gm...> To: <cho...@li...> Sent: Wednesday, June 15, 2005 6:02 PM Subject: [Choco-users] Modeling and retrieving all solutions > Hi, > > I have two questions: > > - I would like to retrieve all the solutions of my problem. But, as I read > and experienced, the number of solutions one can retrieve is limited to > 5. You proposed to use a while loop on the condition pb.nextSolution() > to get all the results. I don't really see how to implement that. When doing > so, the functions s.getSearchSolver().solutions.get(0) becomes irrelevant > and I have no clue where to find the next result. > > - I try to retrieve all interger solutions from a Integer Programming > problem. > I don't know how to multiply an integer variable by an integer value in > order to add a constraint of this kind: 2*x + 3*y <= 10 > > Thanks a lot for your help! > > Matth > > -- > Geschenkt: 3 Monate GMX ProMail gratis + 3 Ausgaben stern gratis > ++ Jetzt anmelden & testen ++ http://www.gmx.net/de/go/promail ++ > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Choco-users mailing list > Cho...@li... > https://lists.sourceforge.net/lists/listinfo/choco-users > |