Function travelling_salesman::hill_climbing::solve
source · [−]Expand description
Returns an approximate solution to the Travelling Salesman Problem using Hill Climbing
For more information, please see the metaheuristics::hill_climbing documentation.
Parameters and Return Type
cities
is an array slice, containing (x,y)
tuple coordinates for each city.
runtime
is a time::Duration
, specifying how long to spend searching for a solution.
Returns a travelling_salesman::Tour
struct, representing the approximate solution found.
Examples
extern crate time;
extern crate travelling_salesman;
fn main() {
let tour = travelling_salesman::hill_climbing::solve(
&[
(27.0, 78.0),
(18.0, 24.0),
(48.0, 62.0),
(83.0, 77.0),
(55.0, 56.0),
],
time::Duration::seconds(1),
);
println!("Tour distance: {}, route: {:?}", tour.distance, tour.route);
}