A parameter_scan whose parameter is not in the model is accepted at load and, on the bngsim network-free path, runs every scan point at the model's own value with no message, so a dose-response is fitted to a flat curve
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start at the configuration load path, where parameter_scan, bifurcate, setParameter and the legacy param_scan key are read, and compare each name with the model's parameters block. The silent drop is in _evaluate_bngl_params (pybnf/bngsim_model/expressions.py) on the network-free path, and the swallowed error is at pybnf/bngsim_model/net_model.py:1311-1318. Done means an unmatched name raises a PybnfError at load that names the action and the parameter, and no backend runs the scan silently.
由索引模型根据 Issue 内容生成。
描述
A BNGL parameter_scan that names a parameter the model does not have (a typo, or a parameter renamed in the model but not in the action) is never checked against the model. BNG2.pl stops the action with ABORT: Parameter kdg not defined (BioNetGen 2.9.3, Perl2/BNGAction.pm:1646-1648). PyBNF's backends handle it in three different ways, and none of them refuses it at load.
bngsim network-free bridge (silent). _run_nf_parameter_scan reads the name (pybnf/bngsim_model/nf_model.py:187) and stores each scan value under it in point_inputs (nf_model.py:219). It then rebuilds the overrides with _build_nf_param_overrides (nf_model.py:220). That calls _evaluate_bngl_params (pybnf/bngsim_model/expressions.py:460-495), which returns a value only for the names in the model's parameters block (for name, expr in param_exprs). A name that is not in the block is dropped there, before _apply_param_overrides (nf_model.py:155-171) ever sees it. So nothing is logged at any level. (The debug-level "could not set NF parameter" message at nf_model.py:167-171 is reached only when no parameters block was parsed, and a fit always passes one, pybnf/algorithms/base.py:782-792.) Every point runs at the model's value. The output's first column is still named after the scanned parameter and still holds the scan values (nf_model.py:248), so data whose first column carries the same name match row for row, and the fit scores a flat curve against the dose-response.
bngsim .net bridge (failed simulations). _prepare_scan_point_model calls point_model.set_param(param_name, ...) (pybnf/bngsim_model/net_model.py:1869), and bngsim raises ParameterError: Parameter 'kdg' not found in model. That is not a PybnfError, so the generic handler (pybnf/algorithms/core.py:382-388) turns it into a failed simulation and prints "A simulation failed with an unknown error ... consider reporting this as a bug". Every evaluation fails, and the fit ends with Fitting complete, objective inf, and exit status 0.
bngl_backend = bionetgen. BNG2.pl aborts each simulation. Every job fails, and the run again ends with inf and exit status 0.
The legacy param_scan configuration key (param: field) reaches the same code and fails the same way. AGENTS.md asks that every parameter a configuration names be resolved when the configuration loads, and that a configuration error never become a failed simulation. Here the configuration error is silent on one path and becomes a failed simulation on the other two.
setParameter on a name that is not in the model has the same gap. BNG2.pl aborts with the same message. The network-free bridge stores the value under the unknown name (nf_model.py:339) and drops it in _evaluate_bngl_params with no message. The .net bridge catches the bngsim error and logs setParameter(kdg, 0.0) failed - param not found at WARNING, which goes to the log file only (net_model.py:1311-1318), then continues with the old value.
Failure scenario
A model's degradation constant is renamed from kdg to kdeg. The parameter_scan({parameter=>"kdg",...}) action and the dose-response data (first column kdg) are left as they were. On the default backend the network-free model fits every dose to the same value. The run finishes normally, and neither the console nor the log mentions kdg. The fitted parameters are whatever best explains a flat dose-response.
Reproduction
PyBNF v1.8.1 on main at dd4c6a3a, bngsim 0.16.0, BioNetGen 2.9.3.
scan_nf.bngl:
begin model
begin parameters
A0 A0__FREE
kdeg 0.1
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
parameter_scan({method=>"nf",parameter=>"kdg",par_min=>0.05,par_max=>0.4,n_scan_pts=>4,t_end=>5,n_steps=>5,suffix=>"scan"})
end actions
scan_ode.bngl is the same with generate_network({overwrite=>1}) before the scan and method=>"ode".
scan.exp (what a scan over the decay constant would give, 1000·exp(−5k)):
# kdg Atot
0.05 778.801
0.1666666667 434.598
0.2833333333 242.521
0.4 135.335
nf_bngsim.conf (edition 1, so the job type defaults to de):
model = scan_nf.bngl : scan.exp
bngl_backend = bngsim
objfunc = sos
uniform_var = A0__FREE 999 1001
population_size = 3
max_iterations = 1
random_seed = 1
parallel_count = 1
output_dir = out_nf_bngsim
delete_old_files = 0
Results of pybnf -c (all four exit 0 and print Fitting complete):
| model / backend | what happens | objective |
|---|---|---|
scan_nf.bngl, bngsim (also auto) |
runs; no message on the console or in bnf_*.log |
393545.44 |
scan_nf.bngl, bionetgen |
Job gen0indN failed ×3; ABORT: Parameter kdg not defined in each simulation log |
inf |
scan_ode.bngl, bngsim |
Job gen0indN failed ×3, "A simulation failed with an unknown error" ×3; ParameterError: Parameter 'kdg' not found in model in the log |
inf |
scan_ode.bngl, bionetgen |
Job gen0indN failed ×3; ABORT in each simulation log |
inf |
The network-free bridge's best-fit Results/scan_nf_gen0ind2_scan.scan:
| kdg | 0.05 | 0.1667 | 0.2833 | 0.4 |
|---|---|---|---|---|
| bngsim Atot | 623 | 584 | 598 | 605 |
| a scan over the decay constant | 778.8 | 434.6 | 242.5 | 135.3 |
All four points are about 1000·exp(−0.5) = 606.5, the value at the model's kdeg = 0.1.
The same model without its actions block, with the configuration key param_scan = param:kdg, min:0.05, max:0.4, step:0.11666666666666667, time:5, method:nf, suffix:scan and bngl_backend = bngsim, also runs silently (objective 370080.98, scan rows 604, 577, 582, 587).
setParameter: the actions simulate({method=>"nf",t_end=>5,n_steps=>1,suffix=>"p1"}), setParameter("kdg",0), simulate({method=>"nf",t_end=>5,n_steps=>1,suffix=>"p2"}) (and the same with method=>"ode" after generate_network), with kdeg 0.1 and A0 1000, make BNG2.pl abort for both method=>"nf" and method=>"ode". On the bridge, p2 keeps decaying at kdeg = 0.1: network-free 656 → 404; .net 606.5 → 367.9, with a WARNING in the log only.
Siblings
bifurcatereadsparameterthe same way: on the.netbridge through the same scan code; on the network-free bridge it is skipped entirely (#960). Not run.- A
method=>"protocol"scan and the protocol block'ssetParameterlines (#873, route 1) take the.netscan path. Not run. - Edition-2
experiment:dose-responses were not checked. - #878 is a different trigger with the same symptom: a name that is in the block, defined as a bare
__FREEtoken, loses to the PSet key.
Possible fix
When the configuration loads, resolve the parameter of every parameter_scan / bifurcate, the param: of the param_scan key, and the name in every setParameter, against the model's parameters. Refuse an unmatched name with a PybnfError that names the action and the unmatched name, and lists the closest model parameters. That covers all backends at once. As defence in depth, the bridges should raise rather than drop or log: _evaluate_bngl_params should refuse an override key that matches no parameter, and net_model.py:1311-1318 should not catch the error.
#1005
#1005 (fix/872-sample-times-grid, 44ef34e9) rewrites how the network-free scan reads its grid (scan_output_grid) but not how it applies the parameter. Rerunning both bridge cases against 44ef34e9 gives the same flat scan (network-free) and the same ParameterError (.net).
Related: #878, #873, #960, #941.
- 主要语言
- Python
- 星标
- 25
- 派生
- 25
- 平均合并
- 4 小时 5 分钟
- 30 天内合并 PR
- 10
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
lanl/PyBNF 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug minor
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug tech debt
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
bug minor
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
bug silent-incorrectness
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
相似的 Issue
-
area: ci enhancement perceived difficulty: 1
难度 2/5 1-3 小时 新手友好度 74/100
Nitjsefnie-Harness-Commons/daedalus#1826 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
vllm-project/vllm-sail#398 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
DiamondLightSource/sm-bluesky#476 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
维护者通常 6 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100