JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.1k stars 214 forks source link

also show the minimizer #1054

Closed MariusDrulea closed 5 months ago

MariusDrulea commented 8 months ago

Currently the optimize function does show a candidate solution, but only the minimum of the function is shown. We shall also show the minimizer of the function, such that the provided info is complete.

Looks like this now:

 * Status: success (objective increased between iterations)

 * Candidate solution
    Minimizer:     [214.63875045325074, 207.70250063762063, 214.6387496819325, 60.99374379542592, -1.6462211405820447e-10, -2.329416881307505e-9, -2.8537271470976752e-8]
    Final objective value:     8.456923e-13

 * Found with
    Algorithm:     L-BFGS

 * Convergence measures
    |x - x'|               = 2.49e-12 ≤ 1.0e-07
    |x - x'|/|x'|          = 1.16e-14 ≰ 0.0e+00
    |f(x) - f(x')|         = 8.45e-19 ≰ 0.0e+00
    |f(x) - f(x')|/|f(x')| = 9.99e-07 ≰ 0.0e+00
    |g(x)|                 = 6.38e-06 ≰ 1.0e-07

 * Work counters
    Seconds run:   0  (vs limit Inf)
    Iterations:    46
    f(x) calls:    228
    ∇f(x) calls:   228
annuges commented 7 months ago

Just another user here so someone else will need to make that call but I don’t think printing the minimizer like that is a good idea.

While it might be fine for smaller problems dumping the entire Parameter vector of say a +100k parameter model into the console would be completely unusable.

pkofod commented 6 months ago

We used to have this, and I must admit that I removed it because we had to default to showing at max 5 values or something like that, and at that point it gets quite useless for many real use cases. An alternative may of course be to show it in vertical alignment, but I think it's better for the user to just print Optim.minimizer(res) after the optimization run. I'm open to counter arguments of course. You could show it in more of a n x 5 grid that gets wrapped such that you only show 5 columns, but still, if you have hundreds of thousands of variables it will kill your terminal.

pkofod commented 5 months ago

You're welcome to open this if you want to argue the case that it should be shown.