hdavid16 / DisjunctiveProgramming.jl

A JuMP extension for Generalized Disjunctive Programming
MIT License
27 stars 3 forks source link

Support Cardinality Constraints with Logical Expressions #99

Open pulsipher opened 10 months ago

pulsipher commented 10 months ago

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

hdavid16 commented 10 months ago

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?

pulsipher commented 10 months ago

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.