Skip to content

ArrayIndexOutOfBoundsException in STR0a with AllDifferent and a variable whose domain has a single value #11

Closed

Description

@szczepanskiNicolas

The following instance (generated by PyCSP3) has a unique solution (x[0]=0, x[1]=1, x[2]=2):

<instance format="XCSP3" type="CSP">
  <variables>
    <array id="x" size="[3]">
      <domain for="x[0]"> 0 </domain>
      <domain for="x[1]"> 0 1 </domain>
      <domain for="x[2]"> 0..2 </domain>
    </array>
  </variables>
  <constraints>
    <allDifferent> x[] </allDifferent>
  </constraints>
</instance>

but ACE 2.6 fails (java -jar ACE-2.6.jar model.xml -ev):

! ERROR (use -ev for more details)
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 2
	at sets.SetLinkedBinary.contains(SetLinkedBinary.java:80)
	at constraints.extension.STR0$STR0a.isValidTuple(STR0.java:178)
	at constraints.extension.STR0$STR0a.runPropagator(STR0.java:194)
	at constraints.ConstraintExtension$ConstraintExtensionSpecific.launchFiltering(ConstraintExtension.java:192)
	...
s UNKNOWN

The model in PyCSP3:

from pycsp3 import *

x = VarArray(size=3, dom=lambda i: range(i + 1))

satisfy(
    AllDifferent(x)
)

This looks like xcsp3team/pycsp3#50 (AllEqual with a single-value domain).

Tests

Found by the unit tests of PyCSP3 (branch unit-tests, xcsp3team/pycsp3#66), where the following tests are marked as expected failures until this bug is fixed:

Results of the other solvers

Instance Expected (brute force) CHOCO cosoco
the instance above 1 solution correct: 1 solution correct: 1 solution

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):

  • 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

This issue was found by the unit tests of PyCSP3: xcsp3team/pycsp3#66

Activity

  1. added
    bugSomething isn't working
    unit-testsFound by the unit tests of pycsp3 (pycsp3/tests)
    on Sep 14, 2026
  2. xcsp3team commented on Sep 14, 2026

    @xcsp3team
    Owner

    Fixed in ACE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    StructurationSection Structuration of the APIbugSomething isn't workingunit-testsFound by the unit tests of pycsp3 (pycsp3/tests)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions