The model is that each space maintains its own variables, propagators, and branchers. When you clone a space, also the variables must be cloned. That is what update does. Just assigning the variable does not clone it by that you would create two spaces sharing variables which does not work in Gecode. This is not really an issue, just use update and that's it.
Best Christian -- Christian Schulte, Professor of Computer Science, KTH, www.ict.kth.se/~cschulte/ From: ziche...@gmail.com [mailto:ziche...@gmail.com] On Behalf Of Zhu Zichen's cse Sent: Monday, November 11, 2013 9:07 AM To: cschu...@kth.se Cc: users@gecode.org Subject: Re: [gecode-users] Update function Dear Christian, Thanks for your reply. I read the chapter on Search, but I am still confusing. For sequential search where shared always being true, when I update a BoolVar x, why cannot I simply write x=OldSpace.x? It constraints the two variables to take the same value. They might need extra propagation compared with using update function, but the result should be same. Can you help for this? Many thanks. Zichen On Thu, Nov 7, 2013 at 10:20 PM, Christian Schulte <cschu...@kth.se> wrote: Hi, The answer to the first question is simple: because you have to! Update updates variables during cloning g and is needed for search. Posting a constraint as you suggest is something very different. There can be no global variables in Gecode provided you mean something such as Gecode's integer variables as they are always situated inside a given space (this is the space you given when initializing a Gecode variable). Or dou you mean variable as in C++-variable? Then it does not need to be updated. Maybe you would like to read the chapter on Search in MPG that explains what happens during search in Gecode. Cheers Christian -- Christian Schulte, Professor of Computer Science, KTH, www.ict.kth.se/~cschulte/ From: users-boun...@gecode.org [mailto:users-boun...@gecode.org] On Behalf Of Zhu Zichen's cse Sent: Thursday, November 07, 2013 3:12 PM To: users@gecode.org Subject: [gecode-users] Update function Dear All, For variables, why do we have to use update function when we copying? Why cannot I simply use rel(*this,x==_x)? And there are problems when I use update function to update a global variable from another global variable. What should I do when I update global variables? Best Regards, Zichen Zhu
_______________________________________________ Gecode users mailing list users@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users