我在 Windows 8.1 中使用 Choco 2.1.5 和 Eclipse IDE
当我编译下面的代码时:
CPModel m = new CPModel();
m.setDefaultExpressionDecomposition(false);
RealVariable A = Choco.makeRealVar("a", -5.5, 5.5);
RealVariable B = Choco.makeRealVar("b", -4.4, 4.4);
RealVariable C = Choco.makeRealVar("c", -3.3, 3.3);
m.addConstraint(Choco.or(
Choco.eq(A, Choco.plus(B,C)),
Choco.eq(B, Choco.plus(A,C)),
Choco.eq(C, Choco.plus(A,B))
));
CPSolver solver = new CPSolver();
solver.read(m);
System.out.println(solver.solve());
我得到以下输出:
Exception in thread "main" java.lang.UnsupportedOperationException
at choco.kernel.solver.constraints.AbstractSConstraint.opposite(AbstractSConstraint.java:270)
at choco.cp.solver.CPModelToCPSolver.makeSConstraintAndOpposite(CPModelToCPSolver.java:335)
at choco.cp.solver.CPModelToCPSolver.createGenericMetaConstraint(CPModelToCPSolver.java:457)
at choco.cp.solver.CPModelToCPSolver.createMetaConstraint(CPModelToCPSolver.java:432)
at choco.cp.solver.CPModelToCPSolver.readModelConstraint(CPModelToCPSolver.java:353)
at choco.cp.solver.CPModelToCPSolver.readConstraints(CPModelToCPSolver.java:292)
at choco.cp.solver.CPSolver.read(CPSolver.java:519)
at coverbylines.Test.main(Test.java:88)
但是当我尝试使用IntegerVariable
s 时,我没有收到任何错误。会有什么问题?有没有办法解决?