Gustavo Gutierrez wrote:
lems with VarMaps. As you said there are two ways to fill a VarMap:
by using put and putArray methods and by iterating on actor
specifications. I tried the second but because of a design decision
in the past we cannot use it. In our design we have a class
GenericSpace which inherits from Gecode::Space. This class has an
attribute that contains a DynamicArray with all variables declared
in a computation space. This array contains VarBase pointers
(VarImpBase in the trunk version). To fill the VarMap i am using the
following code:
void GenericSpace::merge(GenericSpace *src) {
Reflection::VarMap vm;
for (int i = 0; i < src->vars.getSize(); i++) {
std::stringstream s;
s << "src-" << i;
vm.put(src,src->vars.getVar(i),s.str().c_str());
}
printf("End merge operation\n");fflush(stdout);
}
getVar(i) returns a reference to the VarImpBase stored at position i
in the array. When building the following error appears:
You cannot use put with a VarImBase*, you always have to go through
the actual variable. This is like update: You cannot call update on a
VarImpBase*, only on a Var (or View). The reason is that we do not
want variables to have any virtual functions. I guess you have some
flag indicating which VarImpBase* has which actual variable type, so
that you can copy (update) variables. You should use the same
information for merge. Cast the VarImpBase* to the corresponding
IntVarImp* (or SetVarImp* or whatever you have), then use that to get
an IntVar (or SetVar...), and then call vm.put with that variable.
Cheers,
Guido
_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users