From: Vicenç <vgomez_at_iua.upf.edu>

Date: Mon, 24 Sep 2007 12:34:12 +0200

Date: Mon, 24 Sep 2007 12:34:12 +0200

Dear all, I needed to constrain from above and below a sum of variables whose domains are sets of integer values. I did in that way, using the ic library. For instance: X::[1,2,3], Y::[0,1], Z::[0,2], X+Y+Z #< 6, X+Y+Z #> 4, writeln([X,Y,Z]), labeling([X,Y,Z]). fine. I got [X{[2, 3]}, Y{[0, 1]}, 2] after the writeln, since Z must be instantiated to 2 to fulfill the 2nd constraint. But now, I would like to use sets of real numbers instead of integers. How is the proper method for doing an equivalent program? After loading lib(ic) and lib(propia), I declare the domains and use the $< and $> operators: member(X,[1.0,2.0,3.0]) infers ic, member(Y,[0.0,1.0]) infers ic, member(Z,[0.0,2.0]) infers ic, X+Y+Z $< 6.0, X+Y+Z $> 4.0 after this, I got: X = X{1.0 .. 3.0} Y = Y{0.0 .. 1.0} Z = Z{0.0 .. 2.0} There are 5 delayed goals. Yes (0.00s cpu) Two questions: 1.- Why the domain of Z has not been reduced? What can I do to propagate the constraint? 2.- How can I force the instantiation of all the variables? If I use labeling([X,Y,Z]), I got the type error: type error in indomain(X{1.0 .. 3.0}) many thanks, VicençReceived on Mon Sep 24 2007 - 11:33:27 CEST

*
This archive was generated by hypermail 2.2.0
: Thu Feb 02 2012 - 02:31:58 CET
*