A BNGL simulate() or parameter_scan() with no method runs as an ODE on the bngsim backend, but BNG2.pl refuses it, so the default backend fits a model that bngl_backend = bionetgen cannot run, and neither refuses it at load

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start with bng2pl_network_free_refusals in pybnf/bngsim_model/grid.py (around line 274), then find the get('method', 'ode') defaults in classification.py, grid.py, net_model.py and segment.py. Add a load-time refusal for simulate, parameter_scan and bifurcate that name no method and no poplevel, quoting BNG2.pl's message. Done when the nomethod.bngl reproduction is refused on the default backend, and a model that loads also runs on bngl_backend = bionetgen.

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

描述

BNG2.pl requires method on simulate. With no method it stops with ABORT: simulate() requires 'method' parameter (ode, ssa, pla, psa, nf). (BioNetGen 2.9.3, Perl2/BNGAction.pm:256-257). A parameter_scan calls simulate at each point, so it stops too: Error in parameter_scan (step 1): simulate() requires 'method' parameter.

The bngsim bridge reads a missing method as ode everywhere:

  • the classifier, which decides that bngl_backend = auto takes the .net bridge (pybnf/bngsim_model/classification.py:300, :307, :314 for simulate, parameter_scan, bifurcate);
  • the load-time grid check (pybnf/bngsim_model/grid.py:342 and :184);
  • the run itself (_prepare_simulate_run, pybnf/bngsim_model/net_model.py:1607-1610, and _resolve_scan_settings, net_model.py:2064-2067);
  • the multiple-shooting segment integrator (pybnf/bngsim_model/segment.py:110).

bng2pl_network_free_refusals (grid.py:274) looks only at network-free methods, so an empty method passes it too. The model is therefore accepted at load on every backend. On the bridge it fits as an ODE model. On bngl_backend = bionetgen every simulation aborts, and the fit ends with Fitting complete, objective inf, and exit status 0. That is a configuration error turned into failed simulations.

The bridge is supplying a default for an input whose absence BNG2.pl treats as a mistake. The method decides whether the model is deterministic at all (ode against ssa, psa, nf). So the default backend and bngl_backend = bionetgen disagree about whether the model is valid. Usually the user meant ode, so the impact is low, but the backends should agree.

Failure scenario

A hand-written edition-1 action leaves out method, for example simulate({t_end=>5,n_steps=>5,suffix=>"tc"}). Under the default backend the fit runs and reports a best fit as an ODE model. The same configuration with bngl_backend = bionetgen, or the saved Results/<model>_<best>.bngl run with BNG2.pl, aborts. If the author meant a stochastic method, the default backend has fitted a deterministic model without saying so.

Reproduction

PyBNF v1.8.1 on main at dd4c6a3a, bngsim 0.16.0, BioNetGen 2.9.3.

nomethod.bngl:

begin model
begin parameters
  A0 1000
  kdeg kdeg__FREE
end parameters
begin molecule types
  A()
end molecule types
begin seed species
  A() A0
end seed species
begin observables
  Molecules Atot A()
end observables
begin reaction rules
  A() -> 0 kdeg
end reaction rules
end model
begin actions
generate_network({overwrite=>1})
simulate({t_end=>5,n_steps=>5,suffix=>"tc"})
end actions

tc.exp holds 1000·exp(−0.1 t) at t = 0…5. bngsim.conf (edition 1, so the job type defaults to de):

model = nomethod.bngl : tc.exp
bngl_backend = bngsim
objfunc = sos
uniform_var = kdeg__FREE 0.0999 0.1001
population_size = 3
max_iterations = 1
random_seed = 1
parallel_count = 1
output_dir = out_bngsim
delete_old_files = 0
backend result
bngsim Fitting complete, objective 0.0224; the best-fit tc rows are the ODE solution (1000, 904.81, 818.68, …)
auto the same as bngsim (objective 0.0224)
bionetgen Job gen0ind0/1/2 failed, objective inf, exit 0; ABORT: simulate() requires 'method' parameter (ode, ssa, pla, psa, nf). in each simulation log

perl $BNGPATH/BNG2.pl nomethod.bngl (with kdeg 0.1) exits 1 with the same ABORT. With the action replaced by parameter_scan({parameter=>"kdeg",par_min=>0.1,par_max=>0.4,n_scan_pts=>4,t_end=>5,suffix=>"scan"}), BNG2.pl exits 1 with Error in parameter_scan (step 1): simulate() requires 'method' parameter. The .net bridge runs it as an ODE scan (606.53, 367.88, 223.13, 135.34).

Possible fix

Refuse, at load, a simulate, parameter_scan or bifurcate that names no method (and no poplevel, which BNG2.pl reads as psa). The refusal should name the action and quote BNG2.pl's message, on every backend, so that a model that loads also runs on BNG2.pl. Once that refusal is in place, the get('method', 'ode') defaults listed above are unreachable for hand-written actions. Edition-2 experiments write the method explicitly (pybnf/config.py:1750 defaults the experiment: field to ode, which is documented), so they are unaffected.

#1005

#1005 (fix/872-sample-times-grid, 44ef34e9) does not change this. Rerunning both actions against 44ef34e9 on the .net bridge gives the same ODE rows.

Related: #920 (method spellings that are not recognised as stochastic), #999 (network-free actions BNG2.pl refuses, now refused at load).

主要语言
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 摘要。