Repository navigation
perf: rescore only changed list-shadow rows and recreate grouped ruins in one pass - #275
Merged
Merged
Conversation
The zero-regression gate generated candidates only, against an empty constraint set, and no case declared element groups or list shadows, so neither the score director row maintenance of a route model nor the joint recreate of grouped ruin moves was measured. route_rows changes routes of a model with cascading arrival times through the director; group_ruin does, scores and undoes the compiled grouped ruin candidates. On v0.31.0 one grouped ruin move of a 12-vehicle, 20-stop route costs about 200 ms.
…nges With a cascading shadow, every owner change retracted and re-inserted the row of every element the owner held, so one insertion into a route rescored the whole route. The director now records the elements of each notified owner without retracting them, and after the change retracts only elements whose structure shadows do not already describe their new place, arrivals from no list, elements left in no list, and elements whose cascading value changes. The new PlanningSolution::list_structure_unchanged hook answers the structure question from the element's own shadow fields before they are rewritten, so the director keeps no per-element record; #[shadow_variable_updates(cascading_field = ...)] generates it, and the default (false) keeps the previous behaviour for hand-written solutions. route_rows against v0.31.0: 96 ms to 57 ms, allocations 492k to 262k, peak live bytes 107,632 to 96,256, identical scores on all 4,096 changes.
…ixes Grouped ruin recreate searched every remaining unit's joint placements in every round and committed only the best, about k(k+1)/2 searches for k units, and each scored placement inserted and removed every member in two owner changes. Recreate now places the units in one pass in the plan's order, each at its best placement given those before it, the standard ruin-and-recreate order. A placement search keeps the unit's members in the list between trials and moves only the members after the positions consecutive placements share, in one owner change per trial. group_ruin against v0.31.0 (with the row change): 1,361 ms to 107 ms for two passes, allocations 6.58M to 443k.
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.
Grouped ruin-and-recreate on a route model was about 10× slower per move than single-element ruin was on 0.30. The zero-regression gate never ran that code: its cases only generate candidates, against an empty constraint set, and none declares element groups or list shadows. This PR adds cases that execute moves against a scored route model, then removes the two costs those cases expose.
Commits
route_rows: list changes through the score director.group_ruin: the compiled grouped ruin neighborhood; each candidate is done, scored and undone.PlanningSolution::list_structure_unchangedhook answers the structure question from the element's own shadow fields before they are rewritten. The director therefore keeps no per-element record, and peak live bytes go down.false) keeps the old behaviour for hand-written solutions.Measurements against v0.31.0
Gate smoke, shared-source mode, candidate built with
--features candidate:route_rows(2 passes)group_ruin(2 passes)On a real model (pick-up and delivery routing, Milan demo with 155 jobs on 30 shifts, 60 s solves, 3 runs each), only commit 3 applies, because that model does not use cascading shadows yet:
Tests
full_assertsolves) pass.make lintpasses (public API blessed:PlanningSolution::list_structure_unchanged).cargo clippy --workspace --all-targets --all-features -D warningspasses.Zero-regression gate
Qualifying run on
bfd0ef4aagainst v0.31.0, covering all default cases plus the two new ones: passed, with semantics matching on every case.group_ruin: wall −91.0%, instructions −91.2%, allocations −92.5%.route_rows: wall −40.3%, instructions −39.8%, allocations −46.7%, peak live bytes −10.6%.