[gecode-users] Saving memory with IntVarArrays
Malcolm Ryan
malcolmr at cse.unsw.edu.au
Mon Mar 2 05:34:36 CET 2009
A question about IntVarArrays:
I have a large CSP that I have coded to be constructed incrementally
as the search proceeds to reduce memory usage. To simplify, lets say
that I have an array of N variables for some large N, and each one is
constrained by some relationship with its neighbours. Rather than
create all N variables and N-1 constraints immediately, I create and
constrain variables incrementally once the previous variable has been
assigned. (My real situation is actually more complex than this, but
my question remains the same).
Currently, I create an IntVarArray as:
vars = IntVarArray(space, N);
and then incrementally create variables as:
vars[t] = IntVar(space, domainSet);
My question is: does this actually save memory? I assume that creating
the array created N 'uninitialised' IntVars. Are these variables
significantly smaller than initialised IntVars? Or is this a false
saving? Would I be better to create a smaller IntVarArray and replace
it with an incrementally longer one as variables are created?
Thanks,
Malcolm
More information about the gecode-users
mailing list