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

Run the lazy constraints callback at MIPNODE #427

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

simonbowly
Copy link
Collaborator

Executes the lazy constraints callback (if defined) when where=MIPNODE so that the callback is executed at fractional values. Added a test using callback_knapsack_model to ensure some fractional solutions reach the callback in this example.

Note: branched this from v0.9.14 as v0.10.0 forces a downgrade to JuMP 0.18

@simonbowly simonbowly changed the title Run the lazy constraints callback at MIPNODE. Fixes #426 Run the lazy constraints callback at MIPNODE Nov 1, 2021
Executes the lazy constraints callback (if defined) when where=MIPNODE
so that the callback is executed at fractional values. Added a test
using callback_knapsack_model to ensure fractional solutions reach the
callback.
@odow
Copy link
Member

odow commented Nov 1, 2021

Hi @simonbowly,

Yes, I think I originally only called it at MIPSOL because we didn't have a CallbackNodeStatus attribute at first.

The JuMP documentation does suggest that it may be called at fractional nodes:
image

Re the 0.10.0 stuff, yes, we're very close (https://github.com/jump-dev/JuMP.jl/milestone/12) to releasing a new version of JuMP. Gurobi 0.10 works with MathOptInterface 0.10, but JuMP 0.21 relies on MathOptInterface 0.9.

Can you post a screenshot of the tests passing? We can't run Gurobi on CI due to licensing issues.

@odow
Copy link
Member

odow commented Nov 1, 2021

p.s. if you want to chat about JuMP + Gurobi.jl, we're very keen to have some more official support from Gurobi on this. The licensing issue is a major pain point.

@simonbowly
Copy link
Collaborator Author

Sure thing - test output below for this branch. I see, without CallbackNodeStatus it makes sense that you would want to avoid this call at MIPNODE. And I guess this could break code not already doing this status check.

image

@simonbowly
Copy link
Collaborator Author

This came up in the context of my academic work by the way. But I hadn't realised licensing was blocking CI for you - I'll email you directly about this as I'm sure we can sort something out!

@odow
Copy link
Member

odow commented Nov 3, 2021

@blegat do you regard this as breaking? I guess if we push this out as 0.10.1, must users will be updating from JuMP 0.21 and Gurobi 0.9 to JuMP 0.22 and Gurobi 0.10.1 so it's a good time to do this.

@odow
Copy link
Member

odow commented Nov 3, 2021

This came up in the context of my academic work by the way

The other option, and one that we should encourage, is for users to write solver-specific callbacks whenever the MOI defaults aren't suitable:

https://github.com/jump-dev/Gurobi.jl#callbacks

@odow
Copy link
Member

odow commented Nov 3, 2021

So I knew I'd gone over this at some point. My original implementation had it, but I removed it here:
8091d26#diff-ee94cc576005eb58078f7a3fc01b0f63a66806f019d6b4513ca8f7062f2dd4b8L120-R128

I don't remember the reasoning, but we do the same in CPLEX:
https://github.com/jump-dev/CPLEX.jl/blob/b823bbb90e55046220925c6ba8895b195669f270/src/MOI/MOI_callbacks.jl#L194-L204

What's the motivation for adding lazy constraints to fractional solutions?

@simonbowly
Copy link
Collaborator Author

simonbowly commented Nov 3, 2021

I see - this is for cases where knowledge of fractional solutions might allow the user to identify a necessary lazy constraint earlier in the solve, before an integer solution which violates it arises. In some sense it's equivalent to a user cut, but the behaviour can be slightly different.

If only calling the lazy constraint callback at integer solutions is the MOI default, this is also fine, but the JuMP docs for solver-independent lazy constraint callbacks (with callback_node_status) seem to imply that fractional node relaxations should reach this callback. This does occur when using GLPK. I expected this to be consistent across solvers and assumed Gurobi needed to be brought into line with the others, sorry!

@simonbowly
Copy link
Collaborator Author

Now I see that GLPK doesn't distinguish these cases in its own callback reason codes, and GLPK.jl has to check integrality to create the callback status, which would explain the difference.

@odow
Copy link
Member

odow commented Nov 3, 2021

The operative word in the JuMP docs is "may". It's painfully difficult to ensure consistency across the solvers that implement callbacks.

There's essentially no guarantee that JuMP's solver-independent callbacks behave the same across solvers. All it is is a nice syntax for some common callbacks; the actual behavior is solver-dependent.

That said, I don't see a good reason not to call the lazy constraint at fractional nodes, especially since it's documented and we now have the status mechanism. I'll wait for @blegat to chime in, but this looks good to me.

@blegat
Copy link
Member

blegat commented Nov 3, 2021

@blegat do you regard this as breaking? I guess if we push this out as 0.10.1, must users will be updating from JuMP 0.21 and Gurobi 0.9 to JuMP 0.22 and Gurobi 0.10.1 so it's a good time to do this.

Indeed, we could also simply release v0.11.

That said, I don't see a good reason not to call the lazy constraint at fractional nodes, especially since it's documented and we now have the status mechanism.

I agree, it's also good to remove this difference with GLPK.

@odow odow merged commit 9d4eef6 into jump-dev:master Nov 3, 2021
@odow
Copy link
Member

odow commented Nov 3, 2021

Thanks @simonbowly. My email is [email protected] if you want to discuss the licensing issue.

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

Successfully merging this pull request may close these issues.

3 participants