chocoteam / chocoteam/choco-solver
PropagationTrigger does not allow to run twice initial propagation
- Dominant language
- Java
- Stars
- 779
- Forks
- 159
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 10
Description
The following code fails:
``` java
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:
``` java
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`.
Contributor guide
Assessment
This issue has not been assessed yet.