Skip to content

Commit

Permalink
Change default steady-state method to integrationOnly
Browse files Browse the repository at this point in the history
**Breaking change**

Change the default mode for computing steady states and sensitivities
at steady state to `integrationOnly` (from previously `integrateIfNewtonFails`).

This is done for a more robust default behaviour. For example, the
evaluation in https://doi.org/10.1371/journal.pone.0312148 shows
that - at least for some models - Newton's method may easily lead to
physically impossible solutions.

To keep the previous behaviour, use:
```python
amici_model.setSteadyStateComputationMode(amici.SteadyStateComputationMode.integrateIfNewtonFails)
amici_model.setSteadyStateSensitivityMode(amici.SteadyStateSensitivityMode.integrateIfNewtonFails)
```

Closes #2571.
  • Loading branch information
dweindl committed Nov 10, 2024
1 parent 0009c4a commit e47ef3c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/amici/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2063,12 +2063,12 @@ class Model : public AbstractModel, public ModelDimensions {

/** method for steady-state computation */
SteadyStateComputationMode steadystate_computation_mode_{
SteadyStateComputationMode::integrateIfNewtonFails
SteadyStateComputationMode::integrationOnly
};

/** method for steadystate sensitivities computation */
SteadyStateSensitivityMode steadystate_sensitivity_mode_{
SteadyStateSensitivityMode::integrateIfNewtonFails
SteadyStateSensitivityMode::integrationOnly
};

/**
Expand Down
2 changes: 2 additions & 0 deletions python/tests/test_compare_conservation_laws_sbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def get_results(
sensi_order=0,
sensi_meth=amici.SensitivityMethod.forward,
sensi_meth_preeq=amici.SensitivityMethod.forward,
stst_mode=amici.SteadyStateComputationMode.integrateIfNewtonFails,
stst_sensi_mode=amici.SteadyStateSensitivityMode.newtonOnly,
reinitialize_states=False,
):
Expand All @@ -115,6 +116,7 @@ def get_results(
solver.setSensitivityMethodPreequilibration(sensi_meth_preeq)
solver.setSensitivityMethod(sensi_meth)
model.setSteadyStateSensitivityMode(stst_sensi_mode)
model.setSteadyStateComputationMode(stst_mode)
if edata is None:
model.setTimepoints(np.linspace(0, 5, 101))
else:
Expand Down
7 changes: 6 additions & 1 deletion python/tests/test_preequilibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
def preeq_fixture(pysb_example_presimulation_module):
model = pysb_example_presimulation_module.getModel()
model.setReinitializeFixedParameterInitialStates(True)

model.setSteadyStateComputationMode(
amici.SteadyStateComputationMode.integrateIfNewtonFails
)
model.setSteadyStateSensitivityMode(
amici.SteadyStateSensitivityMode.integrateIfNewtonFails
)
solver = model.getSolver()
solver.setSensitivityOrder(amici.SensitivityOrder.first)
solver.setSensitivityMethod(amici.SensitivityMethod.forward)
Expand Down
7 changes: 7 additions & 0 deletions python/tests/test_pregenerated_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def test_pregenerated_model(sub_test, case):
amici.readModelDataFromHDF5(
options_file, model.get(), f"/{sub_test}/{case}/options"
)
if model_name == "model_steadystate":
model.setSteadyStateComputationMode(
amici.SteadyStateComputationMode.integrateIfNewtonFails
)
model.setSteadyStateSensitivityMode(
amici.SteadyStateSensitivityMode.integrateIfNewtonFails
)
amici.readSolverSettingsFromHDF5(
options_file, solver.get(), f"/{sub_test}/{case}/options"
)
Expand Down
8 changes: 4 additions & 4 deletions python/tests/test_swig_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ def test_copy_constructors(pysb_example_presimulation_module):
# `pysb_example_presimulation_module.getModel()`.
"StateIsNonNegative": None,
"SteadyStateComputationMode": [
2,
1,
amici.SteadyStateComputationMode.integrationOnly,
amici.SteadyStateComputationMode.integrateIfNewtonFails,
],
"SteadyStateSensitivityMode": [
2,
1,
amici.SteadyStateSensitivityMode.integrationOnly,
amici.SteadyStateSensitivityMode.integrateIfNewtonFails,
],
("t0", "setT0"): [
0.0,
Expand Down

0 comments on commit e47ef3c

Please sign in to comment.