Copy() is an internal function (maybe we should make it protected) use by the clone() operation. So you have to use clone() to create a clone of a space!
Christian -- Christian Schulte, www.it.kth.se/~cschulte/ -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Malcolm Ryan Sent: Wednesday, February 04, 2009 9:06 AM To: gecode list Subject: [gecode-users] Copying spaces 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 [email protected] https://www.gecode.org/mailman/listinfo/gecode-users _______________________________________________ Gecode users mailing list [email protected] https://www.gecode.org/mailman/listinfo/gecode-users
