[gecode-users] InVarArray methods

Patrik Haslum patrik.haslum at anu.edu.au
Tue Dec 9 11:21:21 CET 2008


Hi,
Actually, I'm a bit confused over Var's and VarArrays too. My 
understanding (and please correct me if I'm wrong) is that a Var or 
VarArray (and similarly ArgArrays; not sure what's the difference with 
them) holds only pointers/references to the actual variables, which are 
(in some slightly magic fashion) associated with the space object. Does 
this mean that having all variables in VarArrays that are members of the 
Space-derived object (and doing .updates on them in the copy 
constructor) is in fact not necessary? (execpt if I want to do something 
else with the variables, such as print them after a solution has been 
found). The actual variables (as opposed to the pointers stored in a 
Var/VarArray) would get copied/updated anyway? It seems to work, but I 
haven't found a clear indication either way in the documentation.

Julian, if you want to assign a value to an integer variable (that your 
IntVar holds a reference to), I think you have to do it by posting a 
constraint. For example,

dom(this, X, 4, 4)

would constrain the IntVar X so that 4 <= X <= 4 (here assuming the call 
is made from within a method of the space-derived class; otherwise put a 
pointer to the space instead of "this").

cheers,
			/P at trik


Christian Schulte wrote:
> You can only print fields after they have been initialized.
> 
> If you say "assign values" what do you mean? Assigning variables to fields
> in thne array? Or, assigning values to the variables stored at a fields in
> the array?
> 
> Did you look at the examples that come with Gecode?
> 
> --
> Christian Schulte, www.ict.kth.se/~cschulte/
> 
> 
> -----Original Message-----
> From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
> Of Julian Cardona
> Sent: Monday, December 08, 2008 6:32 PM
> To: users at gecode.org
> Subject: [gecode-users] InVarArray methods
> 
> Hey people i feel very idiot posting this but i have no idea hot to assign 
> values to a IntVarArray, i mean, i have an IntVarArray and i can initialize
> it 
> how it is described in the API but i dont know how to assign arbitrary
> vaules 
> to it.
> I cant figure out why i can print out the value of a desired position:
> std::cout << MyIntVarArray[i] << std::endl;
> but im unable to assign values to it in the common way:
> MyIntVarArray[4] = element;
> 
> Please help me!!!
> 
> 
> 
> 
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
> 
> 
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list