dependabot[bot] on maven
Bump testng from 7.5 to 7.6.0 … (compare)
cprudhom on master
`IntVar` handles with `long` va… Merge branch 'master' into long… Merge branch 'longAPI' and 1 more (compare)
dependabot[bot] on maven
dependabot[bot] on maven
dependabot[bot] on maven
cprudhom on master
Improvements relative to reifie… Make "c implied by r" managed b… Clean up FConstraint to share c… (compare)
Hello! We have found a situation where there is a "java.lang.ArrayIndexOutOfBoundsException" while performing a "model.unpost(constraint)" where the constraint has been reified and introduced in another constraint.
Example:
Constraint A = model.arithm(...);
Constraint B = model.arithm(...);
Constraint C = model.arithm(A.reify(), "<=", B.refiy());
model.post(C);
model.solve();
model.unpost(C);
model.unpost(A);
model.unpost(B);
We have created a Git Issue: chocoteam/choco-solver#823
As a workaround we have unpost the propagator constraint
Arrays.stream(A.getPropagators()).filter(Objects::nonNull).map(Propagator::getConstraint).forEach(model::unpost);
Arrays.stream(B.getPropagators()).filter(Objects::nonNull).map(Propagator::getConstraint).forEach(model::unpost);
We think that the "ArrayIndexOutOfBoundsException" is a bug, and maybe there is another way of unposting this constraints or we are missing something.
Thank you!
mvn clean package -DskipTests
git clone https://github.com/chocoteam/choco-solver.git
```
int n = 2;
Model model = new Model("all different");
IntVar[] xs = model.intVarArray("Xs", n, 1, n);
model.allDifferent(xs).post();
Solver solver = model.getSolver();
solver.setSearch(Search.activityBasedSearch(xs));
//solver.setSearch(Search.domOverWDegRefSearch(xs));
// 6. Launch the resolution process
while (solver.solve()) {
for (IntVar x : xs) {
System.out.format("%3d", x.getValue());
}
System.out.println();
}
```
.eq(0)
instead of .not()
on a BoolVar. Is there a functional difference between the two?
Here are what I’ve found with the 2 models.
As you can see, the models are slightly different but the same solutions are found.
That might come from somewhere else.
If you can give me a minimal working example, that would be great.
Model with not()
Model model = new Model();
BoolVar x = model.boolVar("x");
BoolVar y = model.boolVar("y");
x.not().imp(y.not()).post();
System.out.printf("%s%n", model);
Solver solver = model.getSolver();
solver.showShortStatistics();
solver.findAllSolutions();
outputs:
Model[Model-0]
[ 4 vars -- 1 cstrs ]
satisfaction : undefined
== variables ==
x = [0,1]
y = [0,1]
not(x = [0,1])
not(y = [0,1])
== constraints ==
ARITHM ([x + not(y) >= 1])
Model[Model-0], 1 Solutions, Resolution time 0,013s, 3 Nodes (234,2 n/s), 0 Backtracks, 0 Backjumps, 0 Fails, 0 Restarts
Model[Model-0], 2 Solutions, Resolution time 0,021s, 4 Nodes (189,7 n/s), 1 Backtracks, 0 Backjumps, 0 Fails, 0 Restarts
Model[Model-0], 3 Solutions, Resolution time 0,022s, 5 Nodes (230,3 n/s), 3 Backtracks, 0 Backjumps, 0 Fails, 0 Restarts
Model[Model-0], 3 Solutions, Resolution time 0,022s, 5 Nodes (225,3 n/s), 5 Backtracks, 0 Backjumps, 0 Fails, 0 Restarts
Model with eq(0)
Model model = new Model();
BoolVar x = model.boolVar("x");
BoolVar y = model.boolVar("y");
x.eq(0).imp(y.not()).post();
System.out.printf("%s%n", model);
Solver solver = model.getSolver();
solver.showShortStatistics();
solver.findAllSolutions();
outputs:
Model[Model-0]
[ 5 vars -- 1 cstrs ]
satisfaction : undefined
== variables ==
x = [0,1]
y = [0,1]
not(y = [0,1])
(x=0) = [0,1]
not((x=0) = [0,1])
== constraints ==
ARITHM ([not((x=0)) + not(y) >= 1])
Model[Model-0], 1 Solutions, Resolution time 0,009s, 2 Nodes (231,4 n/s), 0 Backtracks, 0 Backjumps, 0 Fails, 0 Restarts
Model[Model-0], 2 Solutions, Resolution time 0,015s, 4 Nodes (274,6 n/s), 1 Backtracks, 0 Backjumps, 0 Fails, 0 Restarts
Model[Model-0], 3 Solutions, Resolution time 0,015s, 5 Nodes (333,7 n/s), 2 Backtracks, 0 Backjumps, 0 Fails, 0 Restarts
Model[Model-0], 3 Solutions, Resolution time 0,015s, 5 Nodes (324,6 n/s), 5 Backtracks, 0 Backjumps, 0 Fails, 0 Restarts
Hi, I'm a beginner with choco-solver and have some difficulties writing a functional model.
my vars
Hello I'm a beginner with choco-solver and I'm currently having trouble writing a working model.
Here is my problem:
Each day of the week I have to find a desk for all users who need one.
My constraints:
Objective:
// Model Parameter
int numberOfDayInWeek = 5;
int numberOfDesk = 5;
int numberOfUser = 5;
Boolean[][] userAvaibility = {
{false, true, true, true, true},
{true, true, true, true, false},
{true, true, true, false, true},
{false, true, true, true, true},
{true, true, true, true, false},
};
Model model = new Model("Desk attribution");
// Define a desk environment.
IntVar[][] varsDesk = model.intVarMatrix("Desk", numberOfDayInWeek, numberOfDesk, -1, numberOfUser, false); // Fix for desk is not affected
// Each User can be assigned to one desk per day
for (int i = 0 ; i < numberOfDayInWeek ; i++)
{
model.post(model.allDifferent(varsDesk[i]));
}
// Remove user for day how is work at home
for (int j = 0 ; j < numberOfDayInWeek ; j++)
{
for (int i = 0 ; i < numberOfUser ; i++)
{
if (!userAvaibility[i][j])
for (int b = 0 ; b < numberOfDesk ; b++)
varsDesk[j][b].ne(i).post();
}
}
Solver solver = model.getSolver();
solver.showStatistics();
solver.showSolutions();
solver.findAllSolutions();
choco-solver-4.10.8-jar-with-dependencies.jar
(https://github.com/chocoteam/choco-solver/releases) or to define a maven-based project with choco-solver as a dependency (https://choco-solver.org/docs/getting-started/#quick-start)
final IntVar objective = m.intVar("objective", minObjective, maxObjective);
m.sum(places, "<=", objective, places.length + 1).post();
final Solution solution = new Solution(m);
// objective
m.setObjective(Model.MAXIMIZE, objective);
// solve
while (solver.solve()) {
solution.record();
}
objective variable (objective = {31..75}) is not instantiated on solution. Check constraints and/or decision variables.