A network-free simulate() with t_start above 0 labels its rows t_start…t_end on the bngsim backend but 0…(t_end − t_start) on BNG2.pl, so the same data are scored against different simulated times on the two backends and nothing warns
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with _nf_simulate_action in pybnf/bngsim_model/nf_model.py, where the bridge labels rows in absolute time, then the BNG2.pl path where pybnf/pset.py reads the .gdat as written, and _sim_row_for in pybnf/objective.py, which matches rows by time. Decide which clock is correct, then either refuse network-free simulate with t_start above 0 in the load-time checks in grid.py, or shift the BNG2.pl rows by t_start. Done means the reproduction in the issue gives the same objective on bngsim, bionetgen and auto.
索引モデルが issue の本文から書いたものです。
説明
BngsimNfModel._nf_simulate_action (pybnf/bngsim_model/nf_model.py:427-499) reads t_start (nf_model.py:442) and calls sess.nfsim.simulate(t_start, t_end, n_steps + 1) (nf_model.py:498). The rows are labelled with absolute model time: t_start=>5,t_end=>10,n_steps=>5 gives rows at t = 5, 6, …, 10. BNG2.pl runs the same action through simulate_nf (BioNetGen 2.9.3, Perl2/BNGAction.pm:889-928). It starts NFsim with -sim (t_end - t_start), and NFsim writes its .gdat from 0, so the same action gives rows at t = 0, 1, …, 5. BNG2.pl knows this and prints WARNING: simulate_nf(): NFsim timepoints are reported as time elapsed since t_start=5. (BNGAction.pm:901-904). PyBNF writes that warning only to each simulation's BNG2.pl log, not to the console or to bnf_*.log.
Neither side translates between the two clocks:
- PyBNF's BNG2.pl path reads the
.gdatas written (pybnf/pset.py:1391-1392). - The objective pairs each data row with the simulation row that has the same time (
_sim_row_for,pybnf/objective.py:591-629). The match is exact withind_var_rounding = 0(objective.py:613-616) and nearest-row with1. - Nothing refuses the action at load.
bng2pl_network_free_refusals(pybnf/bngsim_model/grid.py:274) andcheck_output_grids(grid.py:330) both accept it, and the classifier sends it to the bridge under the defaultbngl_backend = auto.
The data matching assumes that the simulator labels its rows on the data's own clock. Every other path labels with absolute model time:
- BNG2.pl's own ODE
simulate, which passes-i t_startto run_network (BNGAction.pm:480-481). The same action withmethod=>"ode"writes rows at 5…10. - The
.netbridge. - Every action that edition 2 writes. These always say
t_start=>0(pset.py:1525).
So data written in absolute time are scored correctly on the bridge and against the wrong rows on BNG2.pl. Data copied from a BNG2.pl network-free .gdat are scored correctly on BNG2.pl and wrongly on the bridge. A fit can be right on only one backend. The documentation says the two backends write the same rows for every action except the sample_times case of #872 (docs/config_keys.rst:830-835; the module docstring of grid.py). That is not true for this action.
The mismatch is silent whenever the two label sets overlap, that is, when t_end − t_start ≥ t_start. A data time between t_start and t_end − t_start is then present in both outputs, so neither backend raises "not in the simulation output".
Failure scenario
An edition-1 network-free model records a time course from t = 5 to t = 15 (simulate({method=>"nf",t_start=>5,t_end=>15,n_steps=>10,...})). The data are at t = 5, 6, …, 10. On the default backend each datum is compared with the simulation at the same absolute time. On bngl_backend = bionetgen, the datum at t = 5 is compared with the state 5 time units after the start, which is absolute t = 10, and so on for every point. Both fits finish normally. At the same parameter values the objectives differ by a factor of more than 1000, and neither run prints a warning.
Reproduction
PyBNF v1.8.1 on main at dd4c6a3a, bngsim 0.16.0, BioNetGen 2.9.3.
The rows. nfdecay.bngl:
begin model
begin parameters
A0 1000
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
simulate({method=>"nf",t_start=>5,t_end=>10,n_steps=>5,suffix=>"tc",seed=>1})
end actions
perl $BNGPATH/BNG2.pl nfdecay.bngl writes nfdecay_tc.gdat with rows labelled 0, 1, 2, 3, 4, 5 (Atot 1000, 929, 847, 761, 687, 609). It also logs the "time elapsed since t_start=5" warning. The bngsim network-free bridge runs the same action, built as pybnf/algorithms/base.py:782-792 builds it, and labels its rows 5, 6, 7, 8, 9, 10 (Atot 1000, 895, 803, 733, 670, 609). With method=>"ode" plus generate_network, BNG2.pl labels its rows 5…10 as well.
The objective. The same model with kdeg kdeg__FREE in place of kdeg 0.1, and with the action
simulate({method=>"nf",t_start=>5,t_end=>15,n_steps=>10,suffix=>"tc"})
tc.exp is the exact decay measured in absolute time, 1000·exp(−0.1·(t − 5)):
# time Atot
5 1000.0
6 904.837
7 818.731
8 740.818
9 670.32
10 606.531
bngsim.conf (edition 1, so the job type defaults to de):
model = nfdecay.bngl : tc.exp
bngl_backend = bngsim
objfunc = sos
uniform_var = kdeg__FREE 0.0999 0.1001
population_size = 2
max_iterations = 1
random_seed = 1
parallel_count = 1
output_dir = out_bngsim
delete_old_files = 0
bionetgen.conf and auto.conf are the same with bngl_backend = bionetgen and bngl_backend = auto. Run pybnf -c on each. All three print Fitting complete and exit 0. The population is raised to 3, so each run has three evaluations at the same three values of kdeg (Results/sorted_params_final.txt):
| kdeg__FREE | bngsim and auto |
bionetgen |
|---|---|---|
| 0.0999341 | 222.58 | 602497.21 |
| 0.1000300 | 490.10 | 550048.13 |
| 0.1000429 | 3379.17 | 631590.68 |
The best-fit .gdat explains the difference. On bngsim the rows run from 5 (Atot 1000) to 15 (347). On BNG2.pl the same trajectory is labelled 0 (1000) to 10 (374). So the datum at t = 5 (1000) is scored against Atot ≈ 615, the value 5 time units after the start. Network-free runs are stochastic, so the counts vary from run to run. The objective gap does not.
Siblings
- A network-free
parameter_scanwitht_startabove 0 is not affected. It records one row per scan point, keyed by the scanned value. - RuleMonkey (
method=>"rm") andsample_timesnetwork-free actions exist only on the bridge, because BNG2.pl refuses them. They have no BNG2.pl rows to disagree with. - The
.netbridge and BNG2.pl's ODE/SSA/PLA paths agree: both label rows in absolute time. - Not checked: a time-dependent rate law on the network-free path. BNG2.pl's NFsim starts its clock at 0, so
time()there runs from 0, while the bridge's session may start its clock at t_start.
Possible fix
Decide which clock is right, and make the other backend agree or refuse:
- refuse a network-free
simulatewitht_startother than 0 (withn_steps) at load, on both backends, naming the action. The user can then shift the data and writet_start=>0; or - shift BNG2.pl's network-free rows by
t_startwhen PyBNF reads them, so that both backends use absolute time, as every other path does.
Either way, the "one difference remains" note in docs/config_keys.rst needs to list this case until it is fixed.
#1005
#1005 (fix/872-sample-times-grid, 44ef34e9) changes only sample_times grids. Rerunning the row reproduction against 44ef34e9 gives the same rows, 5…10, so this case is unchanged.
Related: #872 (the sample_times row difference), #999 (network-free actions BNG2.pl refuses).
- 主要言語
- Python
- スター
- 25
- フォーク
- 25
- 平均マージ
- 4時間 5分
- マージ済み PR(30日)
- 10
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
software-mansion-labs/Diplomat#20 ·
メンテナーはふだん 1 日以内に返信
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client area対応中かも @lijy91 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
libnativeapi/nativeapi#53 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
View Counts discarded due to field name mismatch対応中かも @rsiva0400 が今日担当しました。 オープンsite-bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Model version publishes the new UK firm entity as a person対応中かも @vahid-ahmadi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
PolicyEngine/policyengine.py#764 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
spcl/HPCAgent-Bench#264 ·
メンテナーはふだん 1 日以内に返信