Skip to content

Unify reduction construction, result recovery, and solver boundaries - #1151

Draft
isPANN wants to merge 10 commits into
mainfrom
refactor/reduction-contracts-clean
Draft

isPANN wants to merge 10 commits into
mainfrom
refactor/reduction-contracts-clean

Conversation

@isPANN

@isPANN isPANN commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

This PR makes an executed reduction responsible for constructing its target and recovering the complete source result. Solvers and CLI workflows use that same recovery path, including when a target optimum establishes source infeasibility.

API and behavior

Before After
Solution extraction, value extraction, and optional completion callbacks carried separate parts of recovery. ReductionResult::recover_result(source, target_result) returns the complete source result.
Witness and aggregate execution could construct the same reduction separately. Each executed step owns one result shared through Rc; shared path prefixes reuse that execution.
A target configuration did not carry a uniform statement of solution quality. SolveOutcome distinguishes Optimal, Feasible, and Infeasible; execution failures remain errors.
Decision bounds and optimization targets could require separate interpretation during completion. Decision targets use Decision<P> where appropriate; rule-owned recovery handles bounds and penalty semantics.
External extraction accepted a raw configuration. pred extract bundle.json --result target-result.json accepts a complete result, validates the target witness, and follows the same recovery path as bundle solving.

For example, a penalty QUBO can have an optimum even when its source ILP is infeasible. The ILP-to-QUBO rule interprets its established energy relation and returns source Infeasible. A merely feasible candidate that cannot establish the source result returns InsufficientSolutionQuality, never a proof of infeasibility.

let reduction = source.reduce_to()?;
let target_result = SolveOutcome::optimal(reduction.target_problem(), target_solution)?;
let source_result = reduction.recover_result(&source, target_result)?;

The solver establishes optimality; SolveOutcome::optimal packages that result and evaluates the witness. Each rule implements its recovery semantics explicitly. There is no default recovery strategy or new cross-rule recovery abstraction.

Supporting changes

  • Keep brute-force candidate aggregation within the brute-force solver, and use registered solver capabilities for dispatch.
  • Store QUBO matrices using sprs, reuse ILP buffers, and use existing petgraph algorithms for applicable graph operations.
  • Validate deserialized models and reconstruct derived state through model construction paths.
  • Correct equal-size pairing recovery in the 3-dimensional-matching-to-3-partition rule.
  • Remove the unused ProblemMetadata trait and point documentation to catalog lookup; narrow internal helper visibility.
  • Migrate callers, examples, documentation, and existing regression cases to the new contract. Preserve the existing test cases, adjusting their API usage.

This is a package-wide API migration. The broad file count includes model/rule callers and their tests. Verifier tooling, local skills, and generated reports are excluded.

Validation

  • make check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • Focused registry, CLI, QUBO recovery, and documentation tests
  • Earlier full coverage run: 97.36% relative to origin/main (before the final metadata cleanup)
  • Earlier MCP tests and paper build passed

Refs #1148.

Normalize filler triples before reconstructing the source matching. Include the reverse-construction proof and noncanonical-witness regressions.
…orage

Keep witness and value mappings on executed reduction results, separate finite brute-force enumeration from model semantics, and make numeric failures explicit. Use native HiGHS execution and sprs-backed QUBO matrices; update registered construction, callers, documentation, and regression tests together.
Reuse the ILP row buffer and combine repeated Steiner extraction scans. Use petgraph union-find, connectivity, and articulation-point implementations in the existing graph checks.
Apply model construction checks to persisted input and reconstruct derived caches from source fields. Preserve public constructor and setter signatures, return deserialization errors for invalid input, and cover creation and loading boundaries with regression tests.
@isPANN
isPANN marked this pull request as draft September 14, 2026 16:54
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.24002% with 236 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.42%. Comparing base (7dd5fcd) to head (e99c577).

Files with missing lines Patch % Lines
...c/models/graph/shortest_weight_constrained_path.rs 81.94% 13 Missing ⚠️
src/models/misc/minimum_weight_and_or_graph.rs 79.31% 12 Missing ⚠️
src/models/graph/undirected_flow_lower_bounds.rs 76.74% 10 Missing ⚠️
...els/graph/hamiltonian_path_between_two_vertices.rs 73.52% 9 Missing ⚠️
src/models/misc/flow_shop_scheduling.rs 72.72% 9 Missing ⚠️
src/models/misc/job_shop_scheduling.rs 79.06% 9 Missing ⚠️
...rc/models/misc/minimum_fault_detection_test_set.rs 81.25% 9 Missing ⚠️
...c/models/misc/precedence_constrained_scheduling.rs 82.00% 9 Missing ⚠️
...dels/graph/directed_two_commodity_integral_flow.rs 87.09% 8 Missing ⚠️
src/models/misc/feasible_register_assignment.rs 83.67% 8 Missing ⚠️
... and 53 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1151      +/-   ##
==========================================
+ Coverage   95.93%   96.42%   +0.49%     
==========================================
  Files        1074     1070       -4     
  Lines      132106   144318   +12212     
==========================================
+ Hits       126730   139160   +12430     
+ Misses       5376     5158     -218     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Reject constraint-violating candidates and feedback-arc incumbents that do not satisfy the recovery premise. Carry complete ILP results through dispatch and evaluate external target results once at the recovery boundary.

Validation: 6,523 workspace tests passed; clippy and formatting passed; changed-line coverage 96.98%.
@isPANN
isPANN marked this pull request as ready for review September 14, 2026 19:43
Use the model constructors for flow create specifications and deserialization. Reject negative internal multipliers and bundle requirements consistently, and test malformed terminals, capacities, bundles, and homologous arc indices through both input paths.

Validation: 6,526 workspace tests passed; clippy and formatting passed. Local PR changed-line coverage against origin/main is 97.54%; changed lines in the three flow models have 100% coverage.
@isPANN
isPANN marked this pull request as draft September 15, 2026 04:01
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