私があなたを正しく理解していれば、完全な行列の合計が 1 であることを確認してください。
次に、ArrayList ("all") を使用してすべての IntegerVariables を 1 つのリストに収集し、"all" に制約を追加できます。列の数など、あなたの例は完全ではありません。そのため、n 列があり、0/1 行列であると想定しています。次に例を示します。
// ...
ArrayList<IntegerVariable> all = new ArrayList<IntegerVariable>();
int n = 5; // number of rows and columns
IntegerVariable[][] rows = new IntegerVariable[n][n];
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
rows[i][j] = makeIntVar("rows["+i+","+j+"]", 0, 1);
all.add(rows[i][j]);
}
}
// convert ArrayList all to an array
model.addConstraint(eq(sum(all.toArray(new IntegerVariable[1])),1));
// ...