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

Tutorial for using Optimization and DiffEqParamEstim for parameter fitting #708

Closed
wants to merge 49 commits into from

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Nov 1, 2023

Adds a single tutorial page. Currently put under catalyst_applications. Once #701 passes I will separately add this to the inverse problem section.

The base tutorial is done (but needs to be reread a bit), but some auxiliary sections need to be added.

@TorkelE
Copy link
Member Author

TorkelE commented Nov 2, 2023

Currently ready for Vaibhav to have a look at.

There is one problem, this bit (when fitting two data both for S and P) fails quite bad:

optprob_S_P = OptimizationProblem(loss_function_S_P, [1.0,1.0, 1.0])
optsol_S_P = solve(optprob_S_P, CMAEvolutionStrategyOpt())
oprob_fitted_S_P = remake(oprob; p=optsol_S_P.u)
fitted_sol_S_P = solve(oprob_fitted_S_P, Tsit5())
plot!(fitted_sol_S_P; idxs=[:S, :P], label="Fitted solution", linestyle=:dash, lw=6, color=[:lightblue :pink])

Is there some easy modification to options I can provide to make this work?

Copy link
Member

@isaacsas isaacsas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this fit in with the current Optimization based tutorial?

Also, why use CMAEvolutionStrategyOpt?

@TorkelE
Copy link
Member Author

TorkelE commented Nov 2, 2023

How does this fit in with the current Optimization based tutorial?

That will be moved to an separate example (and rewritten a bit and be a focus on Fitting parameters of oscillatory processes).

Also, why use CMAEvolutionStrategyOpt?

I just picked one (don't really know much on sensible selection of optimisation methods), happy to change.

@Vaibhavdixit02
Copy link
Member

I second Sam's point above, CMAES doesn't seem like a good choice here. I would recommend using a first order method (BFGS) instead, you can use it from NLopt so that'll cover multiple solver packages as well which might be useful for users to see.

@TorkelE
Copy link
Member Author

TorkelE commented Nov 2, 2023

Yeah, I just wanted to select a optimiser from another package, I can change to that one.

@TorkelE
Copy link
Member Author

TorkelE commented Nov 2, 2023

Updated to use BFGS instead.

@TorkelE
Copy link
Member Author

TorkelE commented Nov 5, 2023

This is ready for merging now.

@TorkelE TorkelE force-pushed the scimlOptimization_tutorial branch from 5164233 to ce8ddae Compare November 8, 2023 21:47
@TorkelE
Copy link
Member Author

TorkelE commented Nov 8, 2023

Will go through and check the merge and latest updates this evening. But in summary, this is now rebased on master (where the inverse problem section exists). I have also moved the previous parameter fitting tutorial to a sub folder for examples, and rewritten it a bit to make it an example of how to fit an oscillation (while this new tutorial simply shows the SciML/Optimization workflow).

@isaacsas
Copy link
Member

I need to go through this carefully still, but I think I’m going to have the same comment about not dynamically generating graphs and such.

@TorkelE
Copy link
Member Author

TorkelE commented Nov 12, 2023

See the reply there. Yes, I agree. I will see what can be done. We could always merge and put in an issue that this should be dealt with at some point of time (although we are starting to get so many issues that it is easy for stuff to get lost there, which makes me slightly reluctant)

@TorkelE
Copy link
Member Author

TorkelE commented Nov 13, 2023

This one is ready for merging

@isaacsas
Copy link
Member

Ok, I’ll let you know once I’ve read it carefully.

@TorkelE TorkelE force-pushed the scimlOptimization_tutorial branch from d1680a7 to bc47caa Compare November 22, 2023 21:08
@TorkelE TorkelE force-pushed the master branch 2 times, most recently from f20d62a to f624106 Compare November 22, 2023 21:16
@TorkelE
Copy link
Member Author

TorkelE commented Dec 4, 2023

replaced by #740

@TorkelE TorkelE closed this Dec 4, 2023
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

Successfully merging this pull request may close these issues.

3 participants