Repository navigation
precedence with covered: java.lang.Exception when the list has not more variables than values #21
Description
The constraint precedence with covered="true" fails when the list has not more variables than values.
<instance format="XCSP3" type="CSP">
<variables>
<array id="x" size="[3]"> 0..3 </array>
</variables>
<constraints>
<precedence>
<list> x[] </list>
<values covered="true"> 0 1 2 </values>
</precedence>
</constraints>
</instance>Observed: ! ERROR: and no solution, and with -ev:
java.lang.Exception
at constraints.global.Precedence.<init>(Precedence.java:101)
at problem.Problem.precedence(Problem.java:2487)
at problem.XCSP3.buildCtrPrecedence(XCSP3.java:524)
The constructor of Precedence controls (!covered || list.length > values.length) && values.length > 1 (this control is still in the current source, 3a6cd59, and ACE built from it fails too).
Expected: with as many variables as values, the single solution x = (0, 1, 2); with less variables than values, no solution (the instance is unsatisfiable, all the values having to be assigned). With more variables than values, ACE finds the expected solutions.
Results of the three solvers
Instance (x with domains 0..3, values 0 1 2 covered) |
Expected (brute force) | ACE | CHOCO | cosoco |
|---|---|---|---|---|
| the instance above: 3 variables | 1 solution | fails: ! ERROR: (java.lang.Exception with -ev) |
correct: 1 solution | correct: 1 solution |
| 2 variables | unsatisfiable | fails: ! ERROR: |
correct: unsatisfiable | correct: unsatisfiable |
| 4 variables | 10 solutions | correct: 10 solutions | correct: 10 solutions | correct: 10 solutions |
with (ACE 2.6 and CHOCO (choco-parsers-4.10.15-beta), embedded in PyCSP3, and cosoco 2.6.1, from pip: the versions used by PyCSP3):
- ACE:
java -jar ACE-2.6.jar model.xml -s=all -xe -xc=false - CHOCO:
java -cp choco-parsers-4.10.15-beta.jar org.chocosolver.parser.xcsp.ChocoXCSP model.xml -a -f -flt - cosoco:
cosoco model.xml -model=2 -nbsols=0
Tests
Found by the unit tests of PyCSP3 (branch tests-precedence, xcsp3team/pycsp3#148), where the following tests are marked as expected failures with ACE, in test_constraints_global_precedence.py:
test_precedence_covered_with_not_more_variables_than_values(4 parameters: as many values as variables, 3 and 2, and more values than variables), whose model is, for instance,
x = VarArray(size=3, dom=range(4))
satisfy(
Precedence(x, values=[0, 1, 2], covered=True)
)test_precedence_without_values_coveredfor shifted domains (4 variables, 5 values), once covered is taken into account by PyCSP3 (Precedence() ignores covered=True when values is not given, or when a single value is given pycsp3#150).
This issue was found by the unit tests of PyCSP3: xcsp3team/pycsp3#148
Activity
Give the issues of the known bugs in the marks of the tests of Preced…
xcsp3team commentedon Sep 30, 2026
Fixed