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

Abierto
#1,007 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
22/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

  • bifurcate reads parameter the same way: on the .net bridge 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's setParameter lines (#873, route 1) take the .net scan 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 __FREE token, 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.

Lenguaje dominante
Python
Estrellas
25
Forks
25
Merge medio
4 h 5 min
PR fusionados (30 d)
10

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de lanl/PyBNF

Todos los issues de lanl/PyBNF

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.