I'm trying to use java choco solver, a CP solver, to color a graph. However i can't seem to get it to work. Even the code in the tutorial doesn't work:
int n = 8;
Model model = new Model(n + "-queens problem");
IntVar[] vars = new IntVar[n];
for(int q = 0; q < n; q++){
vars[q] = (IntVar) model.intVar("Q_"+q, 1, n);
}
for(int i = 0; i < n-1; i++){
for(int j = i + 1; j < n; j++){
model.arithm(vars[i], "!=",vars[j]).post();
model.arithm(vars[i], "!=", vars[j], "-", j - i).post();
model.arithm(vars[i], "!=", vars[j], "+", j - i).post();
}
}
Solution solution = model.getSolver().findSolution();
if(solution != null){
System.out.println(solution.toString());
}
I always get the folowing error:
The method arithm(IntVar, String, int) in the type IIntConstraintFactory is not applicable for the arguments (IntVar, String, IntVar), which i don't understand because vars[j], should be an IntVar.
I hope someone can help!
Kind Regards,
Nicholas