rankMen[m][o]);
*/
IntVar v1 = enumerated("v1", 0, n - 1, solver);
solver.post(element(v1, rankMen[m], wife[m], 0, "detect"));
BoolVar b1 = bool("b1", solver);
solver.post(LogicalConstraintFactory.ifThenElse(b1,
arithm(v1, ">", rankMen[m][o]),
arithm(v1, "<=", rankMen[m][o])
));
/*
IntVar b2 = solver.makeIsLessCstVar(
solver.makeElement(rankWomen[o], husband[o]).var(),
rankWomen[o][m]);
*/
IntVar v2 = enumerated("v2", 0, n - 1, solver);
solver.post(element(v2, rankWomen[o], husband[o], 0, "detect"));
BoolVar b2 = bool("b2", solver);
solver.post(LogicalConstraintFactory.ifThenElse(b2,
arithm(v2, "<", rankWomen[o][m]),
arithm(v2, ">=", rankWomen[o][m])
));
/*
solver.addConstraint(
solver.makeLessOrEqual(
solver.makeDifference(b1, b2), 0));
*/
// b1 -> b2
LogOp t = LogOp.implies(b1, b2);
SatFactory.addClauses(t, solver);
// solver.post(IntConstraintFactory.arithm(b1, "<=", b2));
}
}
// forall(w in Women, o in Men)
// cp.post(rankWomen[w,o] < rankWomen[w,husband[w]] =>
// rankMen[o,wife[o]] < rankMen[o,w]);
for (int w = 0; w < n; w++) {
for (int o = 0; o < n; o++) {
/*
IntVar b1 = solver.makeIsGreaterCstVar(
solver.makeElement(rankWomen[w], husband[w]).var(),
rankWomen[w][o]);
*/
IntVar v1 = enumerated("v1", 0, n - 1, solver);
solver.post(element(v1, rankWomen[w], husband[w], 0, "detect"));
BoolVar b1 = bool("b1", solver);
solver.post(LogicalConstraintFactory.ifThenElse(b1,
arithm(v1, ">", rankWomen[w][o]),
arithm(v1, "<=", rankWomen[w][o])
));
/*
IntVar b2 = solver.makeIsLessCstVar(
solver.makeElement(rankMen[o], wife[o]).var(),
rankMen[o][w]);
*/
IntVar v2 = enumerated("v2", 0, n - 1, solver);
solver.post(element(v2, rankMen[o], wife[o], 0, "detect"));
BoolVar b2 = bool("b2", solver);
solver.post(LogicalConstraintFactory.ifThenElse(b2,
arithm(v2, "<", rankMen[o][w]),
arithm(v2, ">=", rankMen[o][w])
));