Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bug in PropHybridTable -> ASupport #1102

Closed
dimitri-justeau opened this issue Sep 17, 2024 · 0 comments
Closed

[BUG] Bug in PropHybridTable -> ASupport #1102

dimitri-justeau opened this issue Sep 17, 2024 · 0 comments
Assignees
Labels

Comments

@dimitri-justeau
Copy link
Collaborator

In choco-solver 4.10.16, I found a bug in the hybrid table constraint, apparently due to some situations leading to set a negative value in a BitSet. I tried running on different jvms (GraalVM 22 & OpenJDK 18), the behavior is the same.

** Reproducible example: **

import org.chocosolver.solver.Model;
import org.chocosolver.solver.constraints.extension.hybrid.HybridTuples;
import org.chocosolver.solver.constraints.extension.hybrid.ISupportable;
import org.chocosolver.solver.variables.IntVar;

import static org.chocosolver.solver.constraints.extension.hybrid.HybridTuples.*;
import static org.chocosolver.solver.constraints.extension.hybrid.HybridTuples.col;

public class Test {
    public static void main(String[] args) {
        Model m = new Model();
        IntVar[] intVars = m.intVarArray(3, 0, 5);
        ISupportable[][] htuples = new ISupportable[][]{
                {eq(1), gt(2), le(col(0))},
                {eq(2), le(2), ne(col(1))}

        };
        HybridTuples ht = new HybridTuples();
        ht.add(htuples);
        m.table(intVars, ht).post();
        for (int i = 0; i < 7; i++) {
            m.getSolver().solve();
        }
    }
}

** Traceback: **

Exception in thread "main" java.lang.IndexOutOfBoundsException: bitIndex < 0: -1
    at java.base/java.util.BitSet.set(BitSet.java:447)
    at org.chocosolver.solver.constraints.extension.hybrid.ASupport$AndSupport.support(ASupport.java:86)
    at org.chocosolver.solver.constraints.extension.hybrid.ISupportable$UnEqXC.support(ISupportable.java:167)
    at org.chocosolver.solver.constraints.extension.hybrid.ISupportable$Unary.support(ISupportable.java:65)
    at org.chocosolver.solver.constraints.extension.hybrid.ISupportable$Many.satisfiable(ISupportable.java:534)
    at org.chocosolver.solver.constraints.extension.hybrid.PropHybridTable.isTupleSupported(PropHybridTable.java:127)
    at org.chocosolver.solver.constraints.extension.hybrid.PropHybridTable.filter(PropHybridTable.java:164)
    at org.chocosolver.solver.constraints.extension.hybrid.PropHybridTable.propagate(PropHybridTable.java:88)
    at org.chocosolver.solver.propagation.PropagationEngine.propagateEvents(PropagationEngine.java:234)
    at org.chocosolver.solver.propagation.PropagationEngine.propagate(PropagationEngine.java:213)
    at org.chocosolver.solver.Solver.doPropagate(Solver.java:543)
    at org.chocosolver.solver.Solver.propagate(Solver.java:555)
    at org.chocosolver.solver.Solver.searchLoop(Solver.java:343)
    at org.chocosolver.solver.Solver.solve(Solver.java:311)
    at org.chocosolver.capi.Test.main(Test.java:24)
@cprudhom cprudhom self-assigned this Sep 18, 2024
cprudhom added a commit that referenced this issue Sep 23, 2024
cprudhom added a commit that referenced this issue Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants