Skip to content

feat(construction): list_k_opt construction with k from 2 to 5 - #189

Merged
blackopsrepl merged 2 commits into
mainfrom
feature/179-construction-k-opt
Nov 5, 2026
Merged

blackopsrepl merged 2 commits into
mainfrom
feature/179-construction-k-opt

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

Closes #179. Base main @ 2ecd40c1, two commits:

  • 161ceb1c feat(list_k_opt): polish routes with k-opt for k from 3 to 5
  • 6ea7773d feat(construction): accept k from 2 to 5 for list_k_opt construction

Tests: exact O(k) deltas checked against recomputed costs for every cut set and pattern on asymmetric distances (k 3..=5); a feasibility-gated route that only a segment move (not a reversal) sorts, at kernel and end-to-end level (tests/list_k_opt_construction.rs, a new domain that scores route distance); compile-time k validation.

Slice 1 alone: clippy, doc-names, file-length, solver rustdoc, solver lib and list CVRP tests: 757 passed, 0 failed. Gate on 6ea7773d (fmt, clippy, doc-names file-length facade-reachability public-api deps, rustdoc, examples, workspace all-feature tests, doctests): EXIT 0, 1537 passed, 0 failed, 66 result lines. Mutation checks: a wrong reversed inner cost fails deltas_are_exact_for_every_cut_set_and_pattern; an executor that always passes k = 2 fails configured_k_reaches_the_list_k_opt_construction_kernel.

While writing the end-to-end test I found that list_cvrp_k_opt_time_window cannot fail; filed as #188.

The route-local list k-opt kernel implemented only 2-opt and skipped
polishing with a warning for any other `k`. For k from 3 to 5 it now scans
every set of k cuts in lexicographic order and every reconnection pattern
of `enumerate_reconnections(k)`, applies the first improving feasible one
and rescans until none is left. Each candidate's distance delta is exact in
O(k), asymmetric distances included, from the boundary edges and forward
and backward prefix sums. k = 2 keeps its exact 2-opt order and trace
identities.
The compiler rejected every construction `k` but 2 ("list k-opt
construction implements only 2-opt"). `list_k_opt` construction now
accepts k from 2 to 5 and polishes each route with that k; values outside
that range are rejected with the key path. Other heuristics do not use `k`
and still reject any value but the default 2, now with a message saying
so.

Closes #179.
@blackopsrepl
blackopsrepl merged commit 6ea7773 into main Nov 5, 2026
12 checks passed
@blackopsrepl
blackopsrepl deleted the feature/179-construction-k-opt branch November 5, 2026 00:43
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.

Construction k: only 2-opt implemented; k > 2 rejected or skipped

1 participant