# Manipulate trace Optim.jl

**URL:** <https://discourse.julialang.org/t/manipulate-trace-optim-jl/66072>\
**Category:** General Usage\
**Tags:** optim, optimization\
**Created:** [August 9, 2021, 1:41pm UTC](https://discourse.julialang.org/t/manipulate-trace-optim-jl/66072 "2021-08-09T13:41:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AhmedAlreweny](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Post date:** [August 9, 2021, 1:41pm UTC](https://discourse.julialang.org/t/manipulate-trace-optim-jl/66072/1 "2021-08-09T13:41:57Z")

</div>

Hi,

I am using Optim.jl to minimize a certain objective function which includes some secondary calculations. I use

```julia
 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,
    )

```

that gives:

```julia
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?
