In order to save memory, I've been trying to turn my planning code into a two stage in which the first stage only creates and constrains a certain critical subset of variables. When all the first-stage variables have been assigned, additional variables are created and a second stage of search occurs. The two stages are not completely independent however, and there may be failures in the second stage which require backtracking into the first. This should save memeory, since the second-stage variables don't have to be carried around during the first-stage search.
I was hoping that I could do this simply by adding new variables and constraints in the copy constructor at the appropriate moment, but it seems that this does not work. I wrote a simple test case to check: public class Test extends Space { IntVar a, b; public Test() { super("test"); a = new IntVar(this, "a", 1, 4); } public Test(Boolean share, Test old) { super(share, old); a = old.a.copy(this, share); if (a.assigned()) { if (b == null) { b = new IntVar(this, "b", 1, 4); Gecode.rel(this, a, IntRelType.IRT_EQ, b); } else { b = old.b.copy(this, share); } } else { b = null; } } public static void main(String[] args) { Test test = new Test(); System.out.println("Status: " + test.status()); test = (Test) test.cloneSpace(); System.out.println("Status: " + test.status()); System.out.println("a = " + test.a); System.out.println("b = " + test.b); Gecode.rel(test, test.a, IntRelType.IRT_EQ, 3); System.out.println("Status: " + test.status()); System.out.println("a = " + test.a); System.out.println("b = " + test.b); test = (Test) test.cloneSpace(); System.out.println("Status: " + test.status()); System.out.println("a = " + test.a); System.out.println("b = " + test.b); Gecode.rel(test, test.b, IntRelType.IRT_EQ, 1); System.out.println("Status: " + test.status()); System.out.println("a = " + test.a); System.out.println("b = " + test.b); } } The constraint Gecode.rel(this, a, IntRelType.IRT_EQ, b); seems to have no effect. I can set a = 3, b = 1 and the status will still be SS_SOLVED. I'm not entirely surprised. I presume that I am breaking some assumptions in the system. Is there any other way to do a two-stage search like this? Malcolm _______________________________________________ Gecode users mailing list [EMAIL PROTECTED] https://www.gecode.org/mailman/listinfo/gecode-users