[gecode-users] If then type constraints

Christian Schulte cschulte at kth.se
Tue Mar 11 00:03:35 CET 2008


Well, caution is always good but I have never come across an example where
Boolean variables obtained from reification needed extra labeling: typically
the reified expressions make some statement about the variables being
labeled and as Guido pointed out, as soon as all variables but the control
variable is assigned then the control variable will be assigned (that is
required of a reified propagator).

Christian

--
Christian Schulte, www.ict.kth.se/~cschulte/

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Mikael Zayenz Lagerkvist
Sent: Monday, March 10, 2008 7:44 PM
To: Malcolm Ryan
Cc: gecode list
Subject: Re: [gecode-users] If then type constraints

Using BExpr-constructions will create the Booleans in the background,
so you have to be extra careful that instantiating the input variables
is sufficient to determine whether the expresison succeeds or fails.
Otherwise, good luck.

Cheers,
Mikael

On Mon, Mar 10, 2008 at 9:14 AM, Malcolm Ryan <malcolmr at cse.unsw.edu.au>
wrote:
> I've discovered that I can do what I want by posting BExprs anyway,
>  and never have to create all those reified Booleans. Yay.
>
>  Malcolm
>
>
>
>  On 10/03/2008, at 6:42 PM, Mikael Zayenz Lagerkvist wrote:
>
>  > For all reified constraints that I can think of, instantiating the
>  > "base" variables will also mean that the Boolean variable will get
>  > instantiated. However, if you build more complicated expressions with
>  > the Booleans and additional intermediate variables, then these might
>  > not be instantiated. For example, think of the following constraint
>  > system
>  >    IntVar x;
>  >    BoolVar IsA, IsB, Neither;
>  >    x = a   <=>  IsA;
>  >    x = b   <=>  IsB;
>  >    IsA \/ IsB \/ Neither;
>  > The variable Neither will not be instantiated if x is instantiated to
>  > a or b (it can be either true or false, the constraints are satisfied
>  > either way).
>  >
>  > Cheers,
>  > Mikael
>  >
>  > On Mon, Mar 10, 2008 at 5:05 AM, Malcolm Ryan <malcolmr at cse.unsw.edu.au
>  > > wrote:
>  >> If I use reification like this, do I have to write my search code so
>  >> that it instantiates all the booleans as well as all the 'normal'
>  >> variables? Or can I rely on the fact that once all the 'normal'
>  >> variables are instantiated all the booleans should also be
>  >> instantiated.
>  >>
>  >> Malcolm
>  >>
>  >>
>  >>
>  >> On 06/03/2008, at 4:15 PM, Christian Schulte wrote:
>  >>
>  >>> Use reification, that's clumsy but works. So, with minimodeling
>  >>> support it
>  >>> should be something like (~ reifies a linear relation, && is
>  >>> conjunction,
>  >>> imp is implication, and tt means that the statement must be true):
>  >>>      post(home, tt(imp(~(v1 == 2),~(v2 != 1) && ~(v3 != 3)));
>  >>> or directly:
>  >>>      BoolVar b1(home,0,1), b2(home,0,1), b3(home,0,1), b23(home,
>  >>> 0,1);
>  >>>      rel(home, v1, IRT_EQ, 2, b1);
>  >>>      rel(home, v2, IRT_NQ, 1, b2);
>  >>>      rel(home, v3, IRT_NQ, 3, b3);
>  >>>     rel(home, b2, BOT_AND, b3, b23);
>  >>>      rel(home, b1, BOT_IMP, b23, 1);
>  >>>
>  >>> Or check whether extensional constraints work for you.
>  >>>
>  >>> Christian
>  >>>
>  >>> --
>  >>> Christian Schulte, www.ict.kth.se/~cschulte/
>  >>>
>  >>>
>  >>> -----Original Message-----
>  >>> From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On
>  >>> Behalf
>  >>> Of Debdeep Banerjee
>  >>> Sent: Thursday, March 06, 2008 3:03 PM
>  >>> To: users at gecode.org
>  >>> Cc: users at gecode.org
>  >>> Subject: [gecode-users] If then type constraints
>  >>>
>  >>> Hi,
>  >>> How do I model if-then style constraints ? What I want to do is post
>  >>> constraints if a variable is assigned a particular value. For
>  >>> example
>  >>> say  I have variable set V { v1, v2, v3} and each of them has the
>  >>> domain
>  >>> {1,2,3}. what I want to achieve is
>  >>>   if  v1== 2  then
>  >>>        v2 !=1  /\  v3 !=3
>  >>>
>  >>> I know I can do this using a custom propagator, but is there any
>  >>> other way ?
>  >>>
>  >>> With regards
>  >>> Debdeep
>  >>>
>  >>> --
>  >>> Debdeep Banerjee
>  >>> PhD Candidate
>  >>> CSL/RSISE/NICTA
>  >>> Australian National University
>  >>> Email: debdeep.banerjee at rsise.anu.edu.au
>  >>> Web:http://rsise.anu.edu.au/~banerjed
>  >>>
>  >>>
>  >>>
>  >>> _______________________________________________
>  >>> Gecode users mailing list
>  >>> users at gecode.org
>  >>> https://www.gecode.org/mailman/listinfo/gecode-users
>  >>>
>  >>>
>  >>> _______________________________________________
>  >>> Gecode users mailing list
>  >>> users at gecode.org
>  >>> https://www.gecode.org/mailman/listinfo/gecode-users
>  >>
>  >>
>  >> _______________________________________________
>  >> Gecode users mailing list
>  >> users at gecode.org
>  >> https://www.gecode.org/mailman/listinfo/gecode-users
>  >>
>  >
>  >
>  >
>  > --
>  > Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/
>
>
>  _______________________________________________
>  Gecode users mailing list
>  users at gecode.org
>  https://www.gecode.org/mailman/listinfo/gecode-users
>



-- 
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/

_______________________________________________
Gecode users mailing list
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list