You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(11) |
Nov
(4) |
Dec
(7) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(2) |
Feb
(8) |
Mar
(13) |
Apr
(1) |
May
(2) |
Jun
(5) |
Jul
(7) |
Aug
(1) |
Sep
(1) |
Oct
(9) |
Nov
(1) |
Dec
(15) |
2006 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(1) |
May
(10) |
Jun
(1) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
(6) |
Dec
|
2007 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(14) |
Jul
(3) |
Aug
|
Sep
(7) |
Oct
(13) |
Nov
(4) |
Dec
(7) |
2008 |
Jan
(1) |
Feb
(4) |
Mar
(2) |
Apr
(7) |
May
(4) |
Jun
(17) |
Jul
(20) |
Aug
(7) |
Sep
(23) |
Oct
(18) |
Nov
(47) |
Dec
(51) |
2009 |
Jan
(35) |
Feb
(20) |
Mar
(32) |
Apr
(38) |
May
(119) |
Jun
(99) |
Jul
(65) |
Aug
(22) |
Sep
(24) |
Oct
(39) |
Nov
(9) |
Dec
(10) |
2010 |
Jan
(8) |
Feb
(8) |
Mar
(76) |
Apr
(72) |
May
(80) |
Jun
(83) |
Jul
(28) |
Aug
(57) |
Sep
(25) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2014 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(4) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Fatma C. <cel...@gm...> - 2007-11-07 07:32:43
|
Hello choco users :) Does anybody know, "why can I not use OR and AND constraints at th same time"? I just wanna define an array of constraints(which every array's element is the combination of different AND contraints) and wanna OR every array element. But apparently, it is not working :( when I define such constraint I am getting "UnsupportedOperationException()" ( public AbstractConstraint opposite()). So how can I give this constraint?? for(.....){ for (.....){ implor[t5] = pb.ifThen(pb.and(pb.and(impl),pb.and(implStarts)), pb.eq(tasks_starts[t4], starts[t5])); } pb.post(pb.or(implor)); } (detailed code please see below) I really need your help...please write me whatever you think the solution can be. Thanks in advance.... cheers, Fatma detailed code: IntDomainVar[] starts = pb.makeBoundIntVarArray("start", intervalNr, 0, schedulingInterval); IntDomainVar[] tasks_starts = pb.makeBoundIntVarArray("start task", intervalNr, 0, schedulingInterval); for (int j = 0; j < (20/periods_data[i]); j++) { Constraint[] implor = new Constraint[intervalNr]; int t5 = 0; for (int i1 = 0; i1 < n; i1++) { for (int j1 = 0; j1 < (20/periods_data[i1]); j1++) { Constraint[] impl = new Constraint[20]; Constraint[] implStarts = new Constraint[20]; for (int m = 0; m < 20; m++) { impl[m]= pb.implies(pb.leq(starts[t5],m),pb.eq(gap[m], 0)); implStarts[m]= pb.implies(pb.leq(pb.minus (starts[t4],starts[t5]),jitters_data[i]+1),pb.TRUE); } implor[t5] = pb.ifThen(pb.and(pb.and(impl),pb.and(implStarts)), pb.eq(tasks_starts[t4], starts[t5])); t5++; } } pb.post(pb.or(implor)); t4++; } |
From: Fatma C. <cel...@gm...> - 2007-11-06 07:30:22
|
Hello all, For a long time I am struggling with a problem and unfortunatelly still could not find any solution :( Please write me if you have any ideal. Problem description: Scheduliing some tasks according to some criterias.(see below) int[] periods_data = new int[]{20,20,10}; IntDomainVar[] starts = pb.makeBoundIntVarArray("start", 4, 0, 20); IntDomainVar[] starts_task = pb.makeBoundIntVarArray("start task", 4, 0, 20); int t1 = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < (20/periods_data[i]); j++) { Constraint[] implor = new Constraint[4]; int t2 = 0; for (int i1 = 0; i1 < 3; i1++) { for (int j1 = 0; j1 < (20/periods_data[i1]); j1++) { Constraint[] impl = new Constraint[20]; for (int m = 0; m < 20; m++) { impl[m]= pb.ifThen(pb.and(pb.leq(starts[t2],m), pb.geq (starts[t1],m)),pb.eq(gap[m], 0)); } implor[t2] = pb.ifThen(pb.and(pb.and(impl), pb.distanceLT(starts[t1], starts[t2], jitters_data[i]+1)), pb.eq(starts_task[t1], starts[t2])); t2++; } } pb.post(pb.or(implor)); t1++; } } implor[t2] line gives " choco.integer.constraints.DistanceXYC cannot be cast to choco.bool.BinConjunction" error. You have any idea, why? And how can I give the same constraint in a different way? I appreciate your help. cheers, FAtma |
From: Malcolm R. <mal...@cs...> - 2007-10-16 06:16:21
|
On 15/10/2007, at 7:48 PM, Hadrien Cambazard wrote: > Yes, I would say that this code is safe. > You can remove value while iterating just like for Integer > variables if I remember well. > Did you got any problems while doing that ? I was just checking. Many java iterators are not safe to use in this way. (Or perhaps that was just true in older versions of the JDK.) > Please, keep in mind that SetVar just like RealVar are more > examples of how to extend choco than real kernels for set and > continous variables. We are typically not using them ourselves yet. > This should change soon for continous variables but set variables > are not the next priority. Does that mean that they have not been thoroughly tested, or just that they haven't been highly optimised? I'm in the process of writing constraints representing the subset relationship and set partitioning. > I hope, you manage to reach your goals with choco despite our lack > of reactivity ! Thanks, but I sadly think I'm going to need to look for a better documented system, or else I'm going to spend all my time trying to decipher your code rather than working on my problem. Are there any other constraint programming systems you would recommend? The features I particularly need are: 1) Integer variables, with equality and comparison and basic arithmetic 2) Set variables over integers, with membership, subset, intersection, union etc 3) Boolean combinations of constraints, (disjuction, equivalence, implication, negation) I'm looking for a system that is not too much of a nightmare to debug. I've tried ECLiPSe prolog, but visualisation and debugging in Prolog is pretty awful. Java is my programming language of choice. Malcolm -- "The modern man in revolt has become practically useless for all purposes of revolt. By rebelling against everything he has lost his right to rebel against anything." - G.K.Chesterton, Orthodoxy |
From: Malcolm R. <mal...@cs...> - 2007-10-15 00:58:22
|
On 10/10/2007, at 9:24 PM, Guillaume Rochart wrote: > Hi all, > > 1/ isConsistent should return if there exist or not a support > satisfying the constraint (it should say true if there exists one > but say true too if we do not really know) > 2/ isSatisfed should return if the constraint is satisfied when all > variables are instantiated > 3/ isEntailed should return true if the constraint is satisfied > (whatever value is chosen in current domains), false if it not > satisfied (already violated whateter value we choose), null otherwise. So when would isConsistent return anything other than (isEntailed != Boolean.FALSE)? How often are these methods called? Does it matter much how efficient they are? Malcolm -- Many clever men like you have trusted to civilisation. Many clever Babylonians, many clever Egyptians, Many clever men at the end of Rome. - G.K.Chesterton, The Napoleon of Notting Hill |
From: Malcolm R. <mal...@cs...> - 2007-10-12 03:06:51
|
Hi, I'm trying to write a constraint which represents the partitioning of a set into a collection of disjoint subsets. To make sure that the subsets are disjoint, it is useful to keep track of how many subsets have each element in their kernel or envelope. It is more efficient to store this information and update it as we are notified of additions and removals, rather than to scan all the sets on every pass. I have written code which uses a HashMap for this purpose, but it just occured to me that this will not work with backtracking. Is there an appropriate alternative structure which will respond to backtracking appropriately? Thanks, Malcolm -- "If there is one thing worse than the modern weakening of major morals it is the modern strengthening of minor morals. Thus it is considered more withering to accuse a man of bad taste than of bad ethics." -- G.K.Chesterton, On Lying in Bed |
From: Malcolm R. <mal...@cs...> - 2007-10-12 03:06:49
|
Is it safe to remove an element from the domain of a SetVar while iterating over it? That is: is the following code legal? for (IntIterator it0 = set.getDomain().getEnvelopeIterator(); it0.hasNext();) { int x = it0.next(); if (test(x)) set.remFromEnvelope(x, 0); } Malcolm -- "Progress should mean that we are always changing the world to fit the vision, instead we are always changing the vision." - G.K.Chesterton, Orthodoxy |
From: Guillaume R. <ro...@gm...> - 2007-10-10 11:24:34
|
Hi all, 1/ isConsistent should return if there exist or not a support satisfying the constraint (it should say true if there exists one but say true too if we do not really know) 2/ isSatisfed should return if the constraint is satisfied when all variables are instantiated 3/ isEntailed should return true if the constraint is satisfied (whatever value is chosen in current domains), false if it not satisfied (already violated whateter value we choose), null otherwise. Regards, Guillaume On 10/10/07, Malcolm Ryan <mal...@cs...> wrote: > > On 10/10/2007, at 11:25 AM, Malcolm Ryan wrote: > > > What are the correct semantics of the isConsistent() method on > > Propagator? > > And what is the semantics of isEntailed()? Am I correct in thinking > that it should return false only if the constraint is contradicted, > and return null if it neither entailed nor contradicted? The > description doesn't make this clear. > > Malcolm > > -- > "The act of defending any of the cardinal virtues has today all > the exhilaration of a vice." > - G.K.Chesterton A Defense of > Humility > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Choco-users mailing list > Cho...@li... > https://lists.sourceforge.net/lists/listinfo/choco-users > |
From: Malcolm R. <mal...@cs...> - 2007-10-10 05:05:52
|
On 10/10/2007, at 11:25 AM, Malcolm Ryan wrote: > What are the correct semantics of the isConsistent() method on > Propagator? And what is the semantics of isEntailed()? Am I correct in thinking that it should return false only if the constraint is contradicted, and return null if it neither entailed nor contradicted? The description doesn't make this clear. Malcolm -- "The act of defending any of the cardinal virtues has today all the exhilaration of a vice." - G.K.Chesterton A Defense of Humility |
From: Malcolm R. <mal...@cs...> - 2007-10-10 01:26:37
|
What are the correct semantics of the isConsistent() method on Propagator? Malcolm -- "The modern man in revolt has become practically useless for all purposes of revolt. By rebelling against everything he has lost his right to rebel against anything." - G.K.Chesterton, Orthodoxy |
From: Malcolm R. <mal...@cs...> - 2007-10-09 07:54:49
|
On 09/10/2007, at 5:44 PM, Narendra Jussien wrote: > Yes, the Problem.post() method introduces a backtrackable > constraint in the network. Does it make sense for a constraint to post new subconstraints during the propagation process? For example, would the attached Java code work? Or is there a better way to do this? > We are aware of the documentation issue in choco and we are happy > to announce that we hired some permanent staff for the choco > project. This staff will start in November so we plan a real > documentation by mid-2008. That's excellent news. Malcolm -- "The act of defending any of the cardinal virtues has today all the exhilaration of a vice." - G.K.Chesterton A Defense of Humility |
From: Narendra J. <nju...@e-...> - 2007-10-09 07:49:30
|
Yes, the Problem.post() method introduces a backtrackable constraint =20 in the network. We are aware of the documentation issue in choco and we are happy to =20 announce that we hired some permanent staff for the choco project. =20 This staff will start in November so we plan a real documentation by =20 mid-2008. Narendra Le 8 oct. 07 =E0 08:42, Malcolm Ryan a =E9crit : > Poking around in the source, it looks like this might be possible. > The documentation for Problem.post() seems to indicate that it is > possible to post a new constraint which will be retracted on > backtracking. Is that correct? > > A lot of the internals of Choco are very sparsely documented. Do you > plan on fixing that soon? > > Malcolm > > On 08/10/2007, at 1:07 PM, Malcolm Ryan wrote: > >> I then have a bunch of different constraints which apply to all >> elements in the list (and only those). So essentially, for each such >> constraint C(V), I form a list of 100 constraints which state whether >> the constraint applies to each element, depending on the length >> variable: >> >> L > 0 =3D> C(V_0) >> L > 1 =3D> C(V_1) >> ... >> L > 99 =3D> C(V_99) >> >> It seems to me that introducing 100 constraints like this is >> inefficient. I'd much rather have a single constraint which watched >> as the lower bound of L increased and added individual element >> constraints on the fly. So when L is foung to be greater than 2, C >> (V_0), C(V_1) and C(V_2) are added to the problem. >> >> The apparent difficulty with this is the backtracking behaviour. If >> on backtracking we determine that L is less than 2, then we need to >> retract C(V_2) from the constraint store. Is there any easy way to do >> this in Choco? >> >> Malcolm >> >> -- >> Many clever men like you have trusted to civilisation. >> Many clever Babylonians, many clever Egyptians, >> Many clever men at the end of Rome. >> - G.K.Chesterton, The Napoleon of >> Notting Hill >> >> >> >> >> ---------------------------------------------------------------------=20= >> - >> --- >> This SF.net email is sponsored by: Splunk Inc. >> Still grepping through log files to find problems? Stop. >> Now Search log events and configuration files using AJAX and a >> browser. >> Download your FREE copy of Splunk now >> http://get.splunk.com/ >> _______________________________________________ >> Choco-users mailing list >> Cho...@li... >> https://lists.sourceforge.net/lists/listinfo/choco-users > > -- > "An inconvenience is only an adventure wrongly considered; > an adventure is an inconvenience rightly considered." > - G.K.Chesterton, On Running After Ones Hat > > > > > ----------------------------------------------------------------------=20= > --- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a =20 > browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Choco-users mailing list > Cho...@li... > https://lists.sourceforge.net/lists/listinfo/choco-users > > |
From: Malcolm R. <mal...@cs...> - 2007-10-08 06:43:20
|
Poking around in the source, it looks like this might be possible. The documentation for Problem.post() seems to indicate that it is possible to post a new constraint which will be retracted on backtracking. Is that correct? A lot of the internals of Choco are very sparsely documented. Do you plan on fixing that soon? Malcolm On 08/10/2007, at 1:07 PM, Malcolm Ryan wrote: > I then have a bunch of different constraints which apply to all > elements in the list (and only those). So essentially, for each such > constraint C(V), I form a list of 100 constraints which state whether > the constraint applies to each element, depending on the length > variable: > > L > 0 => C(V_0) > L > 1 => C(V_1) > ... > L > 99 => C(V_99) > > It seems to me that introducing 100 constraints like this is > inefficient. I'd much rather have a single constraint which watched > as the lower bound of L increased and added individual element > constraints on the fly. So when L is foung to be greater than 2, C > (V_0), C(V_1) and C(V_2) are added to the problem. > > The apparent difficulty with this is the backtracking behaviour. If > on backtracking we determine that L is less than 2, then we need to > retract C(V_2) from the constraint store. Is there any easy way to do > this in Choco? > > Malcolm > > -- > Many clever men like you have trusted to civilisation. > Many clever Babylonians, many clever Egyptians, > Many clever men at the end of Rome. > - G.K.Chesterton, The Napoleon of > Notting Hill > > > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a > browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Choco-users mailing list > Cho...@li... > https://lists.sourceforge.net/lists/listinfo/choco-users -- "An inconvenience is only an adventure wrongly considered; an adventure is an inconvenience rightly considered." - G.K.Chesterton, On Running After Ones Hat |
From: Malcolm R. <mal...@cs...> - 2007-10-08 03:08:44
|
I'm trying to make a constraint based representation of a list of variable length. Basically, I have an array of, say, 100 element variables V_0, ..., V_99, plus a length variable L in [0,100]. Semantically, the first L of the element variables are in the list, the others are irrelevant. I then have a bunch of different constraints which apply to all elements in the list (and only those). So essentially, for each such constraint C(V), I form a list of 100 constraints which state whether the constraint applies to each element, depending on the length variable: L > 0 => C(V_0) L > 1 => C(V_1) ... L > 99 => C(V_99) It seems to me that introducing 100 constraints like this is inefficient. I'd much rather have a single constraint which watched as the lower bound of L increased and added individual element constraints on the fly. So when L is foung to be greater than 2, C (V_0), C(V_1) and C(V_2) are added to the problem. The apparent difficulty with this is the backtracking behaviour. If on backtracking we determine that L is less than 2, then we need to retract C(V_2) from the constraint store. Is there any easy way to do this in Choco? Malcolm -- Many clever men like you have trusted to civilisation. Many clever Babylonians, many clever Egyptians, Many clever men at the end of Rome. - G.K.Chesterton, The Napoleon of Notting Hill |
From: Malcolm R. <mal...@cs...> - 2007-10-04 02:14:17
|
Is the Choco project still being actively developed and supported? Malcolm -- "An inconvenience is only an adventure wrongly considered; an adventure is an inconvenience rightly considered." - G.K.Chesterton, On Running After Ones Hat |
From: Corina P. <pc...@em...> - 2007-10-03 23:27:43
|
hi this is to let you know that we are using choco in an extension of jpf tool (see http://javapathfinder.sourceforge.net/) we are mostly interested in constraints for reals. regards corina |
From: Sciss <co...@sc...> - 2007-09-15 16:13:19
|
thanks for your reply. in fact i had tried with groovy in the =20 meantime. i'm not a groovy expert so i had a couple of problems =20 mapping java signatures to groovy, but generally it worked. will come =20= back to this hopefully soon! ciao, -sciss- Am 14.09.2007 um 23:02 schrieb Maurice Diamantini: > Bonjour =E0 tous, > > Sorry for the late response, but this oeply was stic in my todo box! > > > Le 6 juin 07 =E0 14:10, Sciss a =E9crit : > >> last, i'm interested to know if anyone is using choco in a scripting >> environment on top of java, like groovy or jython. > > About this question, I've done some successfull try (with groovy) and > with > jruby. > > The advantage of (J)Ruby is that it is a full object language > (in fact, groovy is quite ruby like, but only for java) > One can add new method to existing java class (e.g. for adding > utilities to the Problem class of choco (see the example) > > Here is a full (french) commented exemple (and a little eavy > because it show some feature or ryby syntax) > > (Re)Tested with the last jruby-1.0: > jruby -v > ruby 1.8.5 (2007-08-23 rev 4201) [ppc-jruby1.0.1] > > -- Maurice > > > #!/usr/bin/env jruby > > # interpr=E9teur choco : idem jruby apres avoir ajout=E9 choco.jar = dans > CLASSPATH > # interpr=E9teur corlab : idem jruby apres avoir ajout=E9 plein de = jar > pour la > # recherche op=E9rationnelle (dont choco) > #!/usr/bin/env choco > #!/usr/bin/env corlab > > # =3D=3D=3D=3D Variables du carre magique de taille 4 =3D=3D=3D=3D > # 1 2 15 16 > # 12 14 3 5 > # 13 7 10 4 > # 8 11 6 9 > # Somme de chaque ligne/col/diag : sumVar=3D34 > > # Ajout dynamique d'un fichier jar dans le CLASSPATH > require ENV['CHOCO_TEST_JAR'] > require "java" > require "pp" # Pour debug > > # Diff=E9rentes mani=E8res d'afficher des infos sur l'environnement > # > cp =3D java.lang.System.getProperty("java.class.path") > puts "Affichage du java.class.path :\n #{cp.split(":").join("\n > ")}" > > # display the special rubypath variable (i.e. classpath for ruby libs) > puts "Affichage du rubypath \n #{$:.join("\n ")}" > > # display one environment variable (onluy if exists!) > puts "ENV['CLASSPATH'] =3D " << ENV['CLASSPATH'] unless !ENV=20 > ['CLASSPATH'] > > > # display all environment variables calling java method > # java.lang.System.getenv.each { |k,v| p k; p v; puts "--" } > # # # require "choco" > > include_class "choco.integer.IntDomainVar" > include_class "choco.Problem" > include_class "choco.Constraint" > > > class MagicSquare > > # Pour cr=E9er des accesseurs pour ces attributs (sinon private > par d=E9faut) > # attr_accessor :n, :vers, :sumars, :pb > > # @xxxx : instance attribut xxxx need not to be declared (just > lisibility) > @n =3D nil > @vars =3D nil > @sumVar =3D nil > @pb =3D nil > SOLVE_ALL =3D false > > ######################################################################=20= > ## > #### > def initialize argl > @pb =3D Problem.new > self.parseArgs argl > self.buildVariables > self.buildConstraints > self.solve > self.printStats > end > > ######################################################################=20= > ## > #### > def parseArgs argl > puts argl.join(", ") > @n =3D 4 > if argl.length >=3D 1 > @n =3D argl[0].to_i > end > end > > ######################################################################=20= > ## > #### > def buildVariables > @vars =3D [] > puts "n=3D" + @n.to_s > for i in 0...@n > for j in 0...@n > # pb.makeEnumIntVar serait moins bien pour ce =20 > probl=E8me > @vars << @pb.makeBoundIntVar("C_#{i}_#{j}", 1, @n*@n) > end > end > puts "Construction des variables de d=E9cision principales > faite." > # Calcul de la somme de chaque ligne/col =3D 1/n * = sommeTotale > (de 1..n^2) > @sumVal =3D @n * (@n*@n + 1) / 2 > @sumVar =3D @pb.makeBoundIntVar("S", @sumVal, @sumVal) > puts "Construction de la variable auxiliaire sumVar faite." > puts "" > printVars > end > > ######################################################################=20= > ## > #### > def buildConstraints > # > # Toutes les cellules doivent contenir une variable =20 > diff=E9rente > # > # Bug jruby 1.0 ?? : IntDomainVar non reconnu > # @pb.post(@pb.allDifferent( @vars.to_java(IntDomainVar) )) > > @pb.post(@pb.allDifferent(@vars.to_java > ("choco.integer.IntDomainVar") )) > puts "Construction de la contrainte allDifferent faite." > > # > # Contraintes de la forme "somme de toute ligne est =E9gale =E0= > sumVar" > # > for i in 0...@n > > # 1 - first solution : one create and fill a typed java > array > # > row =3D IntDomainVar[@n].new > # Fill java array with choco variable > for j in 0...@n > row[j] =3D @vars[i*@n+j] > end > # With ruby operator overloading, the folowing could be > # writable as: > # constraint =3D (@pb.sum(row) =3D=3D @sumVar) > # but choco need some work to make this easier ! > constraint =3D @pb.eq(@pb.sum(row), @sumVar) > @pb.post constraint > > # # 2 - Second solution : play with ruby list, then =20 > convert > # # it to the java array befor passing to choco =20 > method. > # # > # row =3D [] > # for j in 0...@n > # row << @vars[i*@n+j] > # end > # jrow =3D row.to_java("choco.integer.IntDomainVar") > # c =3D @pb.eq(@pb.sum(jrow), @sumVar) > # @pb.post c > > > end > puts "Construction des contraintes de lignes faite." > > # Contraintes de la forme "somme de toute colonne est =E9gale > =E0 sumVar" > # > for j in 0...@n > col =3D [] > for i in 0...@n > col << @vars[i*@n+j] > end > @pb.post(@pb.eq(@pb.sum( > col.to_java("choco.integer.IntDomainVar")), > @sumVar)) > > end > puts "Construction des contraintes de colonnes faite." > # > # Egalit=E9 de la somme des deux diagonales > # - diag1 : diagonale directe > # - diag2 : diagonale inverse > diag1 =3D [] > diag2 =3D [] > for i in 0...@n > diag1 << @vars[i*@n+i]; > diag2 << @vars[i*@n+(@n-1-i)]; > end > chocoIntDomVar =3D "choco.integer.IntDomainVar" > @pb.post(@pb.eq(@pb.sum(diag1.to_java(chocoIntDomVar)), > @sumVar)) > @pb.post(@pb.eq(@pb.sum(diag2.to_java(chocoIntDomVar)), > @sumVar)) > > puts "Construction des contraintes des diagonales faite." > end > def solve > puts "Before propagate" > # printVars vars > begin > @pb.propagate > rescue > # puts "Erreur lors de la propag. initiale" > puts "Error while initial propagation" > exit > end > puts "After propagate" > # printVars vars > puts "Before solve" > if SOLVE_ALL > @pb.solveAll > else > @pb.solve > end > puts "After solve" > end > def printVars > # print "=3D=3D=3D=3D Variables du carre magique de taille = #{@n} =20 > =3D=3D=3D=3D" > print "=3D=3D=3D=3D Variables of magic squar of size #{@n} = =3D=3D=3D=3D" > for i in 0...@vars.length > if (i % @n =3D=3D 0) > print "\n" > end > if @vars[i].isInstantiated > printf "%4d ", @vars[i].val > else > printf "%10s ", @vars[i].pretty > end > end > puts "" > # print "Somme de chaque ligne/col/diag : sumVar=3D" > print "Sum of each line/col/diag : sumVar=3D" > if @sumVar.isInstantiated > print @sumVar.val > else > print @sumVar.pretty > end > puts "" > end > def printStats > if SOLVE_ALL > print " (nbSol found: #{@pb.nbSol})\n" > print "Last found solution:\n" > else > print "First found solution:\n" > end > printVars > print "n=3D#{@n} =3D> nbNodes=3D#{@pb.nbNodes} en = #{@pb.nbMillis/ > 1000.0} s." > end > end > > # With ruby, one can add methods to existing choco java class > class Problem > def nbSol > getSolver().getNbSolutions() > # can be call as : solver.nbSolution > end > def nbMillis > # jruby accepte la conversion implicite de m=E9thode > "getSearchSolver()" > # en attribut virtuel "searchSolver" > # getSolver.getSearchSolver.limits.get(0).getNbTot > solver.searchSolver.limits.get(0).nbTot > end > def nbNodes > # getSolver.getSearchSolver.limits.get(1).getNbTot > solver.searchSolver.limits.get(1).nbTot > end > end > > > # ARGV est la liste des arguments transmis au programme > MagicSquare.new ARGV > puts "FIN" > > > # ./ > > > ----------------------------------------------------------------------=20= > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Choco-users mailing list > Cho...@li... > https://lists.sourceforge.net/lists/listinfo/choco-users |
From: Maurice D. <md...@fr...> - 2007-09-14 21:02:31
|
Bonjour =E0 tous, Sorry for the late response, but this oeply was stic in my todo box! Le 6 juin 07 =E0 14:10, Sciss a =E9crit : > last, i'm interested to know if anyone is using choco in a scripting > environment on top of java, like groovy or jython. About this question, I've done some successfull try (with groovy) and =20= with jruby. The advantage of (J)Ruby is that it is a full object language (in fact, groovy is quite ruby like, but only for java) One can add new method to existing java class (e.g. for adding utilities to the Problem class of choco (see the example) Here is a full (french) commented exemple (and a little eavy because it show some feature or ryby syntax) (Re)Tested with the last jruby-1.0: jruby -v ruby 1.8.5 (2007-08-23 rev 4201) [ppc-jruby1.0.1] -- Maurice #!/usr/bin/env jruby # interpr=E9teur choco : idem jruby apres avoir ajout=E9 choco.jar dans = =20 CLASSPATH # interpr=E9teur corlab : idem jruby apres avoir ajout=E9 plein de jar =20= pour la # recherche op=E9rationnelle (dont choco) #!/usr/bin/env choco #!/usr/bin/env corlab # =3D=3D=3D=3D Variables du carre magique de taille 4 =3D=3D=3D=3D # 1 2 15 16 # 12 14 3 5 # 13 7 10 4 # 8 11 6 9 # Somme de chaque ligne/col/diag : sumVar=3D34 # Ajout dynamique d'un fichier jar dans le CLASSPATH require ENV['CHOCO_TEST_JAR'] require "java" require "pp" # Pour debug # Diff=E9rentes mani=E8res d'afficher des infos sur l'environnement # cp =3D java.lang.System.getProperty("java.class.path") puts "Affichage du java.class.path :\n #{cp.split(":").join("\n =20= ")}" # display the special rubypath variable (i.e. classpath for ruby libs) puts "Affichage du rubypath \n #{$:.join("\n ")}" # display one environment variable (onluy if exists!) puts "ENV['CLASSPATH'] =3D " << ENV['CLASSPATH'] unless = !ENV['CLASSPATH'] # display all environment variables calling java method # java.lang.System.getenv.each { |k,v| p k; p v; puts "--" } # # # require "choco" include_class "choco.integer.IntDomainVar" include_class "choco.Problem" include_class "choco.Constraint" class MagicSquare # Pour cr=E9er des accesseurs pour ces attributs (sinon private =20 par d=E9faut) # attr_accessor :n, :vers, :sumars, :pb # @xxxx : instance attribut xxxx need not to be declared (just =20 lisibility) @n =3D nil @vars =3D nil @sumVar =3D nil @pb =3D nil SOLVE_ALL =3D false =20 ########################################################################=20= #### def initialize argl @pb =3D Problem.new self.parseArgs argl self.buildVariables self.buildConstraints self.solve self.printStats end =20 ########################################################################=20= #### def parseArgs argl puts argl.join(", ") @n =3D 4 if argl.length >=3D 1 @n =3D argl[0].to_i end end =20 ########################################################################=20= #### def buildVariables @vars =3D [] puts "n=3D" + @n.to_s for i in 0...@n for j in 0...@n # pb.makeEnumIntVar serait moins bien pour ce probl=E8me @vars << @pb.makeBoundIntVar("C_#{i}_#{j}", 1, @n*@n) end end puts "Construction des variables de d=E9cision principales =20 faite." # Calcul de la somme de chaque ligne/col =3D 1/n * sommeTotale =20= (de 1..n^2) @sumVal =3D @n * (@n*@n + 1) / 2 @sumVar =3D @pb.makeBoundIntVar("S", @sumVal, @sumVal) puts "Construction de la variable auxiliaire sumVar faite." puts "" printVars end =20 ########################################################################=20= #### def buildConstraints # # Toutes les cellules doivent contenir une variable diff=E9rente # # Bug jruby 1.0 ?? : IntDomainVar non reconnu # @pb.post(@pb.allDifferent( @vars.to_java(IntDomainVar) )) @pb.post(@pb.allDifferent(@vars.to_java=20 ("choco.integer.IntDomainVar") )) puts "Construction de la contrainte allDifferent faite." # # Contraintes de la forme "somme de toute ligne est =E9gale =E0 = =20 sumVar" # for i in 0...@n # 1 - first solution : one create and fill a typed java =20 array # row =3D IntDomainVar[@n].new # Fill java array with choco variable for j in 0...@n row[j] =3D @vars[i*@n+j] end # With ruby operator overloading, the folowing could be # writable as: # constraint =3D (@pb.sum(row) =3D=3D @sumVar) # but choco need some work to make this easier ! constraint =3D @pb.eq(@pb.sum(row), @sumVar) @pb.post constraint # # 2 - Second solution : play with ruby list, then convert # # it to the java array befor passing to choco method. # # # row =3D [] # for j in 0...@n # row << @vars[i*@n+j] # end # jrow =3D row.to_java("choco.integer.IntDomainVar") # c =3D @pb.eq(@pb.sum(jrow), @sumVar) # @pb.post c end puts "Construction des contraintes de lignes faite." # Contraintes de la forme "somme de toute colonne est =E9gale =20= =E0 sumVar" # for j in 0...@n col =3D [] for i in 0...@n col << @vars[i*@n+j] end @pb.post(@pb.eq(@pb.sum( col.to_java("choco.integer.IntDomainVar")), =20 @sumVar)) end puts "Construction des contraintes de colonnes faite." # # Egalit=E9 de la somme des deux diagonales # - diag1 : diagonale directe # - diag2 : diagonale inverse diag1 =3D [] diag2 =3D [] for i in 0...@n diag1 << @vars[i*@n+i]; diag2 << @vars[i*@n+(@n-1-i)]; end chocoIntDomVar =3D "choco.integer.IntDomainVar" @pb.post(@pb.eq(@pb.sum(diag1.to_java(chocoIntDomVar)), =20 @sumVar)) @pb.post(@pb.eq(@pb.sum(diag2.to_java(chocoIntDomVar)), =20 @sumVar)) puts "Construction des contraintes des diagonales faite." end def solve puts "Before propagate" # printVars vars begin @pb.propagate rescue # puts "Erreur lors de la propag. initiale" puts "Error while initial propagation" exit end puts "After propagate" # printVars vars puts "Before solve" if SOLVE_ALL @pb.solveAll else @pb.solve end puts "After solve" end def printVars # print "=3D=3D=3D=3D Variables du carre magique de taille = #{@n} =3D=3D=3D=3D" print "=3D=3D=3D=3D Variables of magic squar of size #{@n} = =3D=3D=3D=3D" for i in 0...@vars.length if (i % @n =3D=3D 0) print "\n" end if @vars[i].isInstantiated printf "%4d ", @vars[i].val else printf "%10s ", @vars[i].pretty end end puts "" # print "Somme de chaque ligne/col/diag : sumVar=3D" print "Sum of each line/col/diag : sumVar=3D" if @sumVar.isInstantiated print @sumVar.val else print @sumVar.pretty end puts "" end def printStats if SOLVE_ALL print " (nbSol found: #{@pb.nbSol})\n" print "Last found solution:\n" else print "First found solution:\n" end printVars print "n=3D#{@n} =3D> nbNodes=3D#{@pb.nbNodes} en = #{@pb.nbMillis/=20 1000.0} s." end end # With ruby, one can add methods to existing choco java class class Problem def nbSol getSolver().getNbSolutions() # can be call as : solver.nbSolution end def nbMillis # jruby accepte la conversion implicite de m=E9thode =20 "getSearchSolver()" # en attribut virtuel "searchSolver" # getSolver.getSearchSolver.limits.get(0).getNbTot solver.searchSolver.limits.get(0).nbTot end def nbNodes # getSolver.getSearchSolver.limits.get(1).getNbTot solver.searchSolver.limits.get(1).nbTot end end # ARGV est la liste des arguments transmis au programme MagicSquare.new ARGV puts "FIN" # ./ |
From: Maurice D. <Mau...@en...> - 2007-09-14 12:36:09
|
Le 14 sept. 07 =E0 09:19, Carlos Testera a =E9crit : > Curiously, searching the web, I've found this web address with a =20 > javadoc > of the library in which the distanceEQ method appears, but I don't =20 > know > to which version of the library it corresponds. This is the link: > http://www.ensta.fr/~diam/corlab/online/choco/ > Any help? try: http://www.ensta.fr/~diam/corlab/online/choco.jar it's a link on the version : choco-cvs-20070323.jar Which should correspond to the online doc Note for Hardrien: 1 - wiki seems to have been Hacked http://choco-solver.net/index.php?title=3DDownload_choco 2 - could you hadd some date information naer the version number Change: Version 1.2.04 (jj/mm/yyy) instead of: Version 1.2.04 -- Maurice |
From: Hadrien C. <h.c...@4c...> - 2007-09-14 09:20:52
|
Yes you are right, it seems to be only on cvs. We need to publish a new jar of choco. What you can do is to get choco directly from the cvs : http://choco-solver.net/index.php?=20 title=3DUser_guide#CHOCO_CVS_Source_public_access But I will send you directly the jar. Hadrien Le 14 Sep 2007 =E0 08:19, Carlos Testera a =E9crit : > Hi again. > Hadrien, I have a problem with the distanceEQ method. It doesn't exist > in my version of the choco library. Neither in the javadoc nor in the > code (I've searched for the method in the source, with no results). =20= > I'm > using the 1.2.04 version. Is that the last one?. > Curiously, searching the web, I've found this web address with a =20 > javadoc > of the library in which the distanceEQ method appears, but I don't =20 > know > to which version of the library it corresponds. This is the link: > http://ensta.fr/~diam/corlab/online/choco/ > > Any help? > > Thanks. > > Hadrien Cambazard escribi=F3: >> Hi Carlos, >> >> for |x1-x2|=3D1, you can use pb.distanceEQ(x1,x2,1). >> Otherwise (but it will be less efficient) you can do : >> pb.eq(pb.minus(x1,x2), y); // y =3D x1 - x2 >> pb.abs(y2,y); // y2 =3D |y| >> pb.eq(y2,1); // y2 =3D 1 >> >> Hope it helps >> >> Hadrien >> >> >> Le 13 Sep 2007 =E0 16:39, Carlos Testera a =E9crit : >> >>> Hi. >>> I'm new to choco. I'm doing some tests and examples with the =20 >>> library, >>> and I've found a problem. I've searched in the list and in the =20 >>> forum, >>> but with no results. >>> I would like to add to my problem a constraint of the type |x1-x2|=3D1= >>> I've seen the abs method (it is not in the javadoc), but I don't >>> understand how it works, because it receives two arguments, and I =20= >>> don't >>> know their funcionality. Moreover, I've tryed to make a call like >>> problem.abs(y1,problem.minus(x1,x2)) expecting that it will create a >>> variable (y1) representing the absolute value of the difference =20 >>> of x1 >>> and x2, but that method does not allow an IntExp object as argument. >>> Any help? >>> >>> Thanks >>> >>> --Carlos Testera >>> University of Leon >>> Leon >>> Spain >>> E-mail: >>> car...@un... >>> Phone: >>> +34 987291000 >>> ext 5432 >>> >>> >>> --------------------------------------------------------------------=20= >>> ----- >>> >>> This SF.net email is sponsored by: Microsoft >>> Defy all challenges. Microsoft(R) Visual Studio 2005. >>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> _______________________________________________ >>> Choco-users mailing list >>> Cho...@li... >>> https://lists.sourceforge.net/lists/listinfo/choco-users >> >> > > > --=20 > Carlos Testera > University of Leon > Leon > Spain > E-mail: > car...@un... > Phone: > +34 987291000 > ext 5432 > > > ----------------------------------------------------------------------=20= > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Choco-users mailing list > Cho...@li... > https://lists.sourceforge.net/lists/listinfo/choco-users |
From: Carlos T. <car...@un...> - 2007-09-14 07:19:23
|
Hi again. Hadrien, I have a problem with the distanceEQ method. It doesn't exist in my version of the choco library. Neither in the javadoc nor in the code (I've searched for the method in the source, with no results). I'm using the 1.2.04 version. Is that the last one?. Curiously, searching the web, I've found this web address with a javadoc of the library in which the distanceEQ method appears, but I don't know to which version of the library it corresponds. This is the link: http://ensta.fr/~diam/corlab/online/choco/ Any help? Thanks. Hadrien Cambazard escribió: > Hi Carlos, > > for |x1-x2|=1, you can use pb.distanceEQ(x1,x2,1). > Otherwise (but it will be less efficient) you can do : > pb.eq(pb.minus(x1,x2), y); // y = x1 - x2 > pb.abs(y2,y); // y2 = |y| > pb.eq(y2,1); // y2 = 1 > > Hope it helps > > Hadrien > > > Le 13 Sep 2007 à 16:39, Carlos Testera a écrit : > >> Hi. >> I'm new to choco. I'm doing some tests and examples with the library, >> and I've found a problem. I've searched in the list and in the forum, >> but with no results. >> I would like to add to my problem a constraint of the type |x1-x2|=1 >> I've seen the abs method (it is not in the javadoc), but I don't >> understand how it works, because it receives two arguments, and I don't >> know their funcionality. Moreover, I've tryed to make a call like >> problem.abs(y1,problem.minus(x1,x2)) expecting that it will create a >> variable (y1) representing the absolute value of the difference of x1 >> and x2, but that method does not allow an IntExp object as argument. >> Any help? >> >> Thanks >> >> --Carlos Testera >> University of Leon >> Leon >> Spain >> E-mail: >> car...@un... >> Phone: >> +34 987291000 >> ext 5432 >> >> >> ------------------------------------------------------------------------- >> >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2005. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Choco-users mailing list >> Cho...@li... >> https://lists.sourceforge.net/lists/listinfo/choco-users > > -- Carlos Testera University of Leon Leon Spain E-mail: car...@un... Phone: +34 987291000 ext 5432 |
From: Hadrien C. <h.c...@4c...> - 2007-09-13 16:25:06
|
Hi Carlos, for |x1-x2|=3D1, you can use pb.distanceEQ(x1,x2,1). Otherwise (but it will be less efficient) you can do : pb.eq(pb.minus(x1,x2), y); // y =3D x1 - x2 pb.abs(y2,y); // y2 =3D |y| pb.eq(y2,1); // y2 =3D 1 Hope it helps Hadrien Le 13 Sep 2007 =E0 16:39, Carlos Testera a =E9crit : > Hi. > I'm new to choco. I'm doing some tests and examples with the library, > and I've found a problem. I've searched in the list and in the forum, > but with no results. > I would like to add to my problem a constraint of the type |x1-x2|=3D1 > I've seen the abs method (it is not in the javadoc), but I don't > understand how it works, because it receives two arguments, and I =20 > don't > know their funcionality. Moreover, I've tryed to make a call like > problem.abs(y1,problem.minus(x1,x2)) expecting that it will create a > variable (y1) representing the absolute value of the difference of x1 > and x2, but that method does not allow an IntExp object as argument. > Any help? > > Thanks > > --=20 > Carlos Testera > University of Leon > Leon > Spain > E-mail: > car...@un... > Phone: > +34 987291000 > ext 5432 > > > ----------------------------------------------------------------------=20= > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Choco-users mailing list > Cho...@li... > https://lists.sourceforge.net/lists/listinfo/choco-users |
From: Carlos T. <car...@un...> - 2007-09-13 15:39:49
|
Hi. I'm new to choco. I'm doing some tests and examples with the library, and I've found a problem. I've searched in the list and in the forum, but with no results. I would like to add to my problem a constraint of the type |x1-x2|=1 I've seen the abs method (it is not in the javadoc), but I don't understand how it works, because it receives two arguments, and I don't know their funcionality. Moreover, I've tryed to make a call like problem.abs(y1,problem.minus(x1,x2)) expecting that it will create a variable (y1) representing the absolute value of the difference of x1 and x2, but that method does not allow an IntExp object as argument. Any help? Thanks -- Carlos Testera University of Leon Leon Spain E-mail: car...@un... Phone: +34 987291000 ext 5432 |
From: eran s. <era...@gm...> - 2007-07-30 07:25:35
|
Hello, At first i want thank you all for a wonderful and enjoyably tool you created (Choco). Following "Choco-users Digest, Vol 7, Issue 1", it seemed that and(), or() had some problems. In the file attached, you can see the fix i suggest. Another thing: I am working with Set variables. In the file attached, i added the function opposite() to some classes, so and(), or() won't fail on them (still, i am not sure i added to all classes needed). There are some problems with: choco.bool.AbstractLargeBoolConstraint.setStatus(). With the assert at the beginning. See this code for example: Problem pb = new Problem(); IntDomainVar x1 = pb.makeEnumIntVar("x1", 0, 10); IntDomainVar x2 = pb.makeEnumIntVar("x2", 0, 10); Constraint c2 = pb.gt(x1, 7); Constraint c3 = pb.lt(x2, 3); Constraint c1 = pb.lt(x2, x1); Constraint c = pb.and(c1, c2, c3); pb.post(c); pb.solve(); You will get: Exception in thread "main" java.lang.AssertionError at choco.bool.AbstractLargeBoolConstraint.setStatus(AbstractLargeBoolConstraint.java:81) at choco.bool.AbstractLargeBoolConstraint.setSubConstraintStatus(AbstractLargeBoolConstraint.java:132) at choco.AbstractConstraint.setEntailed(AbstractConstraint.java:207) at choco.integer.constraints.GreaterOrEqualXYC.awakeOnSup(GreaterOrEqualXYC.java:89) at choco.bool.LargeConjunction.awakeOnSup(LargeConjunction.java:52) at choco.integer.var.IntVarEvent.propagateSupEvent(IntVarEvent.java:237) at choco.integer.var.IntVarEvent.propagateEvent(IntVarEvent.java:177) at choco.prop.VarEventQueue.propagateSomeEvents(VarEventQueue.java:54) at choco.AbstractProblem.propagate(AbstractProblem.java:282) at choco.search.AbstractGlobalSearchSolver.incrementalRun(AbstractGlobalSearchSolver.java:153) at choco.Solver.launch(Solver.java:175) at choco.Problem.solve(Problem.java:763) What's wrong? Cheers, Eran Shaham On 7/12/07, cho...@li... <cho...@li...> wrote: > Send Choco-users mailing list submissions to > cho...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/choco-users > or, via email, send a message with subject or body 'help' to > cho...@li... > > You can reach the person managing the list at > cho...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Choco-users digest..." > > > Today's Topics: > > 1. Pb with boolean using version 1.2.04 (coletta) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 12 Jul 2007 11:07:31 +0200 > From: coletta <co...@li...> > Subject: [Choco-users] Pb with boolean using version 1.2.04 > To: cho...@li... > Message-ID: <469...@li...> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Dear all, > > Please find bellow a short TestCase, producing an AssertionError > in AbstractLargeBoolConstraint. > > Thanks for your help ;-) > > Best regards, > -- > Remi > > import static org.junit.Assert.*; > import junit.framework.TestCase; > > import choco.Constraint; > import choco.Problem; > import choco.bool.LargeConjunction; > import choco.integer.IntDomainVar; > import choco.integer.constraints.GreaterOrEqualXYC; > > public class TestChocoBoolean extends TestCase { > > public static void testBoolean() { > Problem pb = new Problem(); > IntDomainVar e1= pb.makeEnumIntVar("e1", 0,4); > IntDomainVar s1= pb.makeEnumIntVar("s1", 0,4); > IntDomainVar e2= pb.makeEnumIntVar("e2", 0,4); > IntDomainVar s2= pb.makeEnumIntVar("s2", 0,4); > > IntDomainVar extraVar= pb.makeEnumIntVar("extra", 0,1); > > Constraint[] tab = new Constraint[3]; > tab[0] = new GreaterOrEqualXYC(e1,s1,0); > tab[1] = new GreaterOrEqualXYC(e2,s2,0); > tab[2] = new GreaterOrEqualXYC(s2,e1,1); > Constraint before = new LargeConjunction(tab); > > pb.post(pb.ifThen(pb.eq(extraVar,1),before)); > pb.solveAll(); > } > } > > > > > ------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > > ------------------------------ > > _______________________________________________ > Choco-users mailing list > Cho...@li... > https://lists.sourceforge.net/lists/listinfo/choco-users > > > End of Choco-users Digest, Vol 7, Issue 1 > ***************************************** > |
From: Sylvain B. <syl...@ce...> - 2007-07-18 09:33:16
|
Hello all, Choco, version 1.2.04, seems to have some problems to handle boolean constraints of linear constraints correctly (or do I misuse Choco ?). Just consider the following example: Problem p = new Problem(); IntDomainVar[][] v = p.makeEnumIntVarArray("v", 3, 2, 0, 1); Constraint[] tab = {p.eq(p.sum(v[0]), 2), p.eq(p.sum(v[1]), 2), p.eq(p.sum(v[2]), 2)}; Constraint c = p.or(tab); p.post(c); if (p.solve().booleanValue()) { System.out.print("v[0] = [" + v[0][0].getVal() + ", " + v[0][1].getVal() + "] / "); System.out.print("v[1] = [" + v[1][0].getVal() + ", " + v[1][1].getVal() + "] / "); System.out.print("v[2] = [" + v[2][0].getVal() + ", " + v[2][1].getVal() + "] - > c"); System.out.println(c.isSatisfied() ? " satisfied." : " not satisfied!!!"); } while (p.nextSolution().booleanValue()) { System.out.print("v[0] = [" + v[0][0].getVal() + ", " + "[0][1].getVal() + "] / "); System.out.print("v[1] = [" + v[1][0].getVal() + ", " + v[1][1].getVal() + "] / "); System.out.print("v[2] = [" + v[2][0].getVal() + ", " + v[2][1].getVal() + "] - > c"); System.out.println(c.isSatisfied() ? " satisfied." : " not satisfied!!!"); } It produces the following output: v[0] = [0, 0] / v[1] = [0, 0] / v[2] = [0, 0] - > c not satisfied!!! v[0] = [0, 0] / v[1] = [0, 0] / v[2] = [0, 1] - > c not satisfied!!! v[0] = [0, 0] / v[1] = [0, 0] / v[2] = [1, 0] - > c not satisfied!!! v[0] = [0, 0] / v[1] = [0, 0] / v[2] = [1, 1] - > c satisfied. ... (Solving the problem leaves some constraints obviously unsatisfied.) However, replacing in the previous example the array tab by: Constraint[] tab = {p.and(p.eq(v[0][0], 1), p.eq(v[0][1], 1)), p.and(p.eq(v[1][0], 1), p.eq(v[1][1], 1)), p.and(p.eq(v[2][0], 1), p.eq(v[2][1], 1))}; (which is semantically equivalent), produces the right output. Do you have an idea about where the problem can come from ? Just another little problem with boolean binary constraints. The following code: Constraint c = p.or(tab[0], tab[1]); System.out.println(" " + c.isSatisfied()); produces a NullPointerException at choco.bool.BinDisjunction.isSatisfied(BinDisjunction.java:186). Thanks for any help! Sylvain Bouveret. |
From: coletta <co...@li...> - 2007-07-12 09:08:31
|
Dear all, Please find bellow a short TestCase, producing an AssertionError in AbstractLargeBoolConstraint. Thanks for your help ;-) Best regards, -- Remi import static org.junit.Assert.*; import junit.framework.TestCase; import choco.Constraint; import choco.Problem; import choco.bool.LargeConjunction; import choco.integer.IntDomainVar; import choco.integer.constraints.GreaterOrEqualXYC; public class TestChocoBoolean extends TestCase { public static void testBoolean() { Problem pb = new Problem(); IntDomainVar e1= pb.makeEnumIntVar("e1", 0,4); IntDomainVar s1= pb.makeEnumIntVar("s1", 0,4); IntDomainVar e2= pb.makeEnumIntVar("e2", 0,4); IntDomainVar s2= pb.makeEnumIntVar("s2", 0,4); IntDomainVar extraVar= pb.makeEnumIntVar("extra", 0,1); Constraint[] tab = new Constraint[3]; tab[0] = new GreaterOrEqualXYC(e1,s1,0); tab[1] = new GreaterOrEqualXYC(e2,s2,0); tab[2] = new GreaterOrEqualXYC(s2,e1,1); Constraint before = new LargeConjunction(tab); pb.post(pb.ifThen(pb.eq(extraVar,1),before)); pb.solveAll(); } } |