[gecode-users] Why are my variables not constrained 2

Max chaosangel at gmx.de
Sun Oct 5 13:03:33 CEST 2008


I'm sorry for not answering to the last topic, but i seem to have 
problems with the mailing list, i hope this message will be seen.

Thank you for the hint with the status function, that should be what i need.
I found an example in the exmaples folder and tried my little example 
and can not explain the results:


class MyConstraint : public Space
{
    public:
        MyConstraint() : Space(), x(this,1,0,150), y(this,1,0,1)
        {
              post(this, eqv((x[0] != 0), y[0]));
              post(this, x[0] == 0);
              post(this, y[0] == 1);
              status();
       

}

        MyConstraint(bool share, MyConstraint& cp) : Space(share, cp)
        {
            x.update(this, share, cp.x);
            y.update(this, share, cp.y);
        }

        virtual Space* copy(bool share)
        {
            return new MyConstraint(share, *this);
        }

        IntVarArray x;
        BoolVarArray y;
};


int main(int args, char** argv)
{
    MyConstraint* myC = new MyConstraint();
    Search::Options so;
    DFS<MyConstraint> e(myC,so); // depth first search
    delete myC;                    // Constraints can be thrown away, 
they are copied
   
    MyConstraint* temp = e.next();
    temp->status();
    while(temp != NULL) // find all solutions
    {
        std::cout << temp->x << " und y= " << temp->y << std::endl;
        temp = e.next();
    }

    return 0;
}



The intended meaning should be, x=0, y=1, if y==1 then x !=0

As a result i get:
{0} und y= {1}

The ssame results with branching on y (without setting it to 1)
i do get 2 results
{0} und y= {1}
{0} und y= {0}

So the first constraint is never apllied, what am i doing wrong ?!?!

Tank you for the help.






More information about the gecode-users mailing list