Skip to main content

Crate routik_solver

Crate routik_solver 

Source
Expand description

§routik-solver

Pure VRP core (no I/O) for the capacitated VRP with time windows (CVRPTW). It holds the data model, the CostMatrix abstraction, the Clarke-Wright savings construction, the local-search neighbourhoods, and a simulated- annealing metaheuristic (solve).

The solver depends on the CostMatrix trait only — distances and times come from behind it, never from a baked-in map engine. Implementations are HaversineMatrix (straight-line + a configurable speed) and EuclideanMatrix (planar, unit speed — the Solomon-benchmark convention).

Hard constraints (capacity, time windows) are always respected; solve never returns a worse solution than the construction baseline under the configured Objective, and is deterministic for a given seed.

use routik_solver::{solve, Coord, HaversineMatrix, Problem, SolverConfig, Stop, StopId, Vehicle, VehicleId};

let problem = Problem {
    depot: Coord::new(48.8566, 2.3522),
    stops: vec![Stop {
        id: StopId(1),
        coord: Coord::new(48.8606, 2.3376),
        demand: 10,
        time_window: None,
        service_time: 0.1,
    }],
    vehicles: vec![Vehicle { id: VehicleId(1), capacity: 50 }],
    depot_window: None,
};
let matrix = HaversineMatrix::from_problem(&problem, 50.0);
let solution = solve(&problem, &matrix, &SolverConfig::default()).expect("feasible");
assert!(solution.feasible);

Re-exports§

pub use anneal::Budget;
pub use anneal::SolveStats;
pub use anneal::SolverConfig;
pub use anneal::solve;
pub use anneal::solve_with_stats;
pub use clarke_wright::SolveError;
pub use clarke_wright::clarke_wright;
pub use matrix::CostMatrix;
pub use matrix::EuclideanMatrix;
pub use matrix::HaversineMatrix;
pub use matrix::MatrixError;
pub use matrix::ProvidedMatrix;
pub use model::Coord;
pub use model::LocationId;
pub use model::Problem;
pub use model::Route;
pub use model::Solution;
pub use model::Stop;
pub use model::StopId;
pub use model::TimeWindow;
pub use model::Unassigned;
pub use model::UnassignedCode;
pub use model::Vehicle;
pub use model::VehicleId;
pub use objective::Objective;

Modules§

anneal
Simulated-annealing metaheuristic over the local-search neighbourhoods.
clarke_wright
Clarke-Wright savings construction heuristic.
matrix
Cost matrix abstraction and the Haversine (great-circle) implementation.
model
VRP data model.
objective
The objective function the metaheuristic minimises.