[gecode-users] Problem with he creation of a "branching" class

Mikael 'Zayenz' Lagerkvist zayenz at gmail.com
Fri Mar 10 08:25:10 CET 2006


On 3/9/06, Javier Andrés Mena Zapata <javimena at gmail.com> wrote:
> I'm creating a Branching class for scheduling. I don't undestand what
> is going wrong.
> Sometimes the Space class throws an exception:
>
> 00271         throw SpaceFailed("Space::commit");
>
> I don't undestand very well what I'm doing wrong... maybe I should use
> Views and not Arrays, but I need the var to impose the constraints on
> the new Spaces. Currently even if I don't impose new constraints, it
> doesn't works.

I saw one trouble with your code that is quite serious. The
branch-function of a Branching may be called multiple times before the
commit-function is called. Therefor, you should make sure that the
branch-function just computes the pair (i,j) once for each new node.

Consider the output that you produce:
   SchedulingBranch(Space* home, IntVarArray& liv)
   var: 0 and 1
   virtual Actor* copy(Space* home, bool share)
   start
   var: 0 and 2
   virtual Actor* copy(Space* home, bool share)
   branching in L vars 0 and 2
Here we see that branch() (producing the "var..."-lines) is called
twice before commit(...) (producing the "Branching..."-line).

As for View's and Var's, Guido Tack wrote recently:
> You can create an IntView from an IntVar, without going through the IntVarImp.
> Views provide the modifying operations. The rationale behind this design is
> to separate between modelling and writing propagators. For modelling, you
> only use variables. If you write propagators, you use views.

For posting constraints from a branching, you should use the
propagators directly, by calling their post-functions. See
http://www.gecode.org/gecode-doc-latest/classGecode_1_1Int_1_1Rel_1_1Le.html
for documentation about the less-than propagator. It is important that
you check the return-value from the post-function so that you don't
miss a failure.


> Currently I'm not using recomputation (BranchingDesc).

The code you sent does use recomputation and branching-descriptions,
but as far as I can tell, it looks ok.

Hope this helps
Mikael

--
Mikael 'Zayenz' Lagerkvist, http://www.imit.kth.se/~zayenz/




More information about the gecode-users mailing list