Yes, that's right. No caveats. It is as you say: you only have to update yourself if you want to use them for your own purposes, the rest the propagator, brancher, etc in question take care of.
Best Christian -- Christian Schulte, https://chschulte.github.io/ Professor of Computer Science, KTH, [email protected] Expert Researcher, RISE SICS, [email protected] -----Original Message----- From: [email protected] <[email protected]> On Behalf Of Sebastian Albert Sent: Wednesday, March 21, 2018 17:40 To: [email protected] Subject: [gecode-users] Variable implementations are copied automatically during search, right? Dear Gecode users and maintainers I was wondering whether I can use auxilliary variables to formulate and post constraints (i.e., propagators) in my model in the initial constructor without copying them in the copy constructor (as long as I don't want to use their values later on and thus do not need them as member variables in my Space subclass). It seems that this is true and everything still works correctly. (However, I may need to post branchings for them, too, depending on how they are used.) Am I right? So, I conclude that variable implementations are taken care of either by the Space or indirectly when the propagators/branchers are copying their views. Are there any caveats? Here's a small working example (which is not useful, but a test to experiment whether I am right): using namespace Gecode; class Test : public Space { protected: IntVar a, b; public: Test(void) { a = IntVar(*this, 1, 5); b = IntVar(*this, 1, 5); IntVar a_temp = IntVar(*this, 1, 5); IntVar b_temp = IntVar(*this, 1, 5); rel(*this, a == a_temp); rel(*this, b == b_temp); rel(*this, 2 * a_temp == b_temp); branch(*this, a, INT_VAL_MED()); branch(*this, b, INT_VAL_MED()); } void print(void) const { std::cout << a << " " << b << std::endl; } Test(Test& s) : Space(s) { a.update(*this, s.a); b.update(*this, s.b); } virtual Space* copy() { return new Test(*this); } }; Thanks Sebastian _______________________________________________ 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
