chocoteam / chocoteam/choco-solver

PropagationTrigger does not allow to run twice initial propagation

Open
#406 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.