[gecode-users] Copying spaces
Malcolm Ryan
malcolmr at cse.unsw.edu.au
Wed Feb 4 09:06:09 CET 2009
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
More information about the gecode-users
mailing list