[gecode-users] Extending integer and set variables to quantified variables.

Guido Tack tack at ps.uni-sb.de
Thu Mar 9 15:09:34 CET 2006


Hi!

> I am trying to extend Gecode in order to make it solve
> quantified constraints. I would like to stop propagation and
> directly fail if a universally quantified variable is reduced.
> I began to have a look at the IntVar and SetVar classes to see
> how to extend them to add a quantifier information (ForAll our
> Exists), and have them raise an exception if the domain is
> reduced and the quantifier is ForAll.

If I understand you correctly, you want failure if some value is removed from 
a variable's domain. You could easily write a propagator that implements 
exactly this behaviour: as soon as it is invoked, it fails. This works 
because propagators are only invoked if the domain of their variable changes.

> I've been surprised to see that the IntVar class has only
> methods to read information on the variable domain, and that
> the only way to reduce it is : first to access it, using the
> method Variable(), to the IntVarImp object the IntVar
> contains, and only then to invoke the modifying methods to the
> IntVarImp itself (am I right on this point ?). 

You can create an IntView from an IntVar, without going through the IntVarImp. 
Views provide the modifying operations. The rationale behind this design is 
to separate between modelling and writing propagators. For modelling, you 
only use variables. If you write propagators, you use views. One important 
thing is that you may not simply modify a variables domain, you are also 
responsible for checking whether this resulted in failure. If it did, you 
must signal this to the space - otherwise, failure may be overlooked.

> As the methods 
> of the IntVar class to read informations on the variable
> domain is only en encapsulation of the same IntVarDomain
> methods, why are the modifying methods not encapsulated in the
> IntVar class too ?

It's just a matter of clean interfaces. Vars and Views are supposed to be used 
for different things, so we have different interfaces.

> Another thing. I don't know if that would be useful for
> anything else than my issue, but would it be possible to
> declare the value access methode of the IntVar as virtual ?

In the current setup, this wouldn't make much sense. We want to keep as many 
classes non-virtual as possible, as virtual method calls always have a 
significant overhead. What exactly do you plan the overridden value access to 
do? Maybe you could have a look at the Views concept we use in Gecode. This 
allows us to write propagators in terms of "slightly modified variables", and 
maybe that's what you need.

> All this would allow me to only extend gecode with my own
> classes, without having to add a single line in the original
> source code...

If you can express what you want using Views, it would be possible to use an 
unaltered Gecode. Maybe you can tell us in a little more detail what you're 
up to. We'll be glad to help you fit it in!

Cheers,
	Guido

-- 
Guido Tack
Programming Systems Lab, Saarland University, Germany
http://www.ps.uni-sb.de/~tack




More information about the gecode-users mailing list