Closed odow closed 8 months ago
Thanks! Will take a look, we started rewriting those this very week. PR should be online late next week. We will test on this example as well.
Thanks for reporting!
In fact, the presolve from Xpress removed the column 0 from the original problem and couldn't add the specified cut.
One way to work around this problem is to disable the presolve, but this is not really necessary. It is possible to map solutions and cutting planes beetween the original and presolved problem, you just need to set the control MIPDUALREDUCTIONS
to 0.
https://www.fico.com/fico-xpress-optimization/docs/latest/solver/optimizer/HTML/MIPDUALREDUCTIONS.html
using JuMP
using Xpress
model = Model(()->Xpress.Optimizer())
@variable(model, x >= 0, Int)
@variable(model, y >= 0, Int)
@variable(model, FO >= 0)
@constraint(model, FO == x + y )
@constraint(model, x + y <= 220 )
@objective(model, Max, FO)
function lazy_flow_constraints(cb_data)
x_val = callback_value(cb_data,x)
y_val = callback_value(cb_data,y)
if x_val + y_val > 10
con = @build_constraint( x + y <= 10 )
MOI.submit(model, MOI.LazyConstraint(cb_data), con)
end
end
MOI.set(model, MOI.LazyConstraintCallback(), lazy_flow_constraints)
set_optimizer_attributes(model, "MIPDUALREDUCTIONS" => 0)
optimize!(model)
@info(" Execution is " * string(termination_status(model)))
println("x=",JuMP.value(x))
println("y=",JuMP.value(y))
And gives the desired result:
┌ Warning: Callbacks in XPRESS might not work correctly with HEURSTRATEGY != 0
└ @ Xpress C:\Users\rafabench\.julia\dev\Xpress\src\MOI\MOI_wrapper.jl:2660
FICO Xpress v8.14.2, Hyper, solve started 18:38:54, Mar 5, 2023
Heap usage: 124KB (peak 124KB, 595KB system)
Maximizing MILP using up to 4 threads and up to 15GB memory, with these control settings:
OUTPUTLOG = 1
MPSNAMELENGTH = 64
CALLBACKFROMMASTERTHREAD = 1
MIPDUALREDUCTIONS = 0
Original problem has:
2 rows 3 cols 5 elements 2 globals
Presolved problem has:
0 rows 2 cols 0 elements 2 globals
1 delrows
LP relaxation tightened
Presolve finished in 0 seconds
Heap usage: 129KB (peak 145KB, 595KB system)
Coefficient range original solved
Coefficients [min,max] : [ 1.00e+00, 1.00e+00] / [ 0.0, 0.0]
RHS and bounds [min,max] : [ 2.20e+02, 2.20e+02] / [ 2.20e+02, 2.20e+02]
Objective [min,max] : [ 1.00e+00, 1.00e+00] / [ 1.00e+00, 1.00e+00]
Autoscaling applied standard scaling
Will try to keep branch and bound tree memory usage below 7.1GB
*** Solution found: .000000 Time: 0 Heuristic: T ***
Starting concurrent solve with dual (1 thread)
Concurrent-Solve, 0s
Dual
objective dual inf
D 440.00000 .0000000
------- optimal --------
Concurrent statistics:
Dual: 0 simplex iterations, 0.00s
Optimal solution found
Its Obj Value S Ninf Nneg Sum Dual Inf Time
0 440.000000 D 0 0 .000000 0
Dual solved problem
0 simplex iterations in 0.01 seconds at time 0
Final objective : 4.400000000000000e+02
Max primal violation (abs/rel) : 0.0 / 0.0
Max dual violation (abs/rel) : 0.0 / 0.0
Max complementarity viol. (abs/rel) : 0.0 / 0.0
Starting root cutting & heuristics
Its Type BestSoln BestBound Sols Add Del Gap GInf Time
Heuristic search 'R' started
Heuristic search 'R' stopped
* 10.000000 10.000000 2 -0.00% 0 0
*** Search completed ***
Uncrunching matrix
Final MIP objective : 1.000000000000000e+01
Final MIP bound : 1.000000000000000e+01
Solution time / primaldual integral : 0s/ 99.454320%
Number of solutions found / nodes : 2 / 1
Max primal violation (abs/rel) : 0.0 / 0.0
Max integer violation (abs ) : 0.0
[ Info: Execution is OPTIMAL
x=10.0
y=-0.0
Hi!
I happen to also be trying to implement a "lazy constraint" approach to solve a model with Xpress. I am not having the same issue, mine is related that the first callback all succeeds to submit the lazy constraint, but after a certain number of calls (depending on the problem instance that I am solving), it kind of "freezes" and eventually the time limit pops. Could it have any relations?
Best
See also https://discourse.julialang.org/t/lazy-constraints-issues-with-presolve/110449.
We should probably just set MIPDUALREDUCTIONS
by default if you have a callback.
Reported on https://discourse.julialang.org/t/issue-with-lazy-constraints-on-xpress/95463
yields