Repository navigation
perf(solver): keep Clarke-Wright owner admission incremental - #257
Merged
Merged
Conversation
Every Clarke-Wright merge attempt re-derived the feasible owners of every buffered route against every owner whenever routes outnumbered owners, which is every attempt early in the phase. The working solution does not change during the merge loop, so only the merged route's owners can change. On the stock CVRP profile at 4,000 stops 57% of the phase went to that re-checking, and phase time grew 5-6.5x per doubling of the stop count. The merge loop now keeps its admission state beside the routes: - metric-class route counts, so the fast class check costs O(1) per attempt; - whether each route has any feasible owner, learned once and updated for the merged route, so "more routes than owners" is settled from counts; - each route's owner set once few enough routes remain for a matching to decide, updated for the merged route only. The stock domain = "cvrp" profile now declares savings feasibility shared by metric class (ListVariableMetadata and ListVariableSlot gain savings_feasible_shared_by_metric_class with a builder): its hook reads only the owner's ProblemData, which is what the stock metric class groups by, so one owner per class answers for the class. Per-owner element restrictions stay per owner, and explicit hook paths keep asking every owner. The compiled route bindings fold their five hook-declared flags into two, so the compiled list slot keeps its size and the runner's heap layout. The candidate route is assembled in reused buffers instead of cloning both routes on every attempt. Every accept or reject decision is unchanged. A seeded differential test drives the incremental admission against the whole-set recomputation over 800 random instances; every Clarke-Wright test and the uc-deliveries suite pass. Construction-only runs of all 100 X instances give identical routes (17.4 s -> 2.9 s in total), and synthetic stock-profile instances give identical routes at 1k/2k/4k/8k stops with phase time 0.32/2.0/14.3/102.1 s -> 0.10/0.41/1.8/7.8 s. Closes #254
blackopsrepl
force-pushed
the
perf/clarke-wright-owner-admission
branch
from
November 13, 2026 00:36
bcddb11 to
651894d
Compare
Collaborator
Author
|
Qualifying Every case within budget: wall −0.27%..+1.15%, instructions −0.04%..+0.00%, allocations identical, simulated L1 misses −0.14%..+0.32%, LL misses −0.05%..+0.37%. A first run on |
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.
Closes #254.
Every accept or reject decision of the Clarke-Wright merge loop, and therefore every constructed route, is unchanged; only redundant owner work is removed.
Changes
owner_admission.rs). The merge loop keeps, beside the routes:BTreeMaps over every route;owners + 1routes are live, which is when a matching decides admission. Sets are not kept for the early phase, so memory stays linear in routes instead of routes × owners.The post-loop assignment reuses the kept sets.
ListVariableMetadataandListVariableSlotgainsavings_feasible_shared_by_metric_class(defaultfalse, builderwith_savings_feasible_shared_by_metric_class). Thedomain = "cvrp"macro profile declares it: the stocksavings_feasiblereads only the owner'sProblemData, which is whatsavings_metric_classgroups by, and the profile forbids overriding either hook. Declared, one owner per class answerssavings_feasiblefor the class (merge candidates, singletons, completion seeding).route_owner_allowsstays per owner; explicit hook paths and dynamic slots keep asking every owner.public-api.txt, the solver and macros wireframes anddocs/extend-domain.mdare updated.Verification
admission_oracletest: the incremental admission against the old whole-route-set recomputation (kept in the test as the oracle) on 800 seeded random instances (1-5 owners, 1-3 metric classes, per-owner and per-class feasibility, partial fixed owners); every attempt agrees and the final owner sets match. Planting a bug in the ownerless or matching checks fails it.shared_savings_feasibility_asks_one_owner_per_metric_class: identical routes with fewer than half thesavings_feasiblecalls. Macro test: the cvrp profile emitstrue, explicit hooksfalse.Construction-only Clarke-Wright on all 100 X instances (TSPLIB, fleet from
-k), stock profile: identical routes on every instance; total 17.4 s → 2.9 s.Synthetic stock-profile instances (seeded coordinates, one vehicle per 40 stops), identical routes:
At 4,000 stops owner feasibility is now ~2% of the phase (was ~57%); the rest is savings generation and sorting, which Make the stock CVRP profile able to scale linearly in memory, with no regression #252 bounds.
uc-deliveries test suite against this branch: passes.
make pre-releaseandmake examplespass.Full qualifying
make bench-zero-regressionagainstmain(4910340): posted below when it completes.