# Trouble Accessing Minimizer from Optim

Hi All,

I am new to Julia and I am using the Optim package for the first time. The optimize function seems to be finding a solution to my problem, but I cannot figure out how to access the solution. All I see is the objective value. The Optim documentation states that the result object should have a “minimizer” field, but whenever I try to access this field, I get an error that “minimizer is not defined”. Any help would be greatly appreciated. I am guessing there is a very simple answer, but I have not been able to figure it out. Thanks!

• Status: success

• Candidate solution
Final objective value: -1.647806e+00

• Found with
Algorithm: Fminbox with L-BFGS

• Convergence measures
|x - x’| = 9.51e-07 ≰ 0.0e+00
|x - x’|/|x’| = 3.03e-06 ≰ 0.0e+00
|f(x) - f(x’)| = 0.00e+00 ≤ 0.0e+00
|f(x) - f(x’)|/|f(x’)| = 0.00e+00 ≤ 0.0e+00
|g(x)| = 8.43e-10 ≤ 1.0e-08

• Work counters
Seconds run: 0 (vs limit Inf)
Iterations: 3
f(x) calls: 23
∇f(x) calls: 23

Can you show what you have actually done to get the error? Because this works:

``````julia> using Optim

julia> rosenbrock(x) =  (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
rosenbrock (generic function with 1 method)

julia> result = optimize(rosenbrock, zeros(2), BFGS())
* Status: success
(...)

julia> result.minimizer
2-element Vector{Float64}:
0.9999999926033423
0.9999999852005353
``````
1 Like

Hi, it is working now. I am not sure what I was doing wrong before. Thanks!

1 Like