如果复杂变量满足约束条件,如何检查 Choco?例如,如果我有以下配置列表:
int[][] configurations = new int[][] {
{20, 24, 10, 3, 4},
{20, 13, 1, 3, 4}};
其中 config1 = {20, 24, 10, 3, 4} 和 config2 = {20, 13, 1, 3, 4}
int[] constraints = new int[]{21, 15, 2, 10, 10};
是一个约束列表,对于给定的配置,配置中的每个元素都需要高于(或低于)对应的约束。例如:config1 = {20, 24, 10, 3, 4} 约束 = {21, 15, 2, 10, 10}
check if config1[0] < constraints[0] AND config1[1] < constraints[1] AND ...
如果满足所有约束,则只需将其标记为解决方案。这就是我所拥有的
// c = number of configurations
// q = number of elements in each configuration
// p = configurations matrix
for (int i = 0; i < c; i++) {
for (int j = 0; j < q; j++) {
model.arithm(model.intVar(p[i][j]), "<", model.intVar(k[j])).post();
}
}