concorde_rs

Crates.ioconcorde_rs
lib.rsconcorde_rs
version0.1.1
sourcesrc
created_at2023-10-19 15:41:10.294018
updated_at2023-10-25 14:38:14.545861
descriptionA Rust binding to Concorde TSP Solver
homepage
repositoryhttps://github.com/equalis3r/concorde-rs
max_upload_size
id1007924
size461,637
(equalis3r)

documentation

README

concorde-rs

A Rust binding to Concorde TSP Solver that allows for directly calling the solver instead of communicating the problem via TSP.lib file. At the moment, this package only supports the call to two routines of the Concorde TSP Solver:

  1. Held-Karp: an exact solver based on dynamic programming
  2. Lin-Kernighan: a heuristic solver

Usage

use concorde_rs::{solver, Distance, LowerDistanceMatrix};

fn main() {
    struct Node(i32, i32);

    impl Distance for Node {
        fn calc_shortest_dist(&self, other: &Self) -> u32 {
            self.0.abs_diff(other.0) + self.1.abs_diff(other.1)
        }
    }

    let nodes: Vec<Node> = vec![Node(0, 0), Node(0, 3), Node(5, 6), Node(9, 1)];
    let dist_mat = LowerDistanceMatrix::from(nodes.as_ref());
    let solution = solver::tsp_hk(&dist_mat).unwrap();

    assert_eq!(solution.length, 30);
}

License

The Rust binding code is licensed under MIT license. For the Concorde TSP Solver code, please check Concorde TSP Solver.

Commit count: 5

cargo fmt