[Newbie] If statement and contraint programming

duchier at ps.uni-sb.de duchier at ps.uni-sb.de
Mon Apr 28 10:35:59 CEST 2003


thomas.ludwig at wanadoo.fr (Thomas LUDWIG) writes:

> 	if C.(I-1) \= C.(I-3) then C.I =: 1 end

In addition to Raphael's suggestion, here is my take on writing such
an implication.  You have to express it as a logical implication (a
constraint) rather than a procedural implication.  This is frequently
done using '=<:'.  For example:

	(C.(I-1)\=:C.(I-3)) =<: (C.I=:1)

Why does this work?  It has the form B1=<:B2 where both B1 and B2 are
boolean variables, i.e. FS variables taking values in 0#1.  Thus when
B1=1 (i.e. is true), then B2 (taking values in 0#1) must also be 1
(i.e. true) - this takes care of the forward implication B1->B2.  When
B2=0 (i.e. is false), then B1 (taking values in 0#1) must also be 0
(i.e. false) - this takes care of the backward implication ~B2->~B1
(where I write ~ for negation).

Cheers,

-- 
Denys Duchier - Équipe Calligramme - LORIA, Nancy, France
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
Please send bug reports to bugs at mozart-oz.org.





More information about the mozart-users mailing list