[gecode-users] Views and serialization

Guido Tack tack at ps.uni-sb.de
Mon Nov 26 10:02:05 CET 2007


Gustavo Gutierrez wrote:

> On Nov 23, 2007 5:04 PM, Guido Tack <tack at ps.uni-sb.de> wrote:
>> After iterating all the actors, vmp will contain all variables in
>> source, and you can iterate them using a VarMapIter.  For each
>> variable, you get a VarSpec that tells you what type the variable
>> has.  Furthermore, you can use the spec you get to recreate the
>> variable in target:
>
> Does this mean that creating a VarMap is not only achieved by putting
> the VarArray but also by iterating all the actors?.

Yes, with the difference that you don't know the identity of variables  
that were put in by iterating the actors.

> I mean, for the queens problem for instance, the following two codes
> do the same in which respects to filling a VarMap?
>
> code 1:
>
>  VarMap * exportVars(void) {
>    VarMap *vmp = new VarMap();
>    Support::Symbol symb("root",true);
>    vmp->putArray(this,q,symb);
>    return vmp;
>  }
>
>
> code 2:
>
> VarMap * exportVars2(void) {
>    VarMap *vmp = new VarMap();
>    SpecIter si = actorSpecs(*vmp);
>   while (si())
>    ++si;
>   return vmp;
>  }
>
> If that is true i find the second a more general approach, since it
> automatically collects only variables related to constraints.

In realistic examples, you probably need both.  The logic is exactly  
the same as for copying:  You copy the variables that make up your  
solution explicitly, so that they are available in the copy.  All  
other variables are copied if needed (i.e., referenced by propagators  
or branchings) and discarded otherwise.

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/20071126/8c0daffb/attachment.bin>


More information about the gecode-users mailing list