[Gecode] design question
Gustavo Gutierrez
ggutierrez at atlas.puj.edu.co
Thu Mar 3 20:43:14 CET 2005
On Thu, Mar 03, 2005 at 04:07:41PM +0100, Guido Tack wrote:
> On Thursday 03 March 2005 15:51, Christian Schulte wrote:
> > I am sorry but from what you say I cannot come up with any suggestion but
> > to use a debugger...
>
> >From what I see here, you may have hit one of the main design decisions in
> Gecode: When a space fails, it can be in an arbitrarily screwed up state. If
> I understand you correctly, you perform some propagation, and if that fails,
> you go on with some other propagation in the same space. If failing the first
> propagation means that one variable is actually failed, you may not use the
> space any longer. I think this can easily lead to segmentation faults, can't
> it, Christian?
>
I will write a part of the corresponding propagator as a
pseudo-algorithm:
Suppose Bc is a propagator already implemented.
I am interested on writing K3b which has the VarArray x.
K3b<Var,Bc>::propagate(Space* home) {
VarArray<Var> clone(x);
for (int i = n; i--; ){
//new guess upper bound
double new_upper = clone[i].lower() + 2.0;
clone[i].upper(home,new_upper);
Bc narr(home,clone);
if(narr::propagate(home) == ES_FAILED)
x[i].lower(home,new_upper);
}
}
>From Guido's answer i infer the problem occurs because both propagators
share the same space. Another way to accomplish the same behavior is by creating a new Space and to put there the propagator. This will prevent the parent
space to become failed or "...in an arbitrarily screwed up state".
I will try to write the function guessing some space primitives because
i have not seen much about spaces.
K3b<Var,Bc>::propagate(Space* home) {
VarArray<Var> clone(x);
for (int i = n; i--; ){
//compute a guess upper bound
double new_upper = clone[i].lower() + 2.0;
//Create a new space
Space test();
Bc narr(test,clone);
clone[i].upper(test,new_upper);
if(narr::propagate(test)==ES_FAILED)
x[i].lower(home,new_upper);
}
}
In this new version, the space 'test' is created to test the propagator
(narr) in another independent space. Note that the processes performed on test influence subsequent propagation on home. I don't know if this can work
but i don't feel so good creating additional spaces in propagation steps.
All the best,
Gustavo Gutierrez
More information about the gecode-users
mailing list