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
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 25
- Forks
- 25
- Avg merge
- 4h 5m
- Merged PRs (30d)
- 10
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lanl/PyBNF
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug minor
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug minor
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug silent-incorrectness
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
software-mansion-labs/Diplomat#20 ·
Maintainers usually reply within 1 day
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaPossibly taken @lijy91 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
libnativeapi/nativeapi#53 · 1 reaction ·
Maintainers usually reply within 1 day
-
View Counts discarded due to field name mismatchPossibly taken @rsiva0400 claimed this today. Opensite-bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Model version publishes the new UK firm entity as a personPossibly taken @vahid-ahmadi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/policyengine.py#764 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
spcl/HPCAgent-Bench#264 ·
Maintainers usually reply within 1 day