Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Cardinality Constraints with Logical Expressions #99

Open
pulsipher opened this issue Dec 7, 2023 · 2 comments
Open

Support Cardinality Constraints with Logical Expressions #99

pulsipher opened this issue Dec 7, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@pulsipher
Copy link
Collaborator

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

@pulsipher pulsipher added the enhancement New feature or request label Dec 7, 2023
@hdavid16
Copy link
Owner

hdavid16 commented Dec 7, 2023

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
Copy link
Collaborator Author

pulsipher commented Dec 7, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants