[gecode-users] Views and serialization
Guido Tack
tack at ps.uni-sb.de
Tue Nov 27 10:24:24 CET 2007
Gustavo Gutierrez wrote:
> I have a question about the VarMap or VarMapIter. Is it possible to
> know how many variables a VarMap stores, or to access VarBase objects
> through VarMapIter?
No, that functionality was missing. It's now available in the Gecode
trunk.
> . My idea is to iterate on the VarMap and to add
> the VarBase corresponding objects to the q array. The problem is that
> i don't find a method to get the size of the map to use it in a for
> loop. The VarMapIter only provides access to variable specifications
> but not to VarBase objects.
With the added size method, you can implement the iteration yourself
(using the VarBase* var(int i) const; method). If you not only want
to fill an array of VarBase*, but an array of IntVars, BoolVars, or
SetVars, you'll have to cast the VarBase* to the corresponding
variable type. You can do that through the views:
IntVar iv(Int::IntView(static_cast<Int::IntVarImp*>(vm.var(0))))
would create an IntVar from entry 0 of the VarMap vm. You can use the
VarSpec to query the variable type. Currently, vm.spec(0).vti() may
return "VTI_INT", "VTI_BOOL", or "VTI_SET".
Cheers,
Guido
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2436 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20071127/687b3722/attachment.bin>
More information about the gecode-users
mailing list