Skip to main content

tsp_tour

Function tsp_tour 

Source
pub fn tsp_tour(
    cost: &[f64],
    n: usize,
    start: usize,
    end: Option<usize>,
    closed: bool,
    improve: bool,
) -> Vec<usize>
Expand description

Heuristic travelling-salesman tour over a row-major n x n cost matrix. Builds a nearest-neighbour tour and, when improve, polishes it with an iterated local search: or-opt/swap/2-opt descent restarted from double-bridge perturbations, keeping the best tour found. The tour starts at start; when closed it returns there (and end is ignored), otherwise a fixed end pins the final stop and None leaves it free. Returns the visiting order as indices into the matrix.