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

Printing progress to terminal when running optimization? #78

Closed
Yuricst opened this issue Apr 12, 2023 · 3 comments
Closed

Printing progress to terminal when running optimization? #78

Yuricst opened this issue Apr 12, 2023 · 3 comments

Comments

@Yuricst
Copy link

Yuricst commented Apr 12, 2023

Hi,
I was wondering if there are any ways to display to the terminal the information during the optimization (something like a verbosity clause, e.g. the message you'd get when running pygmo: https://esa.github.io/pygmo2/tutorials/nlopt_basics.html?highlight=verbosity).
It could also maybe be the option to include a user-defined callback function called at each iteration, where the function can access the status of the algorithm or something.
Apologies if I just missed it, but I couldn't find it in the documentation/examples...
Thanks!

@longemen3000
Copy link
Contributor

https://jmejia8.github.io/Metaheuristics.jl/stable/api/#Metaheuristics.Options, using debug = true ?

@jmejia8
Copy link
Owner

jmejia8 commented Apr 12, 2023

Hi!

Example 1

You can use the debug=true in the Options

f, bounds, _ = Metaheuristics.TestProblems.get_problem(:discus);
# show information on the optimization process when debug=true 
my_options = Options(debug=true)
# optimize and get results
result = optimize(f, bounds, ECA(options=my_options))

Example 2

Besides, you can pass a logger function to optimize.

f, bounds, _ = Metaheuristics.TestProblems.get_problem(:discus);
# logger function is called each iteration
my_logger(status) = println("Iteration: ", status.iteration, "  | f calls: ", nfes(status), " |  Min: ", minimum(status))
result = optimize(f, bounds, ECA(); logger = my_logger)

See State for more information.

@Yuricst
Copy link
Author

Yuricst commented Apr 12, 2023

Awesome, thank you!

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

3 participants