JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.11k stars 213 forks source link

LoadError: MethodError: no method matching Optim.IPNewtonState #1019

Closed dhathri-auburn closed 1 year ago

dhathri-auburn commented 1 year ago

Hello, I am new to Optim.jl and Julia in general. But, I am trying to implement an NLP program for a collocation scheme using this package and the IPNewton solver within this package. I get this error complaining about IPNewtonState method not being matched/found.

Here is the full error: ERROR: LoadError: MethodError: no method matching Optim.IPNewtonState(::Matrix{Real}, ::Int64, ::Matrix{Real}, ::Matrix{Real}, ::Float64, ::Matrix{Real}, ::Int64, ::Vector{Int8}, ::Matrix{Real}, ::Int64, ::Int64, ::Float64, ::Float64, ::Optim.BarrierStateVars{Float64}, ::Optim.BarrierStateVars{Float64}, ::Optim.BarrierStateVars{Float64}, ::Vector{Float64}, ::Matrix{Float64}, ::Float64, ::Matrix{Real}, ::Int64, ::Optim.BarrierLineSearchGrad{Float64}, ::Matrix{Real}, ::Int64) Closest candidates are: Optim.IPNewtonState(::Tx, ::T, ::Tx, ::Tx, ::T, ::Matrix{T}, ::Any, ::Vector{Int8}, ::Tx, ::T, ::T, ::T, ::T, ::Optim.BarrierStateVars{T}, ::Optim.BarrierStateVars{T}, ::Optim.BarrierStateVars{T}, ::Vector{T}, ::Matrix{T}, ::T, ::Tx, ::T, ::Optim.BarrierLineSearchGrad{T}, ::Tx, ::Any) where {T, Tx} at C:\Users\dhs0020\.julia\packages\Optim\Zq1jM\src\multivariate\solvers\constrained\ipnewton\ipnewton.jl:53 And here is the code snippet that invokes the IPNewton solver:

`using Optimization, OptimizationMOI, OptimizationOptimJL, Ipopt using ForwardDiff, ModelingToolkit

function optimizer(X0, params, lb, ub, lcons, ucons) objective = OptimizationFunction(cost, Optimization.AutoForwardDiff(), cons = constraints) collocation_params = create_common_parameters_for_collocation() merge!(params, collocation_params) problem = Optimization.OptimizationProblem(objective, X0, params, lb = lb, ub = ub, lcons = lcons, ucons = ucons)

# sol = solve(problem, IPNewton(), maxiters = 1; show_trace = true, show_every = 1)
sol = solve(problem, IPNewton())

return sol

end`

I appreciate any help provided to get past this issue.

Thanks, Dhathri

dhathri-auburn commented 1 year ago

I was able to resolve this issue by myself. It had to do with the way I defined initial X (datatype wise) and lower and upper bounds for X and constraints. Once I fixed those data types, this is now running.