Skip to content

Commit 8139df9

Browse files
authored
v2: Clarify model initialization (#645)
Clarify that the parameter table is applied before initial assignments are executed and change the way how concentration and compartment changes are handled.
1 parent dca155d commit 8139df9

1 file changed

Lines changed: 82 additions & 33 deletions

File tree

doc/v2/documentation_data_format.rst

Lines changed: 82 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ PEtab 2.0.0 is a major update of the PEtab format. The main changes are:
142142
**Figure 3: A comparison of simulations in PEtab v1 and v2.**
143143

144144
* Support for math expressions in the condition table
145-
(:ref:`v2_condition_table`).
145+
(:ref:`v2_condition_table`, :ref:`v2_math_expressions`).
146146
* Clarification and specification of various previously underspecified
147147
aspects, including overriding values via the condition table
148-
(:ref:`v2_math_expressions`).
148+
(:ref:`v2_initialization_semantics`, :ref:`v2_reinitialization_semantics`).
149149
* Support for format :ref:`extensions <petab_extensions>`.
150150
* Observable IDs can now be used in observable and noise formulas
151151
(:ref:`v2_observable_table`).
@@ -296,53 +296,50 @@ Detailed field description
296296
Detailed semantics
297297
~~~~~~~~~~~~~~~~~~
298298

299-
All changes defined in the condition table are applied in five consecutive
300-
phases, following the logic of the event assignments in a single SBML event.
299+
See :ref:`v2_initialization_semantics` for how the changes for the initial
300+
period of an experiment are applied and how the model is initialized.
301+
For any subsequent time period, the changes defined in the condition table
302+
are applied in five consecutive phases:
301303

302304
1. **Evaluation of** ``targetValues``
303305

304306
``targetValues`` are first evaluated using the *current* values of all
305307
variables in the respective expressions.
306-
307-
* For the initial time period of an experiment, *current* values are
308-
determined by the initial conditions defined in the model.
309-
310-
Constructs defining initial values of model entities (e.g., SBML's
311-
*initialAssignments*) are applied only once at the start of the first
312-
time period and are not re-evaluated in later time periods. The start
313-
time of the first time period is defined by the respective experiment.
314-
315-
* For subsequent time periods, the *current* values are taken from the
316-
simulation results at the end of the preceding time period.
317-
A special case is simulation time (``time``),
318-
which is set to the start time of the current time period.
308+
The *current* values are taken from the simulation results at the end of the
309+
preceding time period.
310+
A special case is simulation time (``time``),
311+
which is set to the start time of the current time period.
319312

320313
2. **Assignment of the evaluated** ``targetValues`` **to their targets**
321314

322315
All evaluated ``targetValues`` are simultaneously assigned to their
323316
respective targets. It is invalid to apply multiple assignments to the
324317
same target at the same time.
325318

326-
* These assignments respect language specific interpretations of which
327-
variables are *atomic* or *derived*/*algebraic*. Most notably, SBML
328-
considers species amounts and compartment sizes but not
329-
concentrations to be *atomic*. This means that any entry that has a
330-
``targetId`` that refers to a species with
331-
``hasOnlySubstanceUnits=false`` will have its ``targetValue``
332-
(interpreted as concentration) converted to amounts using the
333-
**current** compartment size and then applied to the target's amount.
334-
For further details, refer to SBML semantic test suite case `01779
335-
<https://github.com/sbmlteam/sbml-test-suite/blob/7ab011efe471877987b5d6dcba8cc19a6ff71254/cases/semantic/01779/01779-model.m>`_.
319+
The interpretation of the assigned value depends on the type of the
320+
model and the target entity.
321+
For example, for an SBML model and a ``targetId`` referring to a species,
322+
the ``targetValue`` will override the current amount of the species
323+
if ``hasOnlySubstanceUnits=true`` (*amount-based species*),
324+
or the current concentration if ``hasOnlySubstanceUnits=false``
325+
(*concentration-based species*).
326+
327+
If the target is a compartment, the compartment size is set to the
328+
evaluated value of the ``targetValue`` expression.
329+
The value of a species in such a compartment is not changed by this
330+
assignment. I.e., for an amount-based species, the amount of the species
331+
will be preserved (the concentration may change accordingly),
332+
and for a concentration-based species, the concentration will be preserved
333+
(the amount may change accordingly).
334+
Mind that this differs from the behavior of an SBML event assignment where
335+
compartment size changes always preserve the amounts of species in that
336+
compartment.
336337

337338
3. **Update of derived variables**
338339

339340
After target values have been assigned, all derived variables (i.e.,
340-
algebraic entities such as SBML assignment rules or PySB expressions) are updated.
341-
342-
* These updates follow language specific rules of which variables are
343-
*atomic* or *derived*/*algebraic*. For example, SBML treats species
344-
concentrations to be *derived*, meaning they are recomputed based on
345-
(updated) species amounts and corresponding compartment sizes.
341+
algebraic entities such as SBML assignment rules or PySB expressions)
342+
are updated.
346343

347344
4. **Events and finalization**
348345

@@ -827,6 +824,8 @@ One row per parameter with arbitrary order of rows and columns:
827824

828825
Additional columns may be added.
829826

827+
See :ref:`v2_initialization_semantics` for details on how and when the values
828+
of parameter table parameters are applied.
830829

831830
Detailed field description
832831
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1117,6 +1116,56 @@ Conditions and observables that are not applied to a model do not need to be
11171116
valid for that model.
11181117

11191118

1119+
.. _v2_initialization_semantics:
1120+
1121+
Initialization and parameter application
1122+
----------------------------------------
1123+
1124+
The following describes how the model is initialized and how other PEtab
1125+
parameter values are applied before the simulation starts.
1126+
This procedure is executed for each model and experiment combination
1127+
defined in the PEtab problem.
1128+
1129+
1. Pre-initialization
1130+
1131+
1. Parameters values for parameters that occur in the parameter table are
1132+
applied to the uninitialized model.
1133+
*Uninitialized* means that no model-internal initial values have been
1134+
computed yet (e.g., in SBML models, no initial assignments have been
1135+
evaluated and no derived initial quantities such as concentrations have
1136+
been computed yet).
1137+
For estimated parameters, the respective externally-provided values
1138+
are applied and for non-estimated parameters, the nominal values
1139+
from the parameter table are applied.
1140+
1141+
2. The time is set to the start time of the first period of the given
1142+
experiment (or 0 if there is no explicit experiment), and any
1143+
experiment-specific conditions provided for the first period are applied
1144+
(see :ref:`v2_reinitialization_semantics` for details).
1145+
Target value expressions for the first period must not refer to model
1146+
entities that are not also listed in the parameter table.
1147+
1148+
This pre-initialization replaces any model-internal initial values
1149+
(or initialization constructs such as SBML's *initialAssignments*)
1150+
that would alter the initial time, the values of the parameters contained
1151+
in the parameter table or any target values from the condition table.
1152+
1153+
2. Model initialization
1154+
1155+
The model is initialized according to the model semantics, e.g., by
1156+
evaluating the initial assignments or applying the initial values of
1157+
state variables.
1158+
1159+
3. Simulation
1160+
1161+
Model simulation starts with evaluating any event triggers at the initial
1162+
time, applying pending event assignments, and evaluating the observables
1163+
at the initial time (Steps 4 and 5 in :ref:`v2_reinitialization_semantics`).
1164+
1165+
For any subsequent experiment periods, the steps described in
1166+
:ref:`v2_reinitialization_semantics` are applied at their start times.
1167+
1168+
11201169
.. _v2_objective_function:
11211170

11221171
Frequentist vs. Bayesian inference

0 commit comments

Comments
 (0)