Skip to content

ExperimentsToSbmlConverter: add keep_target, encode fewer changes - #644

Draft
dweindl wants to merge 3 commits into
PEtab-dev:mainfrom
dweindl:condition_parameters_keep_target
Draft

dweindl wants to merge 3 commits into
PEtab-dev:mainfrom
dweindl:condition_parameters_keep_target

Conversation

@dweindl

@dweindl dweindl commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #579 and #645. #579 keeps numeric changes of unassigned constant parameters and species in the first period in the condition table instead of encoding them in the model. This extends that in two steps (one commit each; meant to be squash-merged, the first commit alone crashes on algebraic rules without math, which the second fixes):

  • Condition parameters regardless of constant. Models often set constant="false" for parameters that nothing in the model changes (e.g., Alkan_SciSignal2018, Fiedler_BMCSystBiol2016, Raia_CancerResearch2011, Weber_BMC2015 in the benchmark collection). Such parameters now qualify as condition parameters if they are not the target of a rule or event assignment and not referenced by an algebraic rule.

  • keep_target. A new optional argument, a predicate on target IDs, through which tools can select further parameters whose changes stay in the condition table, if they can apply them: changes in the pre-equilibration and the first main period, including different values in both periods and values that refer to parameters of the parameter table (as with per-experiment parameter mappings in PEtab v1). A selected target is only kept if this is equivalent to encoding it:

    • nothing in the model or problem assigns it,
    • it is only changed in the pre-equilibration and the first main period, to values that only depend on parameters of the parameter table that the model doesn't change (by rules, events, or initial assignments),
    • no value of a change that stays encoded depends on it, and
    • if its values differ between pre-equilibration and main period, no initial assignment, event trigger, delay argument, or size of a compartment with concentration-based species depends on it.

    Dependencies are followed through assignment rules, algebraic rules, reaction rates, rateOf, and compartment sizes of concentration-based species. The effective values per kept period are written to the condition table (pre-equilibration values persist into the main period). Values equal in both periods go to the shared experiment condition, others to new _petab_preequilibration_condition_<id> / _petab_main_condition_<id> conditions.

In the benchmark collection, this allows keeping the changes of all five problems with pre-equilibration (35 parameters that are otherwise assigned by period-start events) and the 23 changes whose values are problem parameters, as in PEtab v1. The converted problems (models, conditions) are identical to those of a prototype of the same logic implemented in AMICI, for 27 problems in two upgrade variants each. With that prototype, the remaining gradient-evaluation overhead of upgraded v2 problems vs. PEtab v1 in AMICI/pyPESTO went from about 5 % to none (geometric mean over 13 problems).

AMICI will use keep_target for the parameters it can set per experiment and per period; the integration follows in a separate AMICI PR.

🤖 Generated with Claude Code

@dweindl dweindl added enhancement New feature or request v2 Affects petab.v2 / PEtab 2.x conversion Problem converters (petab1to2, ExperimentsToSbmlConverter, ...) labels Nov 30, 2026
@codecov-commenter

codecov-commenter commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.02381% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.73%. Comparing base (9c63651) to head (22c54b6).

Files with missing lines Patch % Lines
petab/v2/converters.py 97.02% 1 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
+ Coverage   80.37%   80.73%   +0.35%     
==========================================
  Files          75       75              
  Lines        8556     8714     +158     
  Branches     1561     1609      +48     
==========================================
+ Hits         6877     7035     +158     
+ Misses       1189     1187       -2     
- Partials      490      492       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dweindl and others added 3 commits November 30, 2026 20:43
…ant`

Models often set `constant="false"` for parameters that nothing in the
model changes (e.g., Alkan_SciSignal2018, Fiedler_BMCSystBiol2016,
Raia_CancerResearch2011, Weber_BMC2015 in the benchmark collection).
Treat such parameters like constant ones: a non-constant parameter
qualifies as condition parameter if it is not the target of any rule or
event assignment, and not referenced by any algebraic rule (which may
determine any non-constant entity it refers to).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Condition parameters only cover numeric changes in the first period.
Tools that can handle more, like v1-style per-experiment parameter
mappings and separate pre-equilibration and main-period values, can now
select further parameters via `keep_target`. Their changes stay in the
condition table if

* nothing in the model or problem assigns the parameter (as for condition
  parameters),
* it is only changed in the pre-equilibration and the first main period,
  to values that only depend on parameters of the parameter table that
  the model doesn't change (by rules, events, or initial assignments),
* no value of a change encoded in the model depends on it, and
* if its value differs between pre-equilibration and main period, no
  initial assignment, event trigger, `delay` argument, or size of a
  compartment with concentration-based species depends on it (where the
  jump of an encoded value would make the result depend on how the tool
  applies the main-period value).

Dependencies are followed through assignment rules, algebraic rules,
reaction rates, `rateOf`, and compartment sizes of concentration-based
species. The check is conservative: it considers changes of all
experiments and periods.

The effective values per kept period are written to the condition table,
i.e., pre-equilibration values persist into the main period. Values equal
in both periods go to the shared experiment condition, others to the new
`_petab_preequilibration_condition_<id>` and `_petab_main_condition_<id>`.

In the benchmark collection, this allows keeping the changes of all five
problems with pre-equilibration (35 parameters that are otherwise
assigned by period-start events) and the 23 changes whose values are
problem parameters, as in PEtab v1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dweindl added a commit to dweindl/libpetab-python that referenced this pull request Nov 30, 2026
…tab-dev#645)

The first main period of an experiment with pre-equilibration is always
kept, so the `not period.condition_ids` check never skipped it. It got a
period-start event and an experiment indicator even if it had no changes
to encode, e.g., if it has no conditions. The same applied to any period
whose conditions have no changes. Now the event is only created, and the
indicator only used, if the period has changes to encode.

Since PEtab-dev#579, this also means that an experiment with pre-equilibration
whose changes are all kept in the condition table as condition
parameters no longer gets an experiment indicator.

Split off from PEtab-dev#644.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@dweindl
dweindl force-pushed the condition_parameters_keep_target branch from 52f7b1d to 22c54b6 Compare November 30, 2026 19:44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conversion Problem converters (petab1to2, ExperimentsToSbmlConverter, ...) enhancement New feature or request v2 Affects petab.v2 / PEtab 2.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants