JuliaNLSolvers / Optim.jl

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

LoadError: MethodError: no method matching Optim.BarrierLineSearchGrad #1020

Closed dhathri-auburn closed 1 year ago

dhathri-auburn commented 1 year ago

Hello, I am new to Julia and Optim.jl. I am trying to figure out how to make my constrained NLP problem work within this package. I am getting the following error:

`ERROR: LoadError: MethodError: no method matching Optim.BarrierLineSearchGrad(::Vector{Float64}, ::Matrix{Float64}, ::Optim.BarrierStateVars{Real}, ::Optim.BarrierStateVars{Real}) Closest candidates are: Optim.BarrierLineSearchGrad(::Vector{T}, ::Matrix{T}, ::Optim.BarrierStateVars{T}, ::Optim.BarrierStateVars{T}) where T at C:\Users\dhs0020.julia\packages\Optim\Zq1jM\src\multivariate\solvers\constrained\ipnewton\interior.jl:153

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

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

end `

my constraints function is setting the constraints vector to a Vector{Real} element, so I am not sure why IPNewton method is thinking that the constraints vector type is Vector{Float64}, which is what is I believe the cause of this error is.

I am absolutely stuck and I would appreciate any help provided to get over this issue.

Thanks, Dhathri

dhathri-auburn commented 1 year ago

I was able to resolve this by myself. Once I resolved the data types for X, lower and upper bounds for X and constraints, this started working.