-
-
Notifications
You must be signed in to change notification settings - Fork 410
Closed
Labels
Status: Help WantedHelp is welcome on this issueHelp is welcome on this issuegood first issueThis issue is recommended for new users, it does not require a thorough understanding of the packageThis issue is recommended for new users, it does not require a thorough understanding of the package
Description
On JuMP v0.20.1: Attaching a small lazy callback implementation example below (modified based on https://github.com/JuliaOpt/JuMP.jl/blob/master/examples/callbacks.jl) and the output of CPLEX. x_val values are taking fractional values inside the lazy callback while this must be strictly integral as this callback must be invoked only at incumbents. Typically user callback has to do this.
Posting here since I am using solver independent callback. This issue appears in both CPLEX and Gurobi. Looks like a bug in JuMP but let me know if I am missing anything.
using JuMP, CPLEX, Gurobi
function example_lazy_constraint_mod()
n=4
A = [0.0 0.83513 0.564369 0.432627; 0.83513 0.0 1.93858 1.77313; 0.564369 1.93858 0.0 0.718298; 0.432627 1.77313 0.718298 0.0]
model = direct_model(CPLEX.Optimizer())
# model = direct_model(Gurobi.Optimizer())
@variable(model, x[1:n, 1:n], Bin)
@variable(model, y >= 0)
@variable(model, W[1:n, 1:n])
@objective(model, Max, y)
@constraint(model, [i=1:n], x[i,i] == 0)
@constraint(model, [i=1:(n-1), j=(i+1):n], x[i,j] == x[j,i])
@constraint(model, sum(x) == 2*(n-1))
@constraint(model, [i=1:n], W[i,i] >= 0)
@constraint(model, [i=1:(n-1), j=(i+1):n], W[i,j] == W[j,i])
@constraint(model, [i=1:(n-1), j=(i+1):n], W[i,j] == -A[i,j]*x[i,j] + y)
@constraint(model, [i=1:n], W[i,i] == sum(A[i,:] .* x[i,:]) - y)
function my_callback_function(cb)
x_val = callback_value.(Ref(cb), x)
@show x_val
end
MOI.set(model, MOI.LazyConstraintCallback(), my_callback_function)
optimize!(model)
end
example_lazy_constraint_mod()
CPLEX output
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 0.8351 1.2827 53.59%
0 0 1.2827 3 0.8351 1.2827 3 53.59%
x_val = [-0.0 0.906081 1.0 0.0; 0.906081 -0.0 0.370528 0.723391; 1.0 0.370528 -0.0 0.0; -0.0 0.723391 -0.0 -0.0]
0 0 1.0958 5 0.8351 Cuts: 15 11 31.21%
x_val = [-0.0 0.818876 0.0 0.952067; 0.818876 -0.0 0.229057 0.0479327; -0.0 0.229057 -0.0 0.952067; 0.952067 0.0479327 0.952067 -0.0]
0 0 0.9546 6 0.8351 Cuts: 10 13 14.30%
x_val = [-0.0 0.577504 0.809889 0.0351035; 0.577504 -0.0 0.577504 0.964896; 0.809889 0.577504 -0.0 0.0351035; 0.0351035 0.964896 0.0351035 -0.0]
0 0 0.9257 6 0.8351 Cuts: 3 14 10.85%
x_val = [-0.0 0.440223 0.559777 0.559777; 0.440223 -0.0 0.440223 0.440223; 0.559777 0.440223 -0.0 0.559777; 0.559777 0.440223 0.559777 -0.0]
x_val = [-0.0 0.440223 0.559777 0.559777; 0.440223 -0.0 0.440223 0.440223; 0.559777 0.440223 -0.0 0.559777; 0.559777 0.440223 0.559777 -0.0]
0 0 0.9257 6 0.8351 0.8351 14 0.00%
Elapsed time = 0.02 sec. (0.65 ticks, tree = 0.01 MB, solutions = 1)
Metadata
Metadata
Assignees
Labels
Status: Help WantedHelp is welcome on this issueHelp is welcome on this issuegood first issueThis issue is recommended for new users, it does not require a thorough understanding of the packageThis issue is recommended for new users, it does not require a thorough understanding of the package