Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress meter #1079

Closed
roflmaostc opened this issue Feb 7, 2024 · 1 comment
Closed

Add progress meter #1079

roflmaostc opened this issue Feb 7, 2024 · 1 comment

Comments

@roflmaostc
Copy link

Hi,

is there an option to include a progressbar for the optimization?
Something like: https://julialogging.github.io/reference/progresslogging/#ProgressLogging.jl

Best,

Felix

@roflmaostc
Copy link
Author

roflmaostc commented Jun 4, 2024

Now I use this:

const start_time = Ref(zeros(1))
const last_time = Ref(zeros(1))
function log_time(x)
   if x[end].iteration == 0
       start_time[] .= time()
       last_time[] .= time()
   end 
   @info "Iteration:\t$(x[end].iteration),\t total time:\t$(round(time()-start_time[][1], digits=2))s,\ttime since last iteration:\t$(round(time()-last_time[][1],  digits=2))s"

   last_time[] .= time()
   return false
end


@time patterns_vial, printed_intensity_vial, optim_res_vial = optimize_patterns(togoc(target), geometry_vial, 
GradientBased(optimizer=Optim.LBFGS(), 
options=Optim.Options(iterations=5, store_trace=true, 
                                           callback=SwissVAMyKnife.log_time)), loss)

Resulting in:

Iteration:	0,	 total time:	0.0s,	time since last iteration:	0.0s

Iteration:	1,	 total time:	0.91s,	time since last iteration:	0.91s

Iteration:	2,	 total time:	1.64s,	time since last iteration:	0.73s

Iteration:	3,	 total time:	2.38s,	time since last iteration:	0.73s

Iteration:	4,	 total time:	3.12s,	time since last iteration:	0.74s

Iteration:	5,	 total time:	3.85s,	time since last iteration:	0.74s
``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant