SciML / Optimization.jl

Mathematical Optimization in Julia. Local, global, gradient-based and derivative-free. Linear, Quadratic, Convex, Mixed-Integer, and Nonlinear Optimization in one simple, fast, and differentiable interface.
https://docs.sciml.ai/Optimization/stable/
MIT License
704 stars 77 forks source link

No sol.stats for NLopt #625

Closed QinyingChen closed 7 months ago

QinyingChen commented 9 months ago
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p = [1.0, 100.0]
f = OptimizationFunction(rosenbrock, Optimization.AutoForwardDiff())
prob = Optimization.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
sol = solve(prob, NLopt.LD_LBFGS())

This is the example from NLopt.jl tutorial page. I would expect to have sol.stats to work, for example, showing me how many iterations it takes, and so on. But it shows nothing. Any help is appreciated. Thanks.

Vaibhavdixit02 commented 9 months ago

We don't have sol.stats implemented yet unfortunately. It's on the todo list!

Vaibhavdixit02 commented 9 months ago

You have the original result from the solver package in the sol.original field, I think NLopt doesn't really give a lot of output but you could dig around in its docs to see how to obtain the information you want from that object

Vaibhavdixit02 commented 7 months ago

This is now implemented and should be accessible in sol

QinyingChen commented 4 months ago

Thank you for the update. Appreciated.