On the bngsim network-free path, a bifurcate() action is skipped without any message, so the simulations after it start from the seed species instead of the state the bifurcate left

未关闭
#960 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

Start with pybnf/bngsim_model/classification.py:308-313 and pybnf/bngsim_model/nf_model.py:291-360, then compare the bifurcate handling in pybnf/bngsim_model/net_model.py:1002-1011. Reproduce the supplied bifm.bngl and bngsim.conf cases with both backends and inspect existing tests around action classification and bridge execution. Done means unsupported accepted actions are reported or rejected consistently, with coverage for bifurcate and the related catch-all behavior.

由索引模型根据 Issue 内容生成。

描述

bug silent-incorrectness

A network-free BNGL model (method=>"nf") whose actions block runs bifurcate(...) and then a scored simulate(...) is sent to bngsim's network-free simulator under the default bngl_backend = auto, and also under bngl_backend = bngsim. That simulator has no code for bifurcate. It skips the action without printing anything or writing to the log, and runs the rest of the block as if the action were not there. BNG2.pl runs the bifurcate, and the next simulate continues from the state it left. PyBNF should either run the bifurcate or refuse the model when the configuration loads. In the example below, the scored time course starts at 0 molecules instead of about 180, and the objective at the same parameter values is 61358 instead of 1811.

Example

bifm.bngl (birth p, death k, steady state p/k = 200; the bifurcate ends at k = 0.5, its starting value, so it changes only the state):

begin model
begin parameters
  k  0.5
  p  p__FREE
end parameters
begin molecule types
  A()
end molecule types
begin seed species
  A()  0
end seed species
begin observables
  Molecules  A_tot  A()
end observables
begin reaction rules
  0 -> A()  p
  A() -> 0  k
end reaction rules
end model
begin actions
bifurcate({parameter=>"k",par_min=>0.5,par_max=>2,n_scan_pts=>4,method=>"nf",t_end=>20,n_steps=>2,suffix=>"bif"})
simulate({method=>"nf",t_end=>5,n_steps=>5,suffix=>"tc"})
end actions

tc.exp:

# time	A_tot
0	200
1	200
2	200
3	200
4	200
5	200

bngsim.conf (the box on p is narrow only so that every evaluation uses p = 100):

model = bifm.bngl : tc.exp
bngl_backend = bngsim
objfunc = sos
fit_type = de
uniform_var = p__FREE 99.999 100.001
population_size = 4
max_iterations = 1
random_seed = 1
output_dir = out_bngsim
delete_old_files = 0

Run pybnf -c bngsim.conf, then the same conf with bngl_backend = bionetgen (BNG2.pl with NFsim, BioNetGen 2.9.3). For evaluation gen0ind0 (p = 100.001), Simulations/gen0ind0/bifm_gen0ind0_tc.gdat holds:

t 0 1 2 3 4 5 sos
bngsim (auto or bngsim) 0 75 148 166 172 167 61358
BNG2.pl 177 194 205 174 183 184 1811

The best objectives are 58203 (bngsim) and 991 (BNG2.pl). With bngl_backend = auto the run is identical to the bngsim run (objective 58203). On BNG2.pl the bifurcate's last scan point ends at 178 molecules (its _bifurcation_A_tot.scan), close to the steady state p/k = 200, and tc starts from there. On bngsim, tc starts from the seed amount, 0. Neither the console nor the bnf_*.log file mentions the skipped action.

Why

The configuration-time check classifies bifurcate with a network-free method as a network-free simulation action (pybnf/bngsim_model/classification.py:308-313), so the model is accepted for the network-free bridge (pybnf/algorithms/base.py:705). BngsimNfModel.execute (pybnf/bngsim_model/nf_model.py:291-360) handles parameter_scan, simulate, setParameter, setConcentration, addConcentration, saveParameters and resetParameters. Every other line falls through to logger.debug("BngsimNfModel: skipping unsupported action: %s", line) (nf_model.py:359-360) and the loop continues. The .net bridge's loop does handle bifurcate (pybnf/bngsim_model/net_model.py:1002-1011). BNG2.pl runs a bifurcate as a forward and a backward parameter scan with reset_conc forced to 0 (BioNetGen 2.9.3, Perl2/BNGAction.pm:1520-1553), so the model keeps the state of the last scan point, and the next simulate starts from it.

The same catch-all is also reached by a setConcentration whose quoted value contains a space (#877). Any line that reaches it is one the configuration check accepted and the bridge cannot run, so the skip is never correct.

Possible fix

Make the catch-all at nf_model.py:359-360 raise a PybnfError that names the action. Make the classifier treat bifurcate with a network-free method as unsupported by the bridge: auto then falls back to BNG2.pl, and bngsim refuses at load. (The .net bridge has the same debug-level catch-all at net_model.py:1013-1014. As far as I can tell nothing the classifier accepts reaches it today, but raising there too would stop the two from drifting apart.)

Related: #877 (the other action that reaches this skip), #941 and #880 (other places where bngsim and BNG2.pl disagree after a scan)

Found while fixing the PEtab issues #892–#908 (2026-09-25); reproduced on main at 5ecb1f69.

主要语言
Python
星标
25
派生
25
平均合并
4 小时 5 分钟
30 天内合并 PR
10

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

lanl/PyBNF 的其他 Issue

查看 lanl/PyBNF 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。