TSPLIB
All formats · Reader spec · Cases and output
tsplib.iris reads explicit edge weights in TSPLIB matrix
layouts and coordinates for EUC_2D, CEIL_2D, ATT, and GEO. The
dimension must precede sections that use it. COMMENT lines are skipped;
the reader accepts only the header keys and sections listed in the spec.
This is a TSP reader, not the complete family of TSPLIB problem formats.
The format source is Gerhard Reinelt’s TSPLIB 95 documentation, particularly the specification and data parts. The reader spec is copied from Gecode’s tsp.cpp.
- explicit-five stores a symmetric 5×5
FULL_MATRIXas theweightentry. - euc-2d-five stores five node IDs and the float
arrays
xandy. Expected data contains coordinates, including1.5; distance construction belongs to the Gecode example’s host code. - missing-weights declares
EXPLICITwithout anEDGE_WEIGHT_SECTION. The reference reportsE-CHECK-FAILEDwith an empty record path.
These are hand-made samples under the repository’s MIT license. See the library README for case layout, validation, and Gecode notices.
Reader spec
From Gecode commit 5e7bbd5c26b0702c6fd652356b2289da0710ac3c. Source notices.
Cases and output
Run the commands from the repository root. Successful reads show dzn, JSON, and a summary. Rejected inputs show the CLI's diagnostic and caret, with the stable error code beside it.
euc-2d-five
Five cities given by two-dimensional coordinates
dzn
iris read formats/tsplib/tsplib.iris formats/tsplib/cases/euc-2d-five/input.txt --dznJSON
iris read formats/tsplib/tsplib.iris formats/tsplib/cases/euc-2d-five/input.txt --jsonSummary
iris read formats/tsplib/tsplib.iris formats/tsplib/cases/euc-2d-five/input.txt --summaryexplicit-five
Five cities with an explicit full distance matrix
dzn
iris read formats/tsplib/tsplib.iris formats/tsplib/cases/explicit-five/input.txt --dznJSON
iris read formats/tsplib/tsplib.iris formats/tsplib/cases/explicit-five/input.txt --jsonSummary
iris read formats/tsplib/tsplib.iris formats/tsplib/cases/explicit-five/input.txt --summarymissing-weights
Explicit distances require an edge weight section
E-CHECK-FAILED
check failed: no EDGE_WEIGHT_SECTION
iris read formats/tsplib/tsplib.iris formats/tsplib/cases/missing-weights/input.txt --dznformats/tsplib/cases/missing-weights/input.txt:5:4: check failed: no EDGE_WEIGHT_SECTION
5 | EOF
| ^
spec: formats/tsplib/tsplib.iris:38
Input rejected