Skip to content

Conversation

@harshangrjn
Copy link

Related to #2123 : A small update on example_lazy_constraint() function to make sure the cuts are added only at integral solutions (see https://www.juliaopt.org/JuMP.jl/dev/callbacks/#Lazy-constraints-1)

Related to #2123 :  A small update on example_lazy_constraint() function to make sure the cuts are added only at integral solutions (see https://www.juliaopt.org/JuMP.jl/dev/callbacks/#Lazy-constraints-1)
elseif y_val + x_val > 3 + 1e-6
con = @build_constraint(y - x <= 1)
MOI.submit(model, MOI.LazyConstraint(cb_data), con)
if (isinteger.(x_val) == true) && (isinteger.(y_val) == true) # Add the cut only on integral solutions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isinteger(x_val) && isinteger(y_val)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using isinteger isn't correct. If you don't use the same integrality tolerance as the solver, then you might fail to add cuts on a solution that the solver thinks is integral. Maybe we need to provide better support for adding a lazy constraint callback that is called only at integer solutions. We previously had the fractional keyword argument:
https://github.com/JuliaOpt/JuMP.jl/blob/a9de4d0de1b34b85d35c3624bea236afec7e5bec/src/callbacks.jl#L32

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a callback_status(cb_data) which returns an enum CBNODE_FRACTIONAL, CBNODE_INTEGER, or CBNODE_UNKNOWN.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't thought through all the implications, but that could work also.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for something like MOI.CallbackNodeStatus

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that isinteger was just a hack for that simple example which was there. I actually wrote my own function to handle the integrality tolerance for my problem. It would be ideal to invoke lazy callback at only integral solutions, which was also my original concern.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think callback function form function callback_function(cb_data, cb_where) can be a proper choice, cb_where can be used to control where we can add constraints.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YP-Ye, currently cb_where is for solver-dependent callbacks. We're looking at introducing a way for solver-independent callbacks (which only take (cb_data)) to identify where they are being called from.

@blegat
Copy link
Member

blegat commented Dec 28, 2019

The failure on Julia v1.1 seems to be jump-dev/MathOptInterface.jl#980

@odow
Copy link
Member

odow commented Nov 27, 2020

Closing as out-dated. The fix for #2123 is to support jump-dev/MathOptInterface.jl#1199.

@odow odow closed this Nov 27, 2020
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.

5 participants