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

circumvent gurobi integer division to match cpmpy floordivision #405

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Wout4
Copy link
Collaborator

@Wout4 Wout4 commented Sep 6, 2023

There does not seem to be floordivision in gurobi, so I implemented a workaround using continuous (gurobi) variables.

@Wout4 Wout4 linked an issue Sep 6, 2023 that may be closed by this pull request
@JoD
Copy link
Collaborator

JoD commented Sep 11, 2023

Interesting. So Gurobi supports integer division that rounds towards zero instead of floors? E.g., -3/2 yields -1 instead of -2? What does Gurobi yield for 3/-2? (if it yields -2 we can maybe hack that in?)

Edit: Gurobi apparently does the following decomposition: a/b becomes q with toplevel b*q=a, which indeed is a nice linear constraint if b is a constant, but it enforces a to be divisible by b.

What is the core idea of your fix? I did not immediately get it from the code - something with abs?

Would it make sense to just have a decomposition for div? E.g., a/b is decomposed to q with toplevel q*b=a+r and 0<=r<b. This will then work for Gurobi too.

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

Successfully merging this pull request may close these issues.

gurobi does not support floordivision
2 participants