Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in OptimizationMOI when using HiGHS.Optimizer() but works with Ipopt.Optimizer() #806

Open
avinashresearch1 opened this issue Aug 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@avinashresearch1
Copy link

Describe the bug 🐞

bug in:

if f.adtype isa Optimization.AutoModelingToolkit

ERROR: TypeError: in isa, expected Type, got a value of type typeof(AutoModelingToolkit)
Stacktrace:
 [1] OptimizationMOI.MOIOptimizationCache(prob::OptimizationProblem{…}, opt::MathOptInterface.OptimizerWithAttributes; kwargs::@Kwargs{…})

Minimal Reproducible Example 👇

using Optimization, OptimizationMOI, Ipopt


obj_f(x, p) = 12*x[1] + 20*x[2]
x0 = zeros(2)
_p = SciMLBase.NullParameters()
cons = (res, x, p) -> res .= [
    6*x[1] + 8*x[2]
    7*x[1] + 12*x[2]
    ]
    
opt_fun = OptimizationFunction(obj_f, Optimization.AutoModelingToolkit(); cons = cons)
prob = OptimizationProblem(opt_fun, x0, _p; lcons = [100.0, 120.0], ucons = [+Inf, + Inf], lb = [0.0, 0.0], ub = [+Inf, 3.0])
    

res = solve(prob, Ipopt.Optimizer()) # WORKS

using HiGHS
res = solve(prob, HiGHS.Optimizer()) # ERROR
 
res = solve(prob, OptimizationMOI.MOI.OptimizerWithAttributes(HiGHS.Optimizer)) # SAME ERROR

Error & Stacktrace ⚠️

julia> show(err)
1-element ExceptionStack:
LoadError: TypeError: in isa, expected Type, got a value of type typeof(AutoModelingToolkit)
Stacktrace:
  [1] OptimizationMOI.MOIOptimizationCache(prob::OptimizationProblem{true, OptimizationFunction{true, AutoSymbolics, typeof(obj_f), Nothing, Nothing, Nothing, Nothing, Nothing, var"#25#26", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Vector{Float64}, Vector{Float64}, Nothing, Vector{Float64}, Vector{Float64}, Nothing, @Kwargs{}}, opt::MathOptInterface.OptimizerWithAttributes; kwargs::@Kwargs{maxiters::Nothing, maxtime::Nothing, abstol::Nothing, reltol::Nothing})
    @ OptimizationMOI ~/.julia/packages/OptimizationMOI/LnXYV/src/moi.jl:19
  [2] __init(prob::OptimizationProblem{true, OptimizationFunction{true, AutoSymbolics, typeof(obj_f), Nothing, Nothing, Nothing, Nothing, Nothing, var"#25#26", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Vector{Float64}, Vector{Float64}, Nothing, Vector{Float64}, Vector{Float64}, Nothing, @Kwargs{}}, opt::MathOptInterface.OptimizerWithAttributes; maxiters::Nothing, maxtime::Nothing, abstol::Nothing, reltol::Nothing, mtkize::Bool, kwargs::@Kwargs{})
    @ OptimizationMOI ~/.julia/packages/OptimizationMOI/LnXYV/src/OptimizationMOI.jl:310
  [3] __init
    @ ~/.julia/packages/OptimizationMOI/LnXYV/src/OptimizationMOI.jl:292 [inlined]
  [4] #init#650
    @ ~/.julia/packages/SciMLBase/OXryf/src/solve.jl:174 [inlined]
  [5] init
    @ ~/.julia/packages/SciMLBase/OXryf/src/solve.jl:172 [inlined]
  [6] solve(::OptimizationProblem{true, OptimizationFunction{true, AutoSymbolics, typeof(obj_f), Nothing, Nothing, Nothing, Nothing, Nothing, var"#25#26", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Vector{Float64}, Vector{Float64}, Nothing, Vector{Float64}, Vector{Float64}, Nothing, @Kwargs{}}, ::MathOptInterface.OptimizerWithAttributes; kwargs::@Kwargs{})
    @ SciMLBase ~/.julia/packages/SciMLBase/OXryf/src/solve.jl:96
  [7] solve(::OptimizationProblem{true, OptimizationFunction{true, AutoSymbolics, typeof(obj_f), Nothing, Nothing, Nothing, Nothing, Nothing, var"#25#26", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Vector{Float64}, Vector{Float64}, Nothing, Vector{Float64}, Vector{Float64}, Nothing, @Kwargs{}}, ::MathOptInterface.OptimizerWithAttributes)
    @ SciMLBase ~/.julia/packages/SciMLBase/OXryf/src/solve.jl:93

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
  [87dc4568] HiGHS v1.9.2
  [b6b21f68] Ipopt v1.6.6
  [7f7a1694] Optimization v3.27.0
  [fd9f6733] OptimizationMOI v0.4.3
@avinashresearch1 avinashresearch1 added the bug Something isn't working label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant