[gecode-users] If then type constraints

Malcolm Ryan malcolmr at cse.unsw.edu.au
Mon Mar 10 09:14:00 CET 2008


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/





More information about the gecode-users mailing list