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 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lanl/PyBNF のほかの issue

lanl/PyBNF の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。