joaquimg / BilevelJuMP.jl

Bilevel optimization in JuMP
Other
106 stars 27 forks source link

Test with Alpine #195

Open joaquimg opened 1 year ago

joaquimg commented 1 year ago

Running Alpine with Ipopt+HiGHS.

Most cases fail.

1 - Many seem sem to be trying to add a quadratic constraint to HiGHS:

 Constraints of type MathOptInterface.ScalarQuadraticFunction{Float64}-in-MathOptInterface.GreaterThan{Float64} are not supported by the solver.

  If you expected the solver to support your problem, you may have an error in your formulation. Otherwise, consider using a different solver.

  The list of available solvers, along with the problem types they support, is available at https://jump.dev/JuMP.jl/stable/installation/#Supported-solvers.
  Stacktrace:
    [1] error(s::String)
      @ Base .\error.jl:35
    [2] _moi_add_constraint(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, f::MathOptInterface.ScalarQuadraticFunction{Float64}, s::MathOptInterface.GreaterThan{Float64})

I would expect that quadratic constraints are forwarded to Ipopt as non-linear constraints.

2 - Another common error is:

  Result index of attribute MathOptInterface.ObjectiveValue(1) out of bounds. There are currently 0 solution(s) in the model.
  Stacktrace:
    [1] check_result_index_bounds
      @ C:\Users\joaquimgarcia\.julia\packages\MathOptInterface\NCblk\src\attributes.jl:207 [inlined]
    [2] get
      @ C:\Users\joaquimgarcia\.julia\packages\HiGHS\QRk9O\src\MOI_wrapper.jl:1880 [inlined]
    [3] get(b::MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, attr::MathOptInterface.Bridges.ObjectiveFunctionValue{MathOptInterface.ScalarAffineFunction{Float64}})
      @ MathOptInterface.Bridges C:\Users\joaquimgarcia\.julia\packages\MathOptInterface\NCblk\src\Bridges\bridge_optimizer.jl:993
    [4] get(model::MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, attr::MathOptInterface.Bridges.ObjectiveFunctionValue{MathOptInterface.VariableIndex}, #unused#::MathOptInterface.Bridges.Objective.FunctionizeBridge{Float64})
      @ MathOptInterface.Bridges.Objective C:\Users\joaquimgarcia\.julia\packages\MathOptInterface\NCblk\src\Bridges\Objective\bridges\functionize.jl:96
    [5] get(b::MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, attr::MathOptInterface.Bridges.ObjectiveFunctionValue{MathOptInterface.VariableIndex})
      @ MathOptInterface.Bridges C:\Users\joaquimgarcia\.julia\packages\MathOptInterface\NCblk\src\Bridges\bridge_optimizer.jl:991
    [6] get(b::MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, attr::MathOptInterface.ObjectiveValue)
      @ MathOptInterface.Bridges C:\Users\joaquimgarcia\.julia\packages\MathOptInterface\NCblk\src\Bridges\bridge_optimizer.jl:1000
    [7] _get_model_attribute(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, attr::MathOptInterface.ObjectiveValue)
      @ MathOptInterface.Utilities C:\Users\joaquimgarcia\.julia\packages\MathOptInterface\NCblk\src\Utilities\cachingoptimizer.jl:828
    [8] get
      @ C:\Users\joaquimgarcia\.julia\packages\MathOptInterface\NCblk\src\Utilities\cachingoptimizer.jl:876 [inlined]
    [9] _moi_get_result(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, args::MathOptInterface.ObjectiveValue)
      @ JuMP C:\Users\joaquimgarcia\.julia\packages\JuMP\bofhg\src\optimizer_interface.jl:680
   [10] get(model::Model, attr::MathOptInterface.ObjectiveValue)
      @ JuMP C:\Users\joaquimgarcia\.julia\packages\JuMP\bofhg\src\optimizer_interface.jl:700
   [11] objective_value(model::Model; result::Int64)
      @ JuMP C:\Users\joaquimgarcia\.julia\packages\JuMP\bofhg\src\objective.jl:54
   [12] objective_value
      @ C:\Users\joaquimgarcia\.julia\packages\JuMP\bofhg\src\objective.jl:50 [inlined]
   [13] solve_obbt_model(m::Alpine.Optimizer; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
      @ Alpine C:\Users\joaquimgarcia\.julia\packages\Alpine\85o9X\src\presolve.jl:357

Seems that Alpine is not handling some HiGHS fails well. Possibly due unbounded variables?

cc @harshangrjn @odow

harshangrjn commented 1 year ago

If the problem has convex quadratic constraints, then using Pavito + Highs should work (Alpine's tests have a few examples). Ipopt is used only for feasibility. Unbounded variables shouldn't be an issue as Alpine automatically applies large bounds on them and then tries to tighten their bounds. If you still have issues, share a working example where you can reproduce the issue.

harshangrjn commented 1 year ago

@joaquimg Did using Pavito work like here: https://github.com/lanl-ansi/Alpine.jl/blob/8a3f9c56968dfbe49c4aa321e3bda47f2fb1c343/test/runtests.jl#L37 and https://github.com/lanl-ansi/Alpine.jl/blob/8a3f9c56968dfbe49c4aa321e3bda47f2fb1c343/test/test_algorithm.jl#L104