3

I would like to use the Google or-tools Java api and I can't make disjunction of constraints. I try to implement like this: (A==1 OR B==1) AND ((C==1 OR D==1))... How can I do that?

And the other question is how can I implement the makeSumLessOrEqual(IntVar[] VARS, IntVar limit) because there is only makeSumLessOrEqual(IntVar[] VARS, int limit) function.

Thank you for your help!

4

1 回答 1

2

我想使用 Google or-tools Java api,但无法分离约束。我尝试这样实现: (A==1 OR B==1) AND ((C==1 OR D==1))... 我该怎么做?

创建布尔变量solver.makeIsEqualCstVar(A, 1)

ORsolver.makeMax(boolvar_1, boolvar_2)AND是_solver.makeMin();

另一个问题是如何实现 makeSumLessOrEqual(IntVar[] VARS, IntVar limit) 因为只有 makeSumLessOrEqual(IntVar[] VARS, int limit) 函数。

您需要将makeScalProdAPI 与[1, .., 1, -1]和一起使用vars + [limit]

于 2018-07-24T05:00:47.983 回答