Skip to content

TSPTW

All formats · Reader spec · Cases and output

tsptw.iris reads the node count (including the depot), a square travel-time matrix, then each node’s ready and due times. Node 0 is the depot. The spec requires each time window to be ordered and the depot to open at time 0. Data contains n, dist, ready, and due.

The format source is López-Ibáñez and Blum’s TSPTW instance format. The reader spec is copied verbatim from Gecode’s tsptw.cpp.

  • three-nodes has a depot and two customers, with asymmetric travel times and valid windows.
  • reversed-window gives the first customer ready time 8 and due time 2. The reference reports E-CHECK-FAILED at line 6, column 1, with record path [1].

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.

format tsptw
comment "#"
n: 2..1000
dist[n][n]: 0..gecode.int_max / 2 / n
type time = 0..gecode.int_max / 2
repeat n as nodes {
each node
ready: time
due: time
}
check node.ready <= node.due "the time window of a node is invalid"
check nodes[0].ready == 0 "the depot (node 0) must open at time 0"

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.

reversed-window

A customer closes before it opens

3
0 2 4
3 0 2
4 3 0
0 20
8 2
5 12

E-CHECK-FAILED

check failed for record 2 of 'nodes': the time window of a node is invalid

Read rejectedRun from the repository root.
iris read formats/tsptw/tsptw.iris formats/tsptw/cases/reversed-window/input.txt --dzn
formats/tsptw/cases/reversed-window/input.txt:6:1: check failed for record 2 of 'nodes': the time window of a node is invalid
     6 | 8 2
       | ^
spec: formats/tsptw/tsptw.iris:14

Input rejected

Download full case · Open in playground

three-nodes

Depot and two customers with valid time windows

# Hand-made depot and two customers
3
0 2 4
3 0 2
4 3 0
0 20
2 8
5 12
dzn
iris read formats/tsptw/tsptw.iris formats/tsptw/cases/three-nodes/input.txt --dzn
n = 3;
dist = [| 0, 2, 4
  | 3, 0, 2
  | 4, 3, 0 |];
ready = [0, 2, 5];
due = [20, 8, 12];
JSON
iris read formats/tsptw/tsptw.iris formats/tsptw/cases/three-nodes/input.txt --json
{"iris":"0.1","entries":[{"name":"n","type":"int","depth":0,"value":3},{"name":"dist","type":"int","depth":2,"value":[[0,2,4],[3,0,2],[4,3,0]]},{"name":"ready","type":"int","depth":1,"value":[0,2,5]},{"name":"due","type":"int","depth":1,"value":[20,8,12]}]}
Summary
iris read formats/tsptw/tsptw.iris formats/tsptw/cases/three-nodes/input.txt --summary
formats/tsptw/cases/three-nodes/input.txt [tsptw]
  n: int 3
  dist: int array 3 x 3
  ready: int array 3
  due: int array 3

Download full case · Open in playground