-
Notifications
You must be signed in to change notification settings - Fork 31
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
simplify steadystate logic #1485
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1485 +/- ##
===========================================
+ Coverage 79.43% 79.55% +0.12%
===========================================
Files 66 66
Lines 10370 10374 +4
===========================================
+ Hits 8237 8253 +16
+ Misses 2133 2121 -12
Flags with carried forward coverage won't be shown. Click here to find out more.
|
That one was on my to-do-list anyway... Would have been good to discuss this prior to you putting effort in it... So, give me some background please, as the PR has no description:
|
The big issue is that there was a single function that served 3 different purposes (check whether simulation needs to be stored, whether simulation needs to be run with sensitivities, and whether sensitivities are to be computed using the implicit function theorem). This is in violation of the single-responsibility principle (https://en.wikipedia.org/wiki/Single-responsibility_principle), giving rise to code execution that is so complicated that eve you got confused about it #1461 .
It partially addresses the item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's somewhat orthogonal to what I have planned to do with the steady state solver, therefore I'm not completely happy about it
If I'm not mistaken, the SteadyStateContext flag isn't used any more by now. In this case, please remove it also from include/amici/defines.h
src/steadystateproblem.cpp
Outdated
|
||
if (solver.getSensitivityMethodPreequilibration() | ||
== SensitivityMethod::adjoint && | ||
model.getSteadyStateSensitivityMode() == | ||
SteadyStateSensitivityMode::simulationFSA) | ||
throw AmiException("Preequilibration using adjoint sensitivities " | ||
"is not compatible with simulationFSA " | ||
"sensitivity mode."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that setting SteadyStateSensitivityMode::simulationFSA
and allowing to use adjoint preequilibration is counter-intuitive. However, it would make much sense to allow the user to switch off the Newton solver and using adjoint preequilibration... Would be happy if there was a way to encode this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that setting
SteadyStateSensitivityMode::simulationFSA
and allowing to use adjoint preequilibration is counter-intuitive. However, it would make much sense to allow the user to switch off the Newton solver and using adjoint preequilibration... Would be happy if there was a way to encode this...
How about setting the allowed newton steps to 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, there would be the options newtonOnly, simulationFSA, and simulationASA and something that first tries Newton and uses simulation only if Newton fails... But no need to implement this now.
Something else: I'd advocate to move the steadyStateSensitivitiyMode from model to solver. The value may be model dpeendent, but it encodes the behavior of the solver. Therefore, I'd be happy if we could move this at some point. What's your opinion on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, there would be the options newtonOnly, simulationFSA, and simulationASA and something that first tries Newton and uses simulation only if Newton fails... But no need to implement this now.
I think most of these settings can already be achieved with existing options.
Something else: I'd advocate to move the steadyStateSensitivitiyMode from model to solver. The value may be model dpeendent, but it encodes the behavior of the solver. Therefore, I'd be happy if we could move this at some point. What's your opinion on this?
Yes, I agree, I found it confusing that this is in model, not solver.
src/steadystateproblem.cpp
Outdated
if (solver->getSensitivityOrder() >= SensitivityOrder::first && | ||
model->getSteadyStateSensitivityMode() == | ||
SteadyStateSensitivityMode::simulationFSA && | ||
solver->getSensitivityMethod() != SensitivityMethod::forward) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again not quite getting why you want to exclude this, but okay if you feel like it's really necessary...
Anyhow: All these quantities should have been set prior to the creation of the SteadyStateProblem object and could be caught in the constructor (together with the additional check you implemented there), ideally by using a method like check_steady_state_solver_options
or similar...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check may have become obsolete after adding the respective checks to the constructor.
@@ -462,7 +472,7 @@ bool SteadystateProblem::checkConvergence(const Solver *solver, | |||
sx_ = solver->getStateSensitivity(t_); | |||
model->fsxdot(t_, x_, dx_, ip, sx_[ip], dx_, xdot_); | |||
wrms_ = getWrmsNorm( | |||
x_, xdot_, solver->getAbsoluteToleranceSteadyStateSensi(), | |||
sx_[ip], xdot_, solver->getAbsoluteToleranceSteadyStateSensi(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
If you plan stuff for a year or so and never follow through, you kinda have to live with the possibility that someone starts working on it beforehand.
👍 |
No problem with somebody else working on it at all. But I created a milestone and organized issues for this for the precise reason that one can discuss the way how its implemented prior to it being done... |
…-dev/AMICI into simplify_steadystate_logic
@paulstapor I added a mixed mode which restores the possibility to use combinations of FSA with newton methods |
SonarCloud Quality Gate failed. |
okay at this point I simply give up and consider the simulationFSA functionality broken. AMICI/python/tests/test_preequilibration.py Line 307 in 4e671a5
|
No description provided.