choco-solver icon indicating copy to clipboard operation
choco-solver copied to clipboard

PropagationTrigger does not allow to run twice initial propagation

Open cprudhom opened this issue 9 years ago • 0 comments

The following code fails:

Model m = new Model();
IntVar a = m.intVar("a", 0, 50), b = m.intVar("b", 0, 50);
IntVar[] vars = new IntVar[] { a, b };
m.sum(vars, "=", 100).post();
m.getEnvironment().worldPush();
m.getSolver().propagate();
Assert.assertTrue(a.isInstantiatedTo(50));
Assert.assertTrue(b.isInstantiatedTo(50));
m.getEnvironment().worldPop();
m.getEnvironment().worldPush();
m.getSolver().propagate();
Assert.assertTrue(a.isInstantiatedTo(50));
Assert.assertTrue(b.isInstantiatedTo(50));
m.getEnvironment().worldPop();

Even if this is an advanced usage of initial propagation (maybe senseless), the second time the propagation is called, the PropagationTrigger's sat_propagators list is empty and it is like no constraints are declared.

To bypass the bug, one has to call:

m.getSolver().getEngine().clear();

before the second try.

I don't think this a major bug, but it exists. I believe that fixing it requires a refactor of PropagationTrigger.

cprudhom avatar May 09 '16 10:05 cprudhom