| Crates.io | aprender-tsp |
| lib.rs | aprender-tsp |
| version | 0.2.0 |
| created_at | 2025-11-29 11:12:02.318366+00 |
| updated_at | 2026-01-12 22:35:31.414946+00 |
| description | Local TSP optimization with personalized .apr models |
| homepage | |
| repository | https://github.com/paiml/aprender |
| max_upload_size | |
| id | 1956588 |
| size | 224,202 |
Local TSP (Traveling Salesman Problem) optimization with personalized .apr models.
.apr binary format# Install
cargo install aprender-tsp
# Train a model
aprender-tsp train instances/berlin52.tsp -o berlin52.apr --algorithm aco
# Solve new instances
aprender-tsp solve -m berlin52.apr instances/new-instance.tsp
# View model info
aprender-tsp info berlin52.apr
# Benchmark against known optimum
aprender-tsp benchmark berlin52.apr --instances instances/berlin52.tsp
| Algorithm | Description | Best For |
|---|---|---|
| ACO | Ant Colony Optimization | General TSP, exploration |
| Tabu | Tabu Search with 2-opt | Local refinement |
| GA | Genetic Algorithm | Large instances |
| Hybrid | GA + Tabu + ACO pipeline | Best quality |
use aprender_tsp::{TspInstance, AcoSolver, TspSolver, Budget};
// Load instance
let instance = TspInstance::from_tsplib("berlin52.tsp")?;
// Solve with ACO
let mut solver = AcoSolver::new()
.with_num_ants(20)
.with_alpha(1.0)
.with_beta(2.5);
let solution = solver.solve(&instance, Budget::iterations(1000))?;
println!("Tour length: {}", solution.length);
println!("Gap from optimal: {:.2}%", solution.optimality_gap(&instance)?);
POC models available on Hugging Face: paiml/aprender-tsp-poc
| Model | Instance | Gap from Optimal |
|---|---|---|
| berlin52-aco.apr | berlin52 | 1.92% |
| att48-aco.apr | att48 | 4.30% |
| eil51-aco.apr | eil51 | 4.07% |
Supports TSPLIB format (.tsp):
NAME: example
TYPE: TSP
DIMENSION: 4
EDGE_WEIGHT_TYPE: EUC_2D
NODE_COORD_SECTION
1 0.0 0.0
2 1.0 0.0
3 1.0 1.0
4 0.0 1.0
EOF
Also supports CSV format with optional header.
.apr files are compact binary models (~77 bytes):
APR\0This crate uses aprender::metaheuristics for core optimization algorithms. See aprender for the full ML library.
MIT