https://github.com/tmtenbrink/relaxheur
https://github.com/tmtenbrink/relaxheur
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tmtenbrink/relaxheur
- Owner: tmtenbrink
- Created: 2023-10-18T16:02:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-24T15:09:11.000Z (over 1 year ago)
- Last Synced: 2025-01-11T05:40:15.854Z (4 months ago)
- Language: Python
- Size: 240 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Download the TSP instances.
Extract them and put them in a folder called `tsp`.
When installed into your environment (for example using Poetry), you can do:
```
tisp
```Alternatively, when using it as a library, you can do:
```python
from tisp import clicli()
```Then run the script. By default it looks for the `gr48` instance.
To run a specific instance, do (the path is interpreted relatively):
```python
from tisp import solve_from_pathsolve_from_path("gr96.dat")
```Or, when you have an instance already loaded, with the costs a simple cost matrix of type `list[list[float]]`:
```python
from tisp import do_branch_and_bound# inst = ... load instance here
do_branch_and_bound(inst)
```It only works for fully connected instances. An example is:
```
3
0 20 5
20 0 3
5 3 0
```"3" is the size of the instance, the rest indicates the cost of edge (i, j), where i is the row and j the column.
Supports Python up to 3.11. Uses mip as the underlying LP solving library. By default it uses included CBC binaries.
### Performance
The main peformance bottleneck is the computation of the min cut to find the constraint to be added to the LP, although for larger instances solving the LP's also takes significant time.
On my 5-year old laptop, `gr48` takes under 10 seconds. Computing it directly as an LP with a solver can take 30-50 seconds. For larger instances, this solver performs even better.