Skip to content

refactor: extract LpStats cluster from the SolveStats god-object#956

Open
rasros wants to merge 1 commit into
mainfrom
refactor/lp-stats-cluster
Open

refactor: extract LpStats cluster from the SolveStats god-object#956
rasros wants to merge 1 commit into
mainfrom
refactor/lp-stats-cluster

Conversation

@rasros

@rasros rasros commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What changed

SolveStats (and its SolveStatsSink) defined every stat in three places — the immutable snapshot field, the sink accumulator, and the mergedWith merge line — with the 12-field LP cluster dominating that triple maintenance. Group the LP stats into their own LpStats / LpStatsSink pair that owns its snapshot and merge:

  • New result/LpStats.kt: LpStats (immutable, with mergedWith) + LpStatsSink (accumulators + observe* methods + snapshot()).
  • SolveStats holds val lp: LpStats; its mergedWith/snapshot() delegate one line to the cluster instead of twelve.
  • SolveStatsSink holds val lp: LpStatsSink; the LP observe* methods moved onto it (sink.observeLpSolve() becomes sink.lp.observeSolve()), and the shared ZERO_COUNT / NO_MAX / naNDeferring helpers were promoted to package-level so both records use them.
  • Dropped the unused @Serializable annotations (nothing serializes these types).

Readers move stats.lpSolves.sum to stats.lp.solves.sum (~44 sites, mostly tests + CliStats); observe* callers move to sink.lp.* (~17 sites in backtrack/lp).

Why

Adding or changing one LP counter meant four scattered edits in a 515-line file. Now it's one ~60-line cluster where the field, its merge, its accumulator, and its snapshot are colocated — and SolveStats becomes composition + delegation. First cluster of several; search / conflict-analysis / scheduling / local-search can follow the same recipe.

Testing

Behavior-preserving: the emitted -s / %%%mzn-stat key strings (lpSolves, lpPruned, ...) are unchanged — only the in-tree field paths moved. Full check lintDocs green across JVM + native + wasm.

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