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

Đang mở
#1,013 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
25
Fork
25
Merge trung bình
4 giờ 5 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của lanl/PyBNF

Tất cả issue của lanl/PyBNF

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.