elkai-rs - a Rust library for solving TSP problems
- based on elkai by fikisipi (LKH by Keld Helsgaun): with proven optimal solutions up to N=315 and more accurate results than Google's OR tools
- asymmetric and symmetric travelling salesman problems support
- clean and simple API: get results with one line calls
[dependencies]
elkai-rs = "0.1.7"
use std::collections::HashMap;
use elkai_rs::Coordinates2D;
fn main() {
let cities = Coordinates2D::new(HashMap::from_iter([
("city1", (0.0, 0.0)),
("city2", (0.0, 4.0)),
("city3", (5.0, 0.0))
]));
println!("{:?}", cities.solve(10));
}
use elkai_rs::DistanceMatrix;
fn main() {
let cities = DistanceMatrix::new(vec![
vec![0, 4, 0],
vec![0, 0, 5],
vec![0, 0, 0]
]);
println!("{:?}", cities.solve(10));
}
The LKH native code by Helsgaun is released for non-commercial use only. Therefore the same restriction applies to elkai-rs, which is explained in the LICENSE
file.
- We link the C api of elkai to Rust with cc-rs.