[gecode-users] Return value of Branching::commit
Guido Tack
tack at ps.uni-sb.de
Sat Jun 21 09:24:11 CEST 2008
Chris Mears wrote:
> How should the return value of commit be constructed in a custom
> Branching class? In the QueenArmies example (copied below), a single
> constraint is posted whose ModEvent value is converted into an
> ExecStatus value by me_failed, and that ExecStatus is returned.
[...]
> However, what if a commit posts many constraints? Is it necessary to
> observe the ModEvent returned by every posted constraint, and return
> ES_FAILED if any of them returns ME_INT_FAILED?
Yes. You can use the GECODE_ME_CHECK and GECODE_ES_CHECK macros, like
this:
GECODE_ME_CHECK(Int::BoolView(q->w[pvd->pos()]).eq(q, val));
GECODE_ME_CHECK(something else);
GECODE_ES_CHECK(call some constraint posting function that returns an
ExecStatus);
return ES_OK;
The macros return ES_FAILED if the ModEvent or ExecStatus is failed,
and otherwise do nothing.
> (My overall aim is to implement some kind of dynamic symmetry
> breaking.
> If a search node branches left with (X = v) and right with (X /= v),
> I'd
> like to post additional constraints on the right branch -- for
> example,
> if X and Y are symmetric, I'd also post (Y /= v). )
Yes, that's no problem.
Cheers,
Guido
More information about the gecode-users
mailing list