lanl-ansi / Juniper.jl

A JuMP-based Nonlinear Integer Program Solver
https://lanl-ansi.github.io/Juniper.jl/stable/
MIT License
179 stars 22 forks source link

Custom Linear relaxations for feasibility pump #254

Open this-josh opened 1 year ago

this-josh commented 1 year ago

I have a non-linear program

juniper_opt = optimizer_with_attributes(Juniper.Optimizer, "nl_solver" => Ipopt.Optimizer, "mip_solver" => Gurobi.Optimizer)
model = Model(juniper_opt)
@variable(model, a)
@NLconstraint(model, a * abs(a) >=3)
@objective(model, Min, a)
optimize!(model)

Now when Juniper creates a MILP to do the feasibility pump it's my understanding it uses everything but the non-linear constraints. In my instance I have a linear relaxation of the non-linear constraints. So I've made it so that Juniper can accept an mip model for the feasibility pump.

mip = Model(juniper_opt)
@variable(mip, a)
@constraint(mip, a * a >=3)
@objective(mip, Min, a)
set_optimizer_attribute(model, "mip_model", mip)

optimize!(model)

Essentially all that changes is in the fpump code I pass the mip model, perhaps there's more that could be done. For my use case this is helpful as my linear relaxation won't remove any valid solutions and it can quickly show a lot to be infeasible.

Is this code of interest? If so, I can open a PR.

Wikunia commented 1 year ago

Yes that would be a nice addition. It currently removes all non linear constraints and changes the objective such that it minimizes the difference to the NLP relaxation. Looking forward to your PR 😊

this-josh commented 1 year ago

After reviewing my current implementation I think I need to better understand MOI before I can do a good job of this. For now I'll have to put this on pause, but it is still on my lists of things to do.