Repository navigation
Description
SbmlModel.get_valid_parameters_for_parameter_table(), get_parameter_ids() and get_free_parameter_ids_with_values() exclude rule targets by collecting rule.getVariable() for all rules. Algebraic rules have no variable, so a non-constant parameter that is determined by an algebraic rule is treated like an ordinary model parameter:
- v2
Problem.validate()and v1lint_problemaccept it as an estimated parameter in the parameter table. The equivalent assignment-rule formulation is rejected. The PEtab v2 specification excludes non-truly-constant entities from the parameter table. - The v1 parameter mapping maps it like any other free parameter.
Since the algebraic rule determines the value, the estimate can be expected to have no effect on the simulation.
import libsbml
from petab.v2 import Problem
from petab.v2.models.sbml_model import SbmlModel
for rule_type in ("assignment", "algebraic"):
model = SbmlModel.from_antimony("k = 1; p = 1; species x = 1; x' = -p * x;")
m = model.sbml_model
m.getParameter("p").setConstant(False)
if rule_type == "assignment":
rule = m.createAssignmentRule() # p = 2 * k
rule.setVariable("p")
rule.setMath(libsbml.parseL3Formula("2 * k"))
else:
rule = m.createAlgebraicRule() # 0 = p - 2 * k
rule.setMath(libsbml.parseL3Formula("p - 2 * k"))
problem = Problem()
problem.model = model
problem.add_observable("obs_x", "x", noise_formula="1")
problem.add_experiment("e1", 0, "")
problem.add_measurement("obs_x", experiment_id="e1", time=1, measurement=1)
problem.add_parameter("k", estimate=True, lb=0.1, ub=10, nominal_value=1)
problem.add_parameter("p", estimate=True, lb=0.1, ub=10, nominal_value=1)
print(rule_type, dict(model.get_free_parameter_ids_with_values()))
print(rule_type, [r.message for r in problem.validate() if r.level >= 30])Output on main (9e2d136):
assignment {'k': 1.0}
assignment ["Extraneous parameter(s) in parameter table: {'p'}", "{'p'} is not allowed to occur in the parameters table."]
algebraic {'k': 1.0, 'p': 1.0}
algebraic []
Expected: p is rejected in the parameter table and is not listed as a free model parameter, as in the assignment-rule case. The same holds for petab.v1.lint_problem, which returns no errors for the algebraic variant.
#623 adds v2 checks for rate-rule and event-assignment targets in the parameter table, but notes that variables determined by algebraic rules are not detected yet.
Suggested fix: treat non-constant parameters that occur in an algebraic rule and are not targets of an assignment or rate rule as rule-determined in the SbmlModel methods above. Identifying exactly which variable an algebraic rule determines requires a matching over all algebraic rules. The above heuristic would cover the common case. Relates to #518.
🤖 This issue was generated with AI assistance (Claude Code).
Activity