Skip to content

Commit c4780f3

Browse files
committed
Changelog for 0.2.0
1 parent d3595dd commit c4780f3

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# TSPF - CHANGELOG
22

33
## Version 0.2.0
4+
- Parse HCP files
5+
- Iterator for node coordinates, display coordinates, fixed edges and edge weights
46

57
## Version 0.1.1
8+
- Getters for several fields in struct Tsp
69

710
## Version 0.1.0
811
Initial release

README.md

+74-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,82 @@
11
# Tspf
22

3+
[![Crates.io](https://img.shields.io/crates/v/tspf)](https://crates.io/crates/tspf) [![Documentation](https://docs.rs/tspf/badge.svg)](https://docs.rs/tspf) [![Build](https://github.com/1crcbl/tspf-rs/actions/workflows/main.yml/badge.svg)](https://github.com/1crcbl/tspf-rs/actions/workflows/main.yml)
4+
35
Tspf is a small library for reading the TSPLIB file format. TSPLIB is a text-based file format often used in the research field of travelling salesman problem, vehicle routing problem and related problems. Some well-known TSP solvers (e.g. [Concorde](http://www.math.uwaterloo.ca/tsp/concorde/index.html) or [LKH](http://webhotel4.ruc.dk/~keld/research/LKH/)) work mainly with this file format as inputs. The department of Discrete and Combinatorial Optimization at Ruprecht-Karls-Universität Heidelberg maintains a detailed [documentation](http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/) for TSPLIB format.
46

7+
## What's new?
8+
The version ```0.2.0``` has the following new features:
9+
- Parse HCP files
10+
- Iterator for node coordinates, display coordinates, fixed edges and edge weights
11+
512
## Status
6-
Currently I'm focusing on implementing an LKH solver (also in Rust). Thus, many features of the parser are still missing, but will be gradually added.
13+
At the moment I'm focusing on implementing an LKH solver (also in Rust). Thus, many features of the parser are still missing, but will be gradually added.
14+
15+
The library can currently parse the following problems from TSPLIB:
16+
:ballot_box_with_check: TSP - symmetric travelling salesman problem
17+
:ballot_box_with_check: HCP - Hamiltonian cycle problem
18+
:black_square_button: ATSP - asymmetric travelling salesman problem
19+
:black_square_button: SOP - sequential ordering problem
20+
:black_square_button: CVRP - capacitated vehicle routing problem
21+
:black_square_button: Tour - a collection of tours
22+
23+
**NOTES**:
24+
- The files ```si175.tsp```, ```si535.tsp```, ```si1032.tsp``` from the TSP dataset require a small change: the type entry in the second line ```TYPE: TSP (M.~Hofmeister)``` is wrong according to the format definition. Instead, that line should simply be ```TYPE: TSP```.
25+
- For the HCP dataset, the file ```alb4000.hcp``` has a wrong entry in line ```8005```. The line should reads ```FIXED_EDGES_SECTION```, instead ```FIXED_EDGES```.
26+
27+
## Examples
28+
To parse an input string, we use the function ```parse_str``` from the struct ```TspBuilder```:
29+
```rust
30+
use tspf;
31+
32+
let input_str = "
33+
NAME: test
34+
TYPE: TSP
35+
COMMENT: Test
36+
DIMENSION: 3
37+
EDGE_WEIGHT_TYPE: GEO
38+
DISPLAY_DATA_TYPE: COORD_DISPLAY
39+
NODE_COORD_SECTION
40+
1 38.24 20.42
41+
2 39.57 26.15
42+
3 40.56 25.32
43+
EOF
44+
";
45+
46+
match tspf::TspBuilder::parse_str(input_str) {
47+
Ok(tsp) => {
48+
// Iterates over the node coordinates.
49+
for node in tsp.node_coords_itr() {
50+
println!("{:?}", node);
51+
}
52+
}
53+
Err(e) => {
54+
eprintln!("{}", e)
55+
}
56+
}
57+
```
58+
59+
On the other hand, the function ```parse_path``` handles the parsing from file.
60+
```rust
61+
use std::path::Path;
62+
use tspf;
63+
64+
// The problem file can be downloaded from TSPLIB website.
65+
// See: http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/tsp/
66+
let path = Path::new("path/to/bays29.tsp");
67+
68+
match tspf::TspBuilder::parse_path(path) {
69+
Ok(tsp) => {
70+
// Iterates over the edge weights matrix.
71+
for v in tsp.edge_weights_itr() {
72+
println!("{:?}", v);
73+
}
74+
}
75+
Err(e) => {
76+
eprintln!("{}", e)
77+
}
78+
}
79+
```
780

881
## License
982

0 commit comments

Comments
 (0)