On the bngsim SBML backend, a free parameter that feeds a chain of parameter initialAssignments (k2 := 2*k1, k3 := k2 + k1) is refused on the gradient path, although bngsim's own column for it is exact
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Start with _seed_terms in pybnf/gradient/routing.py, where a seed map entry of None causes the refusal, and check how it treats parameters that bngsim reports as live derived parameters. The reproduction script in the issue (repro.py with nested.xml) shows the refusal and the exact bngsim column to compare against. Done means route_for_model(['k1']) succeeds for the chain k2 := 2*k1, k3 := k2 + k1 while still refusing when a chain member is not live. The issue depends on the unmerged #991, so check that PR first.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
_seed_terms (pybnf/gradient/routing.py:570 on main, :598 at #991's head 213e28ae) refuses a free parameter whose seed map entry is None. The SBML seed map gives None when a parameter reaches another entity's initial value through a second initialAssignment. So a plain chain of derived parameters is refused: k2 := 2*k1, k3 := k2 + k1, with k1 fitted and the rate laws reading all three.
That refusal is no longer needed on any supported bngsim. bngsim 0.16.0 and bngsim main both report k2 and k3 as live derived parameters (param_is_expression), and k1's own sensitivity column already carries the whole chain: dS(2)/dk1 = −302.805 from bngsim against a central difference of −302.80502. #991 routes on exactly that report: a seed onto a live derived parameter is dropped and the input's own column is used. A chain whose every member is live needs no seed composition at all.
The refusal's message is also wrong for this case. It says "Condition sets 'k1'", but no condition is involved; k1 is a free parameter. The wording is being fixed in #991. This issue is about refusing a configuration that bngsim differentiates correctly.
Failure scenario
job_type = lbfgs (or any gradient job type) with sbml_backend = bngsim, the model below, and k1 free. The run stops at load with GradientNotSupported. A gradient-free job type fits it, and the gradient bngsim would supply is exact.
Expected: route k1 to its own parameter column when bngsim reports every derived parameter on the chain as live, and refuse only when one is not live, or when a member of the chain also seeds a species the backend does not report seeding (effective_ic_sensitivity).
Reproduction
nested.xml:
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
<model id="m">
<listOfCompartments><compartment id="c" size="1" constant="true"/></listOfCompartments>
<listOfSpecies>
<species id="S" compartment="c" initialConcentration="100.0" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
<species id="T" compartment="c" initialConcentration="50.0" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
</listOfSpecies>
<listOfParameters>
<parameter id="k1" value="0.1" constant="true"/>
<parameter id="k2" value="0.0" constant="true"/>
<parameter id="k3" value="0.0" constant="true"/>
</listOfParameters>
<listOfInitialAssignments>
<initialAssignment symbol="k2"><math xmlns="http://www.w3.org/1998/Math/MathML"><apply><times/><cn>2.0</cn><ci>k1</ci></apply></math></initialAssignment>
<initialAssignment symbol="k3"><math xmlns="http://www.w3.org/1998/Math/MathML"><apply><plus/><ci>k2</ci><ci>k1</ci></apply></math></initialAssignment>
</listOfInitialAssignments>
<listOfReactions>
<reaction id="d1" reversible="false" fast="false">
<listOfReactants><speciesReference species="S" stoichiometry="1" constant="true"/></listOfReactants>
<kineticLaw><math xmlns="http://www.w3.org/1998/Math/MathML"><apply><times/><ci>c</ci><ci>k3</ci><ci>S</ci></apply></math></kineticLaw>
</reaction>
<reaction id="d2" reversible="false" fast="false">
<listOfReactants><speciesReference species="T" stoichiometry="1" constant="true"/></listOfReactants>
<kineticLaw><math xmlns="http://www.w3.org/1998/Math/MathML"><apply><divide/><apply><times/><ci>k2</ci><ci>T</ci></apply><apply><plus/><cn>1.0</cn><apply><times/><cn>0.01</cn><ci>T</ci></apply></apply></apply></math></kineticLaw>
</reaction>
<reaction id="d3" reversible="false" fast="false">
<listOfReactants><speciesReference species="T" stoichiometry="1" constant="true"/></listOfReactants>
<listOfProducts><speciesReference species="S" stoichiometry="1" constant="true"/></listOfProducts>
<kineticLaw><math xmlns="http://www.w3.org/1998/Math/MathML"><apply><times/><ci>k1</ci><ci>T</ci></apply></math></kineticLaw>
</reaction>
</listOfReactions>
</model>
</sbml>```
`repro.py` (run as `python repro.py nested.xml`):
```python
"""k1 feeds k2 := 2*k1 and k3 := k2 + k1. bngsim's own k1 column is exact; PyBNF refuses."""
import sys
import numpy as np
import bngsim
import pybnf.bngsim_sbml_model as sb
from pybnf.gradient import route_for_model
from pybnf.pset import FreeParameter, PSet, TimeCourse
path = sys.argv[1] # nested.xml below
def s_at_2(k1, sens=False):
model = bngsim.Model.from_sbml(path)
model.set_param('k1', k1)
kwargs = {'sensitivity_params': ['k1']} if sens else {}
result = bngsim.Simulator(model, method='ode', **kwargs).run(t_span=(0, 2), n_points=3)
if sens:
return np.asarray(result.output_sensitivities(['species:S'], axis='parameter')).ravel()[-1]
return np.asarray(result.species)[-1, list(result.species_names).index('S')]
model = bngsim.Model.from_sbml(path)
live = dict(zip(model.param_names, model.param_is_expression))
print('live derived parameters: k2 %s, k3 %s' % (live['k2'], live['k3']))
h = 1e-6
print('dS(2)/dk1: bngsim column %.8g, central difference %.8g'
% (s_at_2(0.1, sens=True), (s_at_2(0.1 + h) - s_at_2(0.1 - h)) / (2 * h)))
pset = PSet([FreeParameter('k1', 'uniform_var', 1e-6, 1e6, value=0.1)])
pybnf_model = sb.BngsimSbmlModelNoTimeout(path, path, pset=pset,
actions=(TimeCourse({'time': '2', 'step': '1'}),))
try:
route_for_model(pybnf_model, ['k1'])
print('PyBNF routed k1')
except Exception as exc:
print('PyBNF: %s: %s' % (type(exc).__name__, str(exc)[:160]))
Output, identical on bngsim 0.16.0 and bngsim main (c966928), with PyBNF at main (05c16fdb, unchanged in f5ff92bf) and at #991's head (213e28ae):
live derived parameters: k2 True, k3 True
dS(2)/dk1: bngsim column -302.805, central difference -302.80502
PyBNF: GradientNotSupported: Condition sets 'k1', which seeds another entity's initial value through an expression the gradient path cannot differentiate -- ...
- Lenguaje dominante
- Python
- Estrellas
- 25
- Forks
- 25
- Merge medio
- 4 h 5 min
- PR fusionados (30 d)
- 10
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de lanl/PyBNF
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug tech debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
bug minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug silent-incorrectness
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
Todos los issues de lanl/PyBNF
Issues similares
-
Adopt size-ratchet v4.0.3Abiertoarea: ci enhancement perceived difficulty: 1
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Nitjsefnie-Harness-Commons/daedalus#1826 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
vllm-project/vllm-sail#398 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
DiamondLightSource/sm-bluesky#476 ·
Los mantenedores suelen responder en 1 día
-
Quick Installation step 2 installs from the plugin manager, but the plugin isn't published yetAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
Los mantenedores suelen responder en 6 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100