[gecode-users] About posting Boolean expression

Christian Schulte cschulte at kth.se
Mon Oct 19 17:10:21 CEST 2009


Nope, MwG is correct on that respect. "x && imp(y,z)" is a Boolean
expression, whereas "a[j] == i+1" is a relation (constraint). Posting a
Boolean expression yields a Boolean variable, posting a relation does not.
Please check the definition of expressions and relations in MwG.

 

Cheers

Christian

 

--

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

 

From: Yong [mailto:yong.huang.2777 at student.uu.se] 
Sent: Monday, October 19, 2009 4:56 PM
To: Christian Schulte
Cc: users at gecode.org
Subject: Re: [gecode-users] About posting Boolean expression

 

Hi Christian,
Thanks for your prompt reply.

The code I wrote was following the example from Section 6.2 Boolean
expressions and relations of <<Modeling with Gecode>>(for Gecode3.1.0). The
original example is:
"
For example, the Boolean expression x && imp(y,z) (to be read as x ? (y ?
z)) for Boolean variables x, y, and z is posted by:
    BoolVar b=post(home, x && imp(y,z));
"
So, is it my inaccurate understanding of this example or the example itself
is not expressed in an accurate way? 

Yong

Christian Schulte wrote: 

Write instead:

 

BoolVar tmp =post(*this, ~(a[j]==(i+1)),ICL_DEF);

 

What you did is posting the constraint that (a[j] == (i+1)) (and hence the
return type of post is void as the compiler tells you). What you apparently
wanted to do is to post a reified constraint which you get with ~ (and hence
the return type is BoolVar).

 

Cheers

Christian

 

--

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

 

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Yong
Sent: Monday, October 19, 2009 3:26 PM
To: users at gecode.org
Subject: [gecode-users] About posting Boolean expression

 

Hi group,
A question about posting Boolean expression here. Any hint will be
appreciated!

My compiler will give "cannot convert from 'void' to 'Gecode::BoolVar'"
error on below code:

BoolVar tmp =post(*this,(a[j]==(i+1)),ICL_DEF);

Yong

ps: I'm using Gecode3.2.0 + VC++ 2008 Express Edition

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20091019/63b7b627/attachment.htm>


More information about the gecode-users mailing list