Skip to content

Add mrp_generic: generic driver for sequential sampling#639

Draft
DLWoodruff wants to merge 11 commits intoPyomo:mainfrom
DLWoodruff:mrp
Draft

Add mrp_generic: generic driver for sequential sampling#639
DLWoodruff wants to merge 11 commits intoPyomo:mainfrom
DLWoodruff:mrp

Conversation

@DLWoodruff
Copy link
Copy Markdown
Collaborator

@DLWoodruff DLWoodruff commented Mar 25, 2026

Summary

  • Adds mrp_generic.py, a model-agnostic CLI driver for sequential sampling (MRP) confidence intervals, analogous to generic_cylinders.py for decomposition
  • Supports both EF and cylinder-based xhat generation via --xhat-method
  • Supports two-stage and multi-stage problems (auto-detected from --branching-factors)
  • Supports BM and BPL stopping criteria via --stopping-criterion
  • Core logic in mpisppy/generic/mrp.py; entry point in mpisppy/mrp_generic.py
  • Design document in doc/design/mrp_generic_design.rst

Test plan

  • Serial unit tests pass (test_mrp_generic.py: config, xhat generator, do_mrp with BM and BPL)
  • MPI cylinder xhat generator test passes (test_mrp_cylinders.py with mpiexec -np 3)
  • Added to straight_tests.py smoke tests
  • Existing test_conf_int_farmer.py tests still pass (no regressions)
  • Ruff lint clean
  • Run full CI

🤖 Generated with Claude Code

DLWoodruff and others added 2 commits March 25, 2026 10:51
Adds a model-agnostic CLI driver for sequential sampling confidence
intervals, analogous to generic_cylinders for decomposition. Supports
both EF and cylinder-based xhat generation, two-stage and multi-stage
problems, and BM/BPL stopping criteria.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 94.28571% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.93%. Comparing base (8d26d0b) to head (8d3cb21).

Files with missing lines Patch % Lines
mpisppy/mrp_generic.py 93.05% 5 Missing ⚠️
mpisppy/generic/mrp.py 96.00% 4 Missing ⚠️
mpisppy/confidence_intervals/seqsampling.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #639      +/-   ##
==========================================
+ Coverage   70.16%   70.93%   +0.77%     
==========================================
  Files         153      155       +2     
  Lines       18905    19077     +172     
==========================================
+ Hits        13265    13533     +268     
+ Misses       5640     5544      -96     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

DLWoodruff and others added 3 commits March 25, 2026 14:21
Add test_mrp_generic.py to the confidence-intervals CI job and
run_coverage.bash so MRP code is included in coverage reports.
Expand tests with mock-based coverage of _cylinder_xhat_generator,
multistage/cylinders branches in do_mrp, parse_mrp_args, and the
mrp_generic __main__ block.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- The confidence-intervals CI job doesn't install pytest, so run
  test_mrp_generic.py directly (it has unittest.main()).
- Increase max_iterations from 3 to 10 in test_mrp_cylinders.py so
  xhatshuffle has enough iterations to find an inner bound on CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@DLWoodruff DLWoodruff marked this pull request as ready for review April 7, 2026 16:54
@DLWoodruff DLWoodruff marked this pull request as draft April 7, 2026 16:54
@DLWoodruff DLWoodruff marked this pull request as draft April 7, 2026 16:54
DLWoodruff and others added 6 commits April 15, 2026 18:10
The bash example was orphaned: not invoked by any CI job, not included
in run_coverage.bash, and not referenced from the rst docs. Add an
end-to-end invocation step to the confidence-intervals job and a
matching run_phase in run_coverage.bash so flag/path rot gets caught,
and point at the script from doc/src/seqsamp.rst for discoverability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- farmer_mrp_generic.bash now takes an optional solver arg / SOLVERNAME env
  and defaults to xpress, so CI (which lacks a cplex license) can run it.
- parse_mrp_args registers the full set of decomposition args (proper bundles,
  fixer, gapper, tracking, rho groups, etc.) so --xhat-method=cylinders no
  longer crashes on cfg.unpickle_bundles_dir in name_lists.
- run_coverage.bash forwards its SOLVER to farmer_mrp_generic.bash.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The inner-loop xhat step was drawing int(mult*nk) / mult*(nk-nk_m1)
names but advancing self.ScenCount by mk / mk-mk_m1.  When ArRP > 1
and lower_bound_k was not a multiple of ArRP, these diverge, leaving
unused scenario indices between iterations (and, for the reuse branch,
passing a float count that would crash scenario_names_creator).

Draw mk / mk-mk_m1 names so the advance matches the draw.  Also turn
the top-level print("TBD: check seqsampling for start vs start_seed")
into a block comment describing the two-path seed convention (two-stage
uses start=ScenCount; multi-stage uses start_seed / sample_options seed).

Adds a solver-free unit test that exercises ArRP=2 with odd
lower_bound_k values, records every scenario_names_creator call, and
asserts ScenCount == sum(draws) plus pairwise disjointness.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
_cylinder_xhat_generator had rank 0 unlink the bcast'd tmp .npy
immediately after reading it, with no barrier between read and remove.
Faster ranks could finish np.load before the unlink, but slower ones
hit FileNotFoundError (seen on CI MPICH with test_mrp_cylinders).

Add a global Barrier after read so rank 0 can't delete until every
rank has loaded the file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
_cylinder_xhat_generator now issues two barriers (after write, and
after read so rank 0 can't unlink before peers finish); the mocked
test assertion was pinned to one.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant