Skip to main content

smart_dynamic_gravity_tsp/
lib.rs

1//! High-performance TSP solver library featuring the Dynamic Gravity algorithm.
2//!
3//! The Dynamic Gravity algorithm is a novel physics-inspired heuristic that simulates
4//! attraction and inertia to find near-optimal solutions for the Traveling Salesman Problem.
5//!
6//! # Example
7//! ```
8//! use smart_dynamic_gravity_tsp::{City, dynamic_gravity_solve};
9//!
10//! let cities = vec![
11//!     City { x: 0.0, y: 0.0 },
12//!     City { x: 1.0, y: 0.0 },
13//!     City { x: 0.0, y: 1.0 },
14//! ];
15//!
16//! let (distance, path) = dynamic_gravity_solve(
17//!     &cities,
18//!     0.9,    // inertia coefficient
19//!     true,   // enable 2-opt optimization
20//!     100,    // 2-opt iterations
21//!     0.3,    // angle penalty weight
22//!     true,   // use angle penalty
23//!     50,     // 2-opt search window
24//! );
25//!
26//! println!("Distance: {:.2}", distance);
27//! ```
28
29pub mod algorithms;
30pub mod core;
31
32pub use algorithms::dynamic_gravity_solve;
33pub use core::City;
34pub use core::distance::{calculate_cycle_distance, compute_dist_matrix};
35
36#[doc(hidden)]
37pub use algorithms::greedy_solve;