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
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 25
- Forks
- 25
- Avg merge
- 4h 5m
- Merged PRs (30d)
- 10
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lanl/PyBNF
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug minor
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug minor
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug silent-incorrectness
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
Similar issues
-
area: ci enhancement perceived difficulty: 1
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Nitjsefnie-Harness-Commons/daedalus#1826 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
vllm-project/vllm-sail#398 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
DiamondLightSource/sm-bluesky#476 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100