What is the correct way to create a copy of a space? I'm confused by  
the behaviour of the following example:

class MySpace: public Space {
private:
        IntVar x;
public:
        MySpace() : Space(), x(this, 1, 4) {}

        MySpace(bool share, MySpace& old) : Space(share, old) {
                x.update(this, share, old.x);
        }

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

        virtual ~MySpace() {}
};

void CompletePlanVarTest::testUpdate0() {

        MySpace *space = new MySpace();
        cout << "Status: " << space->status() << endl;

        Space *copySpace = space->copy(true);
        cout << "Status: " << copySpace->status() << endl;
}

The output is:

Status: 1
Status: 0

That is the first space is solved (because it has no branchings) but  
the second space has failed. Why?

Is this not the right way to copy a space? Or have I implemented the  
space wrongly?

Malcolm

_______________________________________________
Gecode users mailing list
us...@gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to