I am using Optim.jl to minimize a certain objective function which includes some secondary calculations. I use
algo_ = LBFGS(;alphaguess =InitialHagerZhang(), linesearch = LineSearches.StrongWolfe()) a = Optim.optimize( x -> Objective(x, "opt"), Gradient!, X_vec, method = algo_; g_tol=1e-5, inplace = true, show_trace = true, store_trace=true, )
Iter Function value Gradient norm 0 1.402120e+02 5.798513e+01 * time: 0.0009999275207519531 1 1.215444e+02 2.696291e+01 * time: 3.1009998321533203 2 9.729868e+01 2.400409e+01 * time: 7.192999839782715 3 9.402650e+01 6.969861e+00 * time: 8.806999921798706 4 9.353115e+01 4.200973e+00 * time: 9.63699984550476 5 9.285567e+01 5.642217e+00 * time: 10.458999872207642 6 6.870792e+01 9.093026e+00
What I eventually want is to manipulate the trace a bit to show an additional column containing some secondary calculations from inside of the objective function. I tried to add a print line inside, but as expected, it prints every time the function is called by the line-search algorithm, leading to extra unnecessary information. Any suggestion?