SetVar propagation and unpost problem from 4.10.9

22 views
Skip to first unread message

juha.t...@gmail.com

unread,
May 2, 2023, 6:04:44 AM5/2/23
to choco-solver
Hi Charles,

The following program works with 4.10.8 but throws with 4.10.9 and 4.10.12.
After unposting a constraint and adding a new one, the next propagate throws.

public static void main(String[] args) {

Model m = new Model();

int[] lb= new int[] {};

int[] ub= new int[] {0, 1, 2, 3};


SetVar s = m.setVar("s", lb, ub);


System.out.println(m.getSolver().WELCOME_MESSAGE);


int oldWorld = m.getSolver().getEnvironment().getWorldIndex();

for (int i = 0; i < 4; i++) {

Constraint c = m.member(i, s);

c.post();

try {

m.getSolver().propagate();

System.out.println(i + ": " + s.getUB());

} catch (ContradictionException e) {

m.getSolver().getEngine().flush();

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

}

m.unpost(c);

//m.getSolver().getEnvironment().worldPopUntil(oldWorld);

m.getSolver().reset();

}

}


Printouts:
** Choco 4.10.12 (2023-03) : Constraint Programming Solver, Copyright (c) 2010-2023
0: {0, 1, 2, 3}
Exception in thread "main" java.lang.UnsupportedOperationException
at org.chocosolver.solver.variables.impl.BipartiteList.swap(BipartiteList.java:155)
at org.chocosolver.solver.variables.impl.AbstractVariable.swapOnPassivate(AbstractVariable.java:238)
at org.chocosolver.solver.constraints.Propagator.setPassive(Propagator.java:523)
at org.chocosolver.solver.constraints.set.PropIntCstMemberSet.propagate(PropIntCstMemberSet.java:60)
at org.chocosolver.solver.propagation.PropagationEngine.execute(PropagationEngine.java:243)
at org.chocosolver.solver.propagation.PropagationEngine.activatePropagators(PropagationEngine.java:227)
at org.chocosolver.solver.propagation.PropagationEngine.propagate(PropagationEngine.java:187)
at org.chocosolver.solver.Solver.propagate(Solver.java:715)
at varipdm.gt.choco.SetPossibleValuesTest.main(SetPossibleValuesTest.java:618)

** Choco 4.10.8 (2022-01) : Constraint Programming Solver, Copyright (c) 2010-2022

0: {0, 1, 2, 3}
1: {0, 1, 2, 3}
2: {0, 1, 2, 3}
3: {0, 1, 2, 3}


I also got another exception with SetVar propagation and 4.10.12. I'm still trying to produce a minimal example. Possibly with a cardinality constraint:

Exception in thread "main" java.lang.IndexOutOfBoundsException: fromIndex < 0: -1
at org.chocosolver.memory.structure.S64BitSet.checkRange(S64BitSet.java:180)
at org.chocosolver.memory.structure.S64BitSet.clear(S64BitSet.java:299)
at org.chocosolver.solver.variables.impl.BitsetIntVarImpl.updateLowerBound(BitsetIntVarImpl.java:443)
at org.chocosolver.solver.constraints.set.PropCardinality.propagate(PropCardinality.java:73)
at org.chocosolver.solver.propagation.PropagationEngine.execute(PropagationEngine.java:243)
at org.chocosolver.solver.propagation.PropagationEngine.activatePropagators(PropagationEngine.java:227)
at org.chocosolver.solver.propagation.PropagationEngine.propagate(PropagationEngine.java:187)
at org.chocosolver.solver.Solver.propagate(Solver.java:715)

B.R.

Juha

cpru...@gmail.com

unread,
May 9, 2023, 12:33:46 PM5/9/23
to choco-solver
Hi Juha

Indeed, I changed the way propagators are stored in variables to better deal with entailed ones.
The side effect is that, now, it fails in your case. 
The explanation is the following. 
You are removing a constraint that was entailed after being propagated.
Such a constraint is being swapped in the internal structure of a variable to a place where removal is forbidden.
I can try to find a fix and let you know.

Best 
Charles
Reply all
Reply to author
Forward
0 new messages