Skip to content

Commit c7f46b2

Browse files
committed
"simplify" triggers
1 parent 1eafa48 commit c7f46b2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

petab/v2/converters.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,19 @@ def _create_period_start_event(
276276

277277
exp_ind_id = self.get_experiment_indicator(experiment.id)
278278

279+
# Create trigger expressions
280+
# Since handling of == and !=, and distinguishing < and <=
281+
# (and > and >=), is a bit tricky in terms of root-finding,
282+
# we use these slightly more convoluted expressions.
283+
# (assuming that the indicator parameters are {0, 1})
279284
if period.is_preequilibration:
280285
trig_math = libsbml.parseL3Formula(
281-
f"({exp_ind_id} == 1) && ({self._preeq_indicator} == 1)"
286+
f"({exp_ind_id} > 0.5) && ({self._preeq_indicator} > 0.5)"
282287
)
283288
else:
284289
trig_math = libsbml.parseL3Formula(
285-
f"({exp_ind_id} == 1) && ({self._preeq_indicator} != 1) "
290+
f"({exp_ind_id} > 0.5) "
291+
f"&& ({self._preeq_indicator} < 0.5) "
286292
f"&& (time >= {period.time})"
287293
)
288294
check(trigger.setMath(trig_math))

0 commit comments

Comments
 (0)