DisjunctiveProgramming.jl icon indicating copy to clipboard operation
DisjunctiveProgramming.jl copied to clipboard

Support Cardinality Constraints with Logical Expressions

Open pulsipher opened this issue 2 years ago • 2 comments

Currently, we only cardinality constraints on logical variables. It would be nice to allow arguments to be logical expressions as well.

pulsipher avatar Dec 07 '23 17:12 pulsipher

Can you illustrate what you mean with having logical expressions as the arguments? Is this to avoid defining a Boolean variable for the logical expression and using that Boolean in the cardinality constraint?

hdavid16 avatar Dec 07 '23 17:12 hdavid16

Can you illustrate what you mean with having logical expressions as the arguments? Is this to avoid defining a Boolean variable for the logical expression and using that Boolean in the cardinality constraint?

Yes, this could potentially avoid adding unnecessary Boolean variables. Instead of

model = GDPModel()
@variable(model, y[1:2], Logical)
@variable(model, w, Logical)
@constraint(model, w == y[1] ⟹ y[2] := true)
@constraint(model, [w, y[1]] in AtMost(1))

we could do

model = GDPModel()
@variable(model, y[1:2], Logical)
@constraint(model, [y[1] ⟹ y[2], y[1]] in AtMost(1))

Of course, I know reformulating this might lead to extra Boolean variables anyways, but this is certainty a lot more convenient/concise for the user.

pulsipher avatar Dec 07 '23 17:12 pulsipher