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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to