dependabot[bot] on maven
Bump poi from 4.1.2 to 5.0.0 B… (compare)
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.
I used same code from choco TSP example, but replace subCircuit() as subPath(). Based on choco document, subPath() is described as subPath(IntVar[] vars, IntVar start, IntVar end, int offset, IntVar SIZE)
Creates a subPath constraint which ensures that
the elements of vars define a path of SIZE vertices, leading from start to end. Therefore I think this can replace subCircuit() to find a path, but in fact no solution found.
Hello,
I'm looking for a way to improve the performance of my model that is reused by many HTTP requests (for performance reasons). Sometimes I want to ignore constraints from being executed (I have some use cases-that I need that), but after the propagation/search ends I want to re-add them to the model. I know that it's possible to unpost
constraints from choco-solver. Therefore my questions are:
Following I share my experiments so far:
public static void main(String[] args) throws Exception {
Model model = new Model();
IntVar x = model.intVar("x", new int[]{1, 2, 3});
Constraint cstr = applyWith(model, model.arithm(x, "=", 1));
System.out.println(x); // x = 1
applyWithout(model, cstr);
System.out.println(x); // x = {1..3}
cstr = applyWith(model, model.arithm(x, "=", 1));
System.out.println(x); // x = 1
applyWithout(model, cstr);
System.out.println(x); // x = {1..3}
}
public static Constraint applyWith(Model model, Constraint cstr) throws Exception {
model.getSolver().hardReset();
cstr.post();
model.getSolver().getEnvironment().worldPush();
model.getSolver().propagate();
return cstr;
}
public static void applyWithout(Model model, Constraint cstr) throws Exception {
model.getSolver().hardReset();
model.unpost(cstr);
model.getSolver().getEnvironment().worldPush();
model.getSolver().propagate();
}
Thanks in advance
@bigangswan
that looks work, thanks :) One question I don't quite understand is the following code:
succ[C - 1] = model.intVar("succ_" + (C-1), 0); // expect for the last city
if set the last city range to 0 and why this lead to succ[C-2] always = 16 ?
The first line force the last city to be connected to the first one (with index 0). But you can change which city is the last (or first) one by playing with indices. The fact that such[C_2] = 16 is probably related to the distance matrix
ParallePortfolio
with mutliple identical model instances. After solving, I understand there is portfolio.getBestModel()
but what is the best way to access the values of the solution. In a single threaded approach I store references to those IntVars outside of the model.
IntVar[] starts
array of variables. When the parallel portfolio finds a solution, I don't know which model worked. So how do I retrieve the values? It seems I cannot query the solution for IntVars by name? So I need to keep references to the 4 arrays and then map the bestModel to one of the 4 arrays? ParallelPortfolio portfolio = new ParallelPortfolio()
NO_OF_MODELS.times { index ->
Model model = buildModel(observations)
model.solver.limitTime(SOLVER_LIMIT)
portfolio.addModel(model)
}
if (portfolio.solve()) {
Solution solution = new Solution(portfolio.getBestModel()).record()
// how do I retrieve the bound IntVar values by index
}