refactor: extract LpStats cluster from the SolveStats god-object#956
Open
rasros wants to merge 1 commit into
Open
refactor: extract LpStats cluster from the SolveStats god-object#956rasros wants to merge 1 commit into
rasros wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
SolveStats(and itsSolveStatsSink) defined every stat in three places — the immutable snapshot field, the sink accumulator, and themergedWithmerge line — with the 12-field LP cluster dominating that triple maintenance. Group the LP stats into their ownLpStats/LpStatsSinkpair that owns its snapshot and merge:result/LpStats.kt:LpStats(immutable, withmergedWith) +LpStatsSink(accumulators +observe*methods +snapshot()).SolveStatsholdsval lp: LpStats; itsmergedWith/snapshot()delegate one line to the cluster instead of twelve.SolveStatsSinkholdsval lp: LpStatsSink; the LPobserve*methods moved onto it (sink.observeLpSolve()becomessink.lp.observeSolve()), and the sharedZERO_COUNT/NO_MAX/naNDeferringhelpers were promoted to package-level so both records use them.@Serializableannotations (nothing serializes these types).Readers move
stats.lpSolves.sumtostats.lp.solves.sum(~44 sites, mostly tests +CliStats);observe*callers move tosink.lp.*(~17 sites inbacktrack/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
SolveStatsbecomes composition + delegation. First cluster of several; search / conflict-analysis / scheduling / local-search can follow the same recipe.Testing
Behavior-preserving: the emitted
-s/%%%mzn-statkey strings (lpSolves,lpPruned, ...) are unchanged — only the in-tree field paths moved. Fullcheck lintDocsgreen across JVM + native + wasm.