# [gecode-users] BoolExpr example

Malcolm Ryan malcolmr at cse.unsw.edu.au
Mon Nov 24 02:27:24 CET 2008

```I'm sorry. I still don't completely understand how to us post. Say I
have a constraint like:

((X1 == Y1) && (X2 == Y2) && ... && (XN == YN)) --> L > 0

for general 'N'.

What I've got is:

BoolVar allEqual;
BoolVarArgs eq = BoolVarArgs(nRobots);
for (int r = 0; r < N; r++) {
eq[r] = post(space, ~(X[r] == Y[r]));
}
rel(space, BOT_AND, noop, allEqual);

post(space, !allEqual || (L > 0));

But I'm getting compilation errors on both the 'post' lines. What
should they be? Why?

Finding documentation on 'post' is tricky, since there are so many
different instances of this function across many files. I'm a bit
uncomfortable with the fact that sometimes it adds an actual
constraint and sometimes it just creates a reified BoolVar. How do I
know which case is which?

Malcolm

On 21/11/2008, at 5:57 PM, Mikael Zayenz Lagerkvist wrote:

> On Fri, Nov 21, 2008 at 4:13 AM, Malcolm Ryan <malcolmr at cse.unsw.edu.au
> > wrote:
>> 1) What's the difference between BoolVarArgs and BoolVarArray?
>
> BoolVarArgs is optimized for constructing temporary argument arrays to
> pass to constraints. BoolVarArrays are intended to be used for storing
> BoolVars in a Space.
>
>
>> 2) Could you explain in more detail what ~ does?
>
> The ~-operator takes a linear relation and reifies it (makes it a
> BoolExpr).
>
>
>> 3) Likewise, what does tt() do?
>
> It enforces that a Boolean expression should be true. There is an
> corresponding function ff for enforcing it to be false.
>
>
>> 4) Under exactly what conditions does post() create a BoolVar?
>
> When the expression posted is a BoolExpr and not a BoolRel.
>
>
>> 5) How's the documentation coming along?
>
> I'll leave this question for Christian.
>
>
> Cheers,
> Mikael
>
> --
> Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/

```