Skip to content

fix(npod): keep support points inside the parameter bounds - #332

Open
mhovd wants to merge 1 commit into
mainfrom
claude/pmetrics-pmcore-pharmsol-fixes-qdno6d-npod-bounds
Open

mhovd wants to merge 1 commit into
mainfrom
claude/pmetrics-pmcore-pharmsol-fixes-qdno6d-npod-bounds

Conversation

@mhovd

@mhovd mhovd commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Bug. NPOD's optimizer could move support points outside the parameter box. For example, two_comp_iv with bounds [0.001, 5] ended with k12 = 6.8 and k21 = 34.8.

Fix. Theta::suggest_point now clamps the point to the bounds before the distance check.

Tests.

  • Added a unit test for the clamping.
  • In test_one_compartment_npod, the expected cycle count changes from 11 to 6: on main, a final point had ke = 1.86 with bounds [0.1, 1].
  • That test now also asserts that every support point is within bounds.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GTyUgJEd5uCEmv9qYrv8dC


Generated by Claude Code

NPOD's optimizer could move support points outside the box (e.g. k12 = 6.8
with bounds [0.001, 5]). Theta::suggest_point now clamps the point to the
bounds before the distance check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTyUgJEd5uCEmv9qYrv8dC
Copilot AI balanced review requested due to automatic review settings October 11, 2026 10:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Candidate dimensionality must be validated before zip can silently truncate it.

1 open finding
What changed in this PR

Clamps NPOD support points to parameter bounds before distance checks.

Changes:

  • Clamp proposed support points to valid ranges.
  • Add unit and integration assertions for bounded results.
File Description
src/​estimation/​nonparametric/​theta.rs Implements clamping and unit coverage.
tests/​onecomp.rs Verifies bounded NPOD output and updated cycle count.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +118 to +122
let spp: Vec<f64> = spp
.iter()
.zip(self.parameters.finite_ranges())
.map(|(val, (lower, upper))| val.clamp(lower, upper))
.collect();
@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

ProjectPMcore
Branchclaude/pmetrics-pmcore-pharmsol-fixes-qdno6d-npod-bounds
Testbedmhovd-pgx
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
bimodal_ke_npag📈 view plot
🚷 view threshold
2,911.10 ms
(-33.01%)Baseline: 4,345.58 ms
6,448.85 ms
(45.14%)
bimodal_ke_npod📈 view plot
🚷 view threshold
907.86 ms
(-30.73%)Baseline: 1,310.54 ms
2,051.75 ms
(44.25%)
bimodal_ke_postprob📈 view plot
🚷 view threshold
382.24 ms
(-1.96%)Baseline: 389.89 ms
836.87 ms
(45.68%)
🐰 View full continuous benchmarking report in Bencher

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants