-
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
Steady state sensitivity modes #1727
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1727 +/- ##
===========================================
+ Coverage 77.82% 77.89% +0.06%
===========================================
Files 74 74
Lines 12018 12033 +15
===========================================
+ Hits 9353 9373 +20
+ Misses 2665 2660 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Co-authored-by: Fabian Fröhlich <fabian_froehlich@hms.harvard.edu>
…to stst_problem_settings
I would guess that the expected |
I should have set different |
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.
great work 👍 , not sure why the last remaining test fails, don't see anything that could lead to test failure.
src/steadystateproblem.cpp
Outdated
@@ -90,16 +90,21 @@ void SteadystateProblem::workSteadyStateBackwardProblem( | |||
void SteadystateProblem::findSteadyState(const Solver *solver, Model *model, | |||
int it) { | |||
steady_state_status_.resize(3, SteadyStateStatus::not_run); | |||
bool turnOffNewton = solver->getSensitivityMethod() == |
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.
Don't we generally wan't to turn off the newton solver if model->getSteadyStateSensitivityMode() == SteadyStateSensitivityMode::integrationOnly
? Why also require forward sensitivities here?
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.
Because in adjoint case steady-state computation part is independent of sensitivities computation.
If model->getSteadyStateSensitivityMode() == SteadyStateSensitivityMode::integrationOnly
in adjoint case, I think model steady-state could still be found by Newton method.
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.
Ah, think I am starting to understand. But that ignores solver->getSensitivityMethodPreequilibration()
, right?
I think the best way is to go via SteadystateProblem::getSensitivityFlag
here.
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.
Sorry, noticed a couple more things that need to be adressed :(
(model->getSteadyStateSensitivityMode() == | ||
SteadyStateSensitivityMode::integrationOnly || | ||
model->getSteadyStateSensitivityMode() == | ||
SteadyStateSensitivityMode::integrateIfNewtonFails); | ||
|
||
bool simulationStartedInSteadystate = |
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 think this code requires some updates as the newton solver can't check if we started in a steadystate if it is turned off.
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.
When is this an issue?
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.
For models that start in steady-state (e.g., computed outside of amici or extracted from other simulations), we don't want to be forced to deactivate the newton solver. See #1422.
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.
But thinking about it more carefully, we will only have misleading values if the newton solver is deactivated. In that case we will simply rextract sensitvities from the solver, which should be fine (but we probably perform a single, unnecessary simulaton step with sensitivities, which might be expensive).
@@ -180,7 +180,8 @@ enum class NonlinearSolverIteration { | |||
/** Sensitivity computation mode in steadyStateProblem */ | |||
enum class SteadyStateSensitivityMode { |
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 think we need some documentation of the behavior for the different values, for example in the function Model::setSteadyStateSensitivityMode()
. https://github.com/AMICI-dev/AMICI/blob/master/python/examples/example_constant_species/ExampleEquilibrationLogic.ipynb also needs to be updated.
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.
Yeah, this notebook definitely needs to be updated.
src/steadystateproblem.cpp
Outdated
@@ -90,16 +90,21 @@ void SteadystateProblem::workSteadyStateBackwardProblem( | |||
void SteadystateProblem::findSteadyState(const Solver *solver, Model *model, | |||
int it) { | |||
steady_state_status_.resize(3, SteadyStateStatus::not_run); | |||
bool turnOffNewton = solver->getSensitivityMethod() == |
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.
Ah, think I am starting to understand. But that ignores solver->getSensitivityMethodPreequilibration()
, right?
I think the best way is to go via SteadystateProblem::getSensitivityFlag
here.
You are right about the preequilibration. |
Yes, that looks correct. |
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.
👍
SonarCloud Quality Gate failed. |
Settings for specifying sensitivities computation method at steady state have been implemented/reworked. Three `SteadyStateSensitivityMode` are available for both `SensitivityMethod`s (`forward` and `adjoint`): - `newtonOnly`: only Newton's method is used for sensitivities computation - `integrationOnly`: only integration is used for sensitivities computation, which in forward sensitivity analysis case means that numerical integration has to be used to find the steady state - `integrateIfNewtonFails`: more flexible option, where simulation is used if Newton's method fails Note: Previously available `SteadyStateSensitivityMode` `simulationFSA` has been removed. Co-authored-by: Fabian Fröhlich <fabian_froehlich@hms.harvard.edu>
* exploit stoichiometric matrix * add solver mapping * fixup * fixups * fixup * fixup conservation laws * Steady state sensitivity modes (#1727) * Steady State Sensitivity modes * integrationOnly and integrateIfNewtonFails in forward sensitivity case * turn off newton method in case integrationOnly and forward sensitivity * python tests * Apply suggestions from code review Co-authored-by: Fabian Fröhlich <fabian_froehlich@hms.harvard.edu> * turn off newtin in findSteadyState * fix test_compare_conservation_laws_sbml * take preequilibration into account * fix test_compare_conservation_laws_sbml * quick notebook fix Co-authored-by: Fabian Fröhlich <fabian_froehlich@hms.harvard.edu> * update according to reviews Co-authored-by: Polina Lakrisenko <p.lakrisenko@gmail.com>
Settings for specifying sensitivities computation method at steady state have been implemented/reworked.
Three
SteadyStateSensitivityMode
are available for bothSensitivityMethod
s (forward
andadjoint
):newtonOnly
: only Newton's method is used for sensitivities computationintegrationOnly
: only integration is used for sensitivities computation, which in forward sensitivity analysis case means that numerical integration has to be used to find the steady stateintegrateIfNewtonFails
: more flexible option, where simulation is used if Newton's method failsNote: Previously available
SteadyStateSensitivityMode
simulationFSA
has been removed.