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

Simple interface for recording optimization trajectory #631

Open
TorkelE opened this issue Nov 19, 2023 · 3 comments
Open

Simple interface for recording optimization trajectory #631

TorkelE opened this issue Nov 19, 2023 · 3 comments

Comments

@TorkelE
Copy link
Member

TorkelE commented Nov 19, 2023

It would be useful to have a good interface for recording the path of all evaluated us and their fitness values. I have tried to make this happen, but it requires hacky solutions (e.g. creating a custom optimization function which also saved the evaluations).

PEtab.jl supports this, and it enables to e.g. make various plots that evaluates how successful the optimisation was: https://sebapersson.github.io/PEtab.jl/stable/optimisation_output_plotting/

Something like

opt_prob = OptimizationProblem(...)
sol = solve(opt_prob, alg; save_trace=true)

and then a vector of all evaluated us and their cost function value is stored ina field in sol.

@Vaibhavdixit02
Copy link
Member

https://docs.sciml.ai/Optimization/stable/API/optimization_state/#optstate allows access to those values in the callback now

@TorkelE
Copy link
Member Author

TorkelE commented Mar 23, 2024

Would it be possible to have an option for getting this auto-recorded via an argument, or maybe have a prepared callback that makes this possible without setting up your own system?

Ideally, having a vector of OptimizationState stored in the OptimizationSolution would be really neat (and if one is afraid that that takes lots of space, one could have a kwarg to turn that ON/OFF).

@Vaibhavdixit02
Copy link
Member

Would it be possible to have an option for getting this auto-recorded via an argument,

Would you prefer to evaluate it after running the optimization? You already have access to it while running the optimization in case you want to use it for something - including storing it in an array. Storing it and returning it at the end is not necessarily useful right now so shouldn't be the default. Some of the solvers do have the option to store a trace over the iterations allowing even much more than just iterations and the objective, so that's already possible to set on/off based on kwargs and accessible through the original field of the OptimizationSolution.

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

2 participants