我想在 CHOCO 中模拟以下约束。请提供任何帮助
//cSelected[i]=1 ==> ∀ j∈{1,…,i-1} xCategory[i]!= xCategory[j]
cSelected[i]=0, otherwise
这就是我想要做的
int[] x = new int[]{0, 1, 0, 0, 1, 0};
int[] xCategory = new int[]{3, 1, 2, 2, 3, 0};
int[] xCategorySize = new int[]{0, 100, 200, 300};
IntVar[] cSelected = model.intVarArray("d", 6, 0, 1);
// 3. Post constraints
// i want to add and post this constraint:
//cSelected [i]=1 ==> ∀ j∈{1,…,i-1} xCategory[i]!= xCategory[j]
//cSelected [i]=0, otherwise
for (int i=0; i<x.length;i++)
sum += (1-x[i]) * cSelected[i].getValue() * xCategorySize[xCategory[i]];