[gecode-users] Porting attributed variables

Guido Tack tack at ps.uni-sb.de
Wed Dec 17 13:49:32 CET 2008


Maria Garcia de la Banda wrote:
> Total newbie question (from an LPer): assume that, during search, I  
> want
> to add some extra prunnings for all search variables that have a
> particular attribute (e.g., they apper in a given constraint, or they
> appear in some data structure I am maintaining, or whatever). In  
> some LP
> languages this could easily be done by using "attributed variables",  
> i.e.,
> variables to which extra information can be attached and consulted/
> modified during execution.

Do you want to do the extra pruning in the branching?  E.g., collect  
some attributes for particular variables, and then perform the  
branching based on these attributes?  This reminds me of branchings  
for scheduling, where propagators determine precedences between  
activities, and the branching uses this precedence information to  
order activities.  Is that a similar scenario?

> The question is: how could I do (easily) this in gecode? Using the
> reflection API?

With reflection you can only get information about the variable  
domain, but you can't add extra information.  But you can simply  
introduce an additional data structure that collects the attributes,  
and that is shared between the branching and whoever is responsible  
for maintaining the attributes (e.g. some propagators).
You'd only have to make sure that a) the data structure is copied  
properly, and b) that the branching is still compatible with  
recomputation.  For a), you could abuse a SharedArray and always set  
the bool share flag to false during update.  For b), you have to  
record at each branching step which prunings your branching does, and  
encode them in the BranchingDesc, so that later recomputation steps  
can perform the exact same prunings again.

That's just the overall idea, if you need more concrete hints how to  
implement this, just ask.

Cheers,
	Guido





More information about the gecode-users mailing list