I would like to add constraints of the form
a - b > 0 if c + d == 4
The documentation talks about OnlyEnforceIf
which I was hoping would allow
model.Add(a-b > 0).OnlyEnforceIf(c+d==4)
Unfortunately it seems OnlyEnforceIf can only take a single Boolean and not a condition such as c+d==4. If I am reading the documentation right it then goes on to suggest
model.Add(c+d==4).OnlyEnforceIf(b)
model.Add(c+d!=4).OnlyEnforceIf(b.Not())
model.Add(a-b > 0).OnlyEnforceIf(b)
I have two questions:
(c+d == 4) <=> b
b => (c+d == 4)
is added with model.Add(c+d==4).OnlyEnforceIf(b)
(c+d == 4) => b
's contrapositive is not(b) => not(c+d == 4)
and that is modeled with model.Add(c+d!=4).OnlyEnforceIf(b.Not())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.