starting_params is not checked at load: an out-of-box value leaves am stuck outside the box for the whole run, extra values are dropped, too few crash with IndexError

Aperta
#1,013 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
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, testing

Direzione di ricerca

Start with Configuration._check_starting_params in pybnf/config.py and compare its checks with the existing start_point validation. Read the sampler initialization in pybnf/algorithms/samplers/base.py to understand how values are assigned, then find or add tests for parameter count, bounds, and the continue_run combination. Done means each invalid configuration is rejected at load with an error naming the cause.

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

Descrizione

bug silent-incorrectness

At load, starting_params is checked for only one thing: whether the job_type reads it (Configuration._check_starting_params in pybnf/config.py, added for #559). Its values are never checked, neither their count nor their bounds. The sampler base then copies them into every chain by position (pybnf/algorithms/samplers/base.py, lines 375–378). Three easy mistakes give three different wrong outcomes, and only one of them stops the run.

Every run below uses an analytical objective (objective = expression) with parameters declared kcat [0.5, 50], Km [1, 500], alpha [0.1, 20], and population_size = 2.

1. A value outside its box is accepted, and am then reports a posterior that sits outside the box

job_type = am, max_iterations = 300, starting_params = 69.99 70 3 (kcat is above its upper bound of 50):

exit status 0, no warning
Results/start_point.txt            kcat  69.99  sampled  0.5  50
Results/samples.txt                590 rows; every one is (kcat 69.99, Km 70, alpha 3), Ln_probability -inf
Results/credible68.0_final.txt     kcat  69.99  69.99

Neither chain ever moves. am rejects any proposal that leaves the box (_propose, pybnf/algorithms/samplers/adaptive_mcmc.py; #709). From a start about 20 units outside, essentially every proposal does leave it, so each iteration records the start point again. The run finishes normally, and its histograms and credible intervals describe a single point outside the parameter's own support.

With job_type = mh (step_size = 0.2), the same line is reflected back inside instead. The chain wanders from a point the user did not choose (credible68.0_final.txt: kcat 29.28 to 29.64 after 30 iterations).

start_point refuses the same value at load. Its docs say "A value outside the parameter's declared bounds is refused, not moved." starting_params gets no such check.

The likely way to get here is the one docs/config_keys.rst warns about: pasting a row from samples.txt or sorted_params*.txt. Those files sort their columns by name, while starting_params follows declaration order.

2. Extra values are silently dropped

job_type = am, starting_params = 7 70 3 99 (four values for three parameters):

exit status 0, no warning
Results/start_point.txt   kcat 7   Km 70   alpha 3

The 99 is ignored. A plausible cause is a parameter that was deleted from the conf while its value stayed in the line. Then every value after the deleted parameter's position lands on the wrong parameter.

3. Too few values crash with an error that does not name the cause

job_type = am, starting_params = 7 70:

Sorry, an unknown error occurred: IndexError: list index out of range

4. Also worth deciding: continue_run = 1 together with starting_params

The docs say continue_run = 1 "overrides starting_params entirely", and it does: every chain starts from adaptive_files/MLE_params.txt. But a config that sets both is accepted without a word, so the user gets no sign that the line they wrote did nothing. AGENTS.md asks that a combination like this be refused at load.

Expected

_check_starting_params should refuse at load, with an error that names the cause:

  • a count that differs from the number of free parameters, listing the parameters in declaration order;
  • a value outside its declared box, naming the parameter, its value and its bounds (the same check start_point already gets);
  • probably continue_run = 1 together with starting_params.

Each refusal needs a test.

A separate question is whether am should ever record a sample whose Ln_probability is -inf. A chain that cannot leave its start fails silently however it got there.

Found during the review of #984.

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.