[gecode-users] Re: Var indexes-help
Guido Tack
tack at ps.uni-sb.de
Wed Feb 7 13:26:19 CET 2007
> Hi!
> (Sorry for so much questions on var indexes..)
No problem.
> I have an IntVar, say I, to specify an index of a VarArray and
> I want to post some constraints (like element, linear) for indexes
> between 0(zero) and I.
>
> is there a way to express;
>
> if (current_index < I ) then element(....) + linear(....)
>
> And generally speaking, I cant see the way to tell the
> if___then___ structure.
You can model this using reified constraints and Boolean implication:
BoolVar b0(this, 0, 1);
BoolVar b1(this, 0, 1);
rel(this, I, IRT_GR, current_index, b0);
linear(...., b1);
rel(this, b0, BOT_IMP, b1, 1);
However, there is no reified version of element, you'll have to
express that in a different way.
Cheers,
Guido
More information about the gecode-users
mailing list