From: Varun J. <jai...@ho...> - 2006-11-17 19:20:35
|
=0A= =0A= =0A= =0A= =0A= Hi,Thank you very much for your quick reply. I=0A= guess the real question I wanted to ask was that if choco could return=0A= results even when the problem is infeasible. I did my experiment with=0A= the following problem:------------------------------------------------Varia= bles:Variable0, Domain: {3, 1, 4}Variable1, Domain: {2, 4, 6}Variable2, Dom= ain: {2, 1}Variable3, Domain: {3, 1}Variable4, Domain: {6, 2, 5}Constraints= :Constraint0, on variables 2 , Allowed values:2Constraint1, on variables 2,= 4 , Allowed values:1, 62, 2Constraint2, on variables 4, 2 , Allowed values= :5, 2Constraint3, on variables 1, 3 , Allowed values:2, 3------------------= ------------------------------------All=0A= the constraints were created using Problem.makeTupleFC(IntVar[]=0A= varList, ArrayList tuples, boolean feasible). For example, the first=0A= constraint can be created as follows:--------------------------------------= ----Problem chocoCSP;/** * Set up the variables using chocoCSP.makeEnumIntV= ar() */IntVar[] varList =3D new IntVar[1];varList[0] =3D variables[2];Array= List<int[]> tuples =3D new ArrayList<int[]>();tuples.add(new int[]{2});choc= oCSP.makeTupleFC(varList, tuples, true);-----------------------------------= --------------To obtain solutions, I did the following:--------------------= --------------------------- System.out.println("SolveAll says: " + choco= CSP.solveAll()); System.out.println("isFeasible says: " + chocoCSP.isFea= sible()); System.out.println("Choco Solutions"); if(chocoCSP.solve() = =3D=3D Boolean.TRUE) { do { for(int i =3D 0; i < chocoCSP.getNb= IntVars(); i ++) { System.out.print(((IntDomainVar) chocoCSP.getIn= tVar(i)).getVal() + ", "); } System.out.println(); } whi= le(chocoCSP.nextSolution() =3D=3D Boolean.TRUE); }----------------------= -------------------------Here is the output:SolveAll says: trueisFeasible s= ays: falseChoco Solutions1,2,2,3,5,3,2,2,3,5,4,2,2,3,5,Clearly,=0A= the solutions do not satisfy all the constraints. For instance, none of=0A= the solutions satisfy Constraint1. Is this expected behaviour??Thanks again= ,-Varun.> Date: Fri, 17 Nov 2006 11:31:40 +0100> From: Guillaume.Richaud@em= n.fr> To: jai...@ho...> Subject: Re: [Choco-users] solveAll() bug= ?> > Hi,> > I am not sure to understand what you try to do but i have some = answers :)> -SolveAll still return true (it is hardcoded) but you can modif= y the > function solveAll() in choco.Problem> > In choco.Problem:> public= Boolean solveAll() {> solver.firstSolution =3D false;> solver.gene= rateSearchSolver(this);> solver.launch();> return Boolean.TRUE;> = }> > -What kind of error do you have ? How do you implement the > nextSolut= ion() loop ?> BTW, if you use nextSolution() to display solutions, you can = use instead:> > "Solver.setVerbosity(Solver.SOLUTION);" before to begin to = solve> and "Solver.flushLogs();" to print solutions> > else:> > if (pb.solv= e() =3D=3D Boolean.TRUE) {> > do {> //Code> }> } while(pb.nextSolu= tion() =3D=3D Boolean.TRUE);> }> > > I hope it helps you... :)> -Guillaume>= > Varun Jain a =E9crit :> > Hi..> > Is there any reason why the solveAll()= method will return true even if > > there is no solution that satisfies al= l constraints. I was getting > > this behaviour so I did a little experimen= t: I set up a simple problem > > and executed the following: > > > > Probl= em chocoCSP; > > //............... > > //-----Set up the problem > > //....= ........... > > System.out.println("SolveAll says: " + chocoCSP.solveAll())= ; > > System.out.println("isFeasible says: " + chocoCSP.isFeasible()); > > = > > The following was the output > > > > SolveAll says: true > > isFeasib= le says: false > > > > I thought solveAll() returns false if no solution e= xists. Also, for > > this problem, the solutions I get from the nextSolutio= n() method do > > not satisfy all constraints. Any explainations would be r= eally helpful? > > > > Thanks, > > -Varun. >=20 _________________________________________________________________ Be one of the first to try Windows Live Mail. http://ideas.live.com/programpage.aspx?versionId=3D5d21c51a-b161-4314-9b0e-= 4911fb2b2e6d= |