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

Aperta
#1,008 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
Python
Stelle
25
Fork
25
Merge medio
4h 5m
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lanl/PyBNF

Tutte le issue di lanl/PyBNF

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.