cprudhom on master
Upgrade ibex-java to 1.2.0 (#74… (compare)
Hello, I've a question related to tuple constraints:
The following source code:
Model model = new Model();
IntVar x = model.intVar(new int[]{1, 2, 3, 4});
IntVar y = model.intVar(new int[]{1, 2, 3, 4});
Tuples tuples = new Tuples();
tuples.add(1, 1);
tuples.add(1, 2);
tuples.add(1, 3);
tuples.add(1, 4);
model.table(x, y, tuples).reify().eq(0).post();
model.getSolver().propagate();
System.out.println(x);
System.out.println(y);
It shouldn't remove the value 1 from X domain due to the reification to false?
isEntailed
of each of its propagators. In some specific cases, we were able to provide the opposite of a constraint. That is not the case of Table constraint. But, since you are using extension constraints, you can programmatically reified them by declaring a new dimension to the tuple, and a new variable as scope like:Model model = new Model();
IntVar x = model.intVar(new int[]{1, 2, 3, 4});
IntVar y = model.intVar(new int[]{1, 2, 3, 4});
BoolVar b = model.boolVar();
int STAR = 99;
Tuples tuples = new Tuples();
tuples.setUniversalValue(STAR);
tuples.add(1, 1, 1);
tuples.add(1, 2, 1);
tuples.add(1, 3, 1);
tuples.add(1, 4, 1);
tuples.add(2, STAR, 0);
tuples.add(3, STAR, 0);
tuples.add(4, STAR, 0);
model.table(new IntVar[]{x, y, b}, tuples).post();
b.eq(0).post();
model.getSolver().propagate();
System.out.println(x);
System.out.println(y);
I was confusing about it because of this paper "Efficient Reification of Table Constraints" (10.1109/ICTAI.2017.00029), where the authors present a reification algorithm for table constraints (Algorithm 1). In that algorithm, given c
as a table constraint and b
as a reification variable of c
, they mention the enforcement of GAC on contraint c
if b = 1
or not (c)
if b = 0
.
I'm researching about it because I'm considering integrate the choco-solver with SQL (RDMS) to maintain positive table contraints, the reference is this paper "CSP Techniques for Solving Combinatorial Queries within Relational Databases" (https://doi.org/10.1007/978-3-642-04170-9_6 ), and I was struggling with the implementation of reification.
Based on my research and in choco source code, because my SqlTablePropagator
will work the same way asTuples
, I decided to implement the same isEntailed
logic of Tuples.java
. However, instead of checking the tuples in memory for validation, I query the database to get this information.
@Override
public ESat isEntailed() {
ESat entailed;
if (nbTuples == 0) {
entailed = ESat.FALSE;
} else if (!areAllVariablesInstantiated()) {
entailed = ESat.UNDEFINED;
} else if (getNumberValidTuples() == 1) {
entailed = ESat.TRUE;
} else {
entailed = ESat.FALSE;
}
return entailed;
}
List<IntVar> intervalStarts = []
observations.size().times { i ->
IntVar start = model.intVar("OB $i from", 0, TOTAL_SLOTS - 1)
IntVar end = model.intVar("OB $i to", 0, TOTAL_SLOTS - 1)
model.taskVar(start, observations[i].requestedNoOfSlots, end)
intervalStarts.add(start)
}
model.allDifferent((IntVar[]) intervalStarts).post()
Hello,
Is there some kind of operation on choco that changes the behavior of double values? I'm having some troubles when running tests using a docker container (maven:3.6.3-openjdk-11-slim
).
System.out.println(10.0, 6); // Prints: 1000000.0
model.getSolver().propagate();
System.out.println(10.0, 6); // Prints: 1000000.0000000001
Ibex ibex = new Ibex(new double[]{0.000001, 0.000001});
ibex.add_ctr("{0}=acos({1})");
System.out.println(Math.pow(10, 6)); // Prints: 1000000.0
ibex.build();
System.out.println(Math.pow(10, 6)); // Prints: 1000000.0000000001
IntVar
and the cumulative
constraint. Now some of those observations belong to groups that should be scheduled strictly together filling up one or several consecutive nights. Is there an obvious way to express this?
IntVars
, would it then not work to require that the max(starts) - min(starts) === (M - 1). I just have no clue how to extract such max of IntVars as an intermediate, "fresh" variable? Maybe the distance
constraint, but since it only takes 2 variables would I have to add a constraint for each combination?
Dear All, I am currently try to solve a new problem using Choco solver which needs to use the core idea from classic example Traveling Salesman Problem in tutorials. The example will be modified to given a start city and find a path traverse all cities to the end given city. For example, define a start city0 and the end the path travel all cities to city1.
Based on the current example code, I introduced the code like
model.arithm(succ[0], "=", 0).post();
model.arithm(succ[C - 1], "=", 1).post();
but solver.solve() didn't find any solution. I even replaced the code
model.subCircuit(succ, 0, model.intVar(C)).post();
to:
model.subPath(succ, model.intVar(0), model.intVar(1), 0, model.intVar(C)).post();
but again solver.solve() didn't find any solution.