Hi,
I have a problem to solve an optimisation problem using dynamic constraints.
This is the code:
public static void main (String args[])
{
CPModel m = new CPModel();
IntegerVariable [] roles = new IntegerVariable[3];
CPSolver s = new CPSolver();
for (int k = 0; k < 3; k++)
roles[k] = Choco.makeIntVar("role" + k, 1, 3);
m.addVariable(roles);
IntegerVariable obj1 = Choco.makeIntVar("sum");
m.addConstraint(Choco.eq(obj1, Choco.sum(roles)));
s.read(m);
Hi,
I have a problem to solve an optimisation problem using dynamic constraints.
This is the code:
s.minimize(s.getVar(obj1), true);
s.generateSearchStrategy();
s.post(new NotEqualXC(s.getVar(roles[0]), 1));
}
the result is:
The solutions Are1:
role0:1
role1:1
role2:1
CHOCO : Constraint Programming Solver
CHOCO v2.1.5 (August, 2012), Copyleft (c) 1999-2012
- Initial Propagation: Contradiction due to role0:1 != 1
- Search completed: No solutions
Minimize: sum:3
Solutions: 0
Time (ms): 10
Nodes: 0
Backtracks: 0
Restarts: 0
I dont understand why there are no solution when i add a dynamic constraint to my problem!
Thanks
Hello,
You do not restart the search or create a new solver.
Anyway, I would suggest to upgrade to choco3.
Cheers.