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
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
_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 -- ...
- Ngôn ngữ chính
- Python
- Star
- 25
- Fork
- 25
- Merge trung bình
- 4 giờ 5 phút
- Pull request đã merge (30 ngày)
- 10
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của lanl/PyBNF
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug tech debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug silent-incorrectness
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
software-mansion-labs/Diplomat#20 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaCó thể đã có người làm @lijy91 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
libnativeapi/nativeapi#53 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
View Counts discarded due to field name mismatchCó thể đã có người làm @rsiva0400 đã nhận hôm nay. Đang mởsite-bug triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Model version publishes the new UK firm entity as a personCó thể đã có người làm @vahid-ahmadi đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
PolicyEngine/policyengine.py#764 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
spcl/HPCAgent-Bench#264 ·
Maintainer thường phản hồi trong vòng 1 ngày