With job_type = ms, an ave_norm_sos (column-mean sigma) objective divides each segment by that segment's own data mean, so the segmented stages fit a differently weighted objective from the one the user asked for

Đang mở
#959 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
numpy, python
Lĩnh vực
backend, data

Hướng nghiên cứu

Start with MultipleShootingProblem._build_objective in pybnf/shooting/problem.py and follow experiment.segment_exp_data through ave_norm_sos in pybnf/objective.py and column_mean in pybnf/noise/source.py. Read _require_series_are_cuttable in pybnf/algorithms/optimizers/multiple_shooting.py and docs/gradient_fitting.rst. Done means segmented scoring matches whole-series scoring, or these settings are clearly rejected, with regression coverage.

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

Mô tả

bug

A multiple-shooting fit (job_type = ms) with objective = ave_norm_sos, or noise_model = gaussian, sigma = column_mean, should divide every residual by the mean of the whole data column. Instead, each segment of the time course is divided by the mean of its own rows. Late segments of a decaying curve have small means, so they get a much larger weight, and the segmented stages of the ladder converge to a different optimum. For one decay experiment the correct fit is k = 0.2900. The 4-segment stage drives k to 0.2542, which makes the real objective 47% worse (0.0893 to 0.1311), and the 2-segment stage takes it to 0.2597. The final unsegmented stage then brings k back to 0.28995, so the reported fit is close to right here. But the segmented stages are how ms chooses a basin, and here they steer away from the answer. The docs say ms refuses "any scored quantity that is a function of a whole series", and it does refuse normalization for this reason, but it accepts a column mean without a message.

Example

decay.bngl:

begin model
begin parameters
  k   0.3
  A0  100
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  k
end reaction rules
end model

tc.exp (70·e^(−0.5t) + 30·e^(−0.1t), which a single exponential cannot fit exactly, so the weighting matters):

# time	Atot
0	100
1	69.6023
2	50.3135
3	37.8437
4	29.5831
5	23.9419
6	19.9494
7	17.0114
8	14.762
9	12.9747
10	11.508

ms.conf:

edition = 2
model: decay.bngl
bngl_backend = bngsim
job_type = ms
objective = ave_norm_sos
experiment: tc, data: tc.exp
uniform_var = k 0.01 3
start_point = k 0.8
population_size = 1
max_iterations = 30
output_dir = out_ms

pybnf -c ms.conf prints stage trace: m=4: 0.0892849 m=2: 0.114791 m=1: 0.0773959. In Results/sorted_params_final.txt, listed in run order, the m = 4 stage's iterates move k from 0.2723 (objective 0.0893) to 0.25415 (0.1311). The m = 2 stage ends at k = 0.25966 (0.1148). The single m = 1 iterate is k = 0.28995 (0.0773959).

The correct numbers come from scipy on the closed form 100·e^(−kt), with PyBNF's factor of 1/2:

objective minimiser k whole-series objective there
each residual divided by the whole column's mean (what was asked for) 0.29001 0.0773958
each of 2 segments divided by its own mean 0.25966 0.1148
each of 4 segments divided by its own mean 0.25415 0.1311

The m = 4 and m = 2 stages land exactly on the minimisers of the per-segment-mean objectives. job_type = gntr with the same conf reaches k = 0.290010 (0.0773958).

The same comparison at a single point: at k = 0.3, with every continuity defect zero (so the segments join into the ordinary trajectory), the m = 2 stage scores 0.278768 and the m = 4 stage 0.385826. The single-shoot score is 0.0807138, and numpy gives the same three numbers. Under objective = sos the three agree to seven digits (100.1575), and ms with objective = sos ends at k = 0.290010, the same minimiser, because sos has no divisor. noise_model = gaussian, sigma = column_mean in place of objective = ave_norm_sos gives the same numbers as ave_norm_sos.

Why

MultipleShootingProblem._build_objective (pybnf/shooting/problem.py:409-437) presents each segment to the objective and to the gradient assembly as its own experiment, with experiment.segment_exp_data(segment) (the segment's rows only, problem.py:181-190) as its data (problem.py:426-428). ave_norm_sos computes its divisor from the data it is handed (pybnf/objective.py:2606), and so does the column_mean sigma source (pybnf/noise/source.py:649), so each segment gets its own mean. _require_series_are_cuttable (pybnf/algorithms/optimizers/multiple_shooting.py:627-670) refuses the other quantities computed over a whole series (normalization, an analytic scale, cumulative columns, constraints) but not a column mean. docs/gradient_fitting.rst:219-223 describes that list as refusing "any scored quantity that is a function of a whole series". Reported scores are not affected: certify (problem.py:554-580) re-scores each whole series, which is why the stage trace and sorted_params_final.txt show genuine single-shoot values.

Possible fix

A column mean depends only on the data, so it can be computed once per experiment from the whole series and used for every segment. The segmented objective at a continuous trajectory would then equal the ordinary one, as it already does for sos. Failing that, refuse ave_norm_sos and any sigma = column_mean in _require_series_are_cuttable, with a test either way.

Related: #913 (the final m = 1 stage stops at a loose tolerance, which limits how much of this the last stage can undo)

Found while fixing the PEtab issues #892–#908 (2026-09-25); reproduced on main at 5ecb1f69.

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.