Description
Generate labeled integer-coordinate cities and their complete symmetric Euclidean distance matrix, plus a randomized depot-return tour and its measured length; coincident cities are allowed and the tour is not claimed optimal.
An optimization instance defines choices, constraints, and an objective. A feasible witness demonstrates that its stated constraints can be met; it establishes optimality only when the tool actually computes and verifies an optimum.
Generate labeled integer-coordinate cities and their complete symmetric Euclidean distance matrix, plus a randomized depot-return tour and its measured length; coincident cities are allowed and the tour is not claimed optimal.
When to use this tool
Use this generator to create reproducible traveling salesman instance cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.
How to use the tool and how it works
- Supply cityCount, minimumCoordinate, maximumCoordinate in the field shapes below. Set seed when you need an explicit replay.
- Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
- Read points, distances, tour, tourLength. Use the conventions below and keep answer-bearing fields separate when presenting an exercise.
Draw labeled integer-coordinate cities, calculate all pairwise Euclidean distances, shuffle non-depot city indexes and add depot zero at both ends. Return the tour and its length from the distance matrix.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| cityCount | City Count | Required. Safe integer; minimum 2; maximum 64. |
| minimumCoordinate | Minimum Coordinate | Required. Safe integer. |
| maximumCoordinate | Maximum Coordinate | Required. Safe integer. |
| seed | Optional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed. | Optional. Safe integer. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| points | Points | Required. Array of Array of Safe integer.; minimum items 2; maximum items 2.; minimum items 2; maximum items 64. |
| distances | Distances | Required. Array of Array of Finite number; minimum 0.; minimum items 2; maximum items 64.; minimum items 2; maximum items 64. |
| tour | Tour | Required. Array of Safe integer; minimum 0; maximum 63.; minimum items 2; maximum items 65. |
| tourLength | Tour Length | Required. Finite number; minimum 0. |
| randomness | Replay metadata: source is seed or context; seed is the normalized 32-bit seed or null for a context source. | Required. Object; no unknown keys. |
| randomness.seed | Optional numeric replay seed; normalization and precedence are explained below. | Required. Safe integer. or Null. |
| randomness.source | Source | Required. Text; one of "context", "seed". |
An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.
{
"input": {
"cityCount": 4,
"minimumCoordinate": -10,
"maximumCoordinate": 10,
"seed": 42
},
"output": {
"points": [
[
2,
-1
],
[
7,
4
],
[
-7,
1
],
[
-5,
3
]
],
"distances": [
[
0,
7.0710678118654755,
9.219544457292889,
8.06225774829855
],
[
7.0710678118654755,
0,
14.317821063276352,
12.041594578792294
],
[
9.219544457292889,
14.317821063276352,
0,
2.8284271247461903
],
[
8.06225774829855,
12.041594578792294,
2.8284271247461903,
0
]
],
"tour": [
0,
2,
1,
3,
0
],
"tourLength": 43.64121784766008,
"randomness": {
"seed": 42,
"source": "seed"
}
}
} Limitations and assumptions
- Coincident labeled cities are allowed. The randomized tour is a benchmark witness, not a shortest-tour result or a real-road route.
- A replay requires the same complete input and implementation. Randomized construction does not guarantee uniform coverage of every feasible output; finite samples can repeat unless a distinct-selection rule is explicitly stated.
- The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.
Alternative or Complementary methods
For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.
References
Similar or alternative tools
- Random Traveling Salesman With Time Windows Instance Generator
Generate integer-coordinate cities, ceiling-Euclidean travel times in abstract time units, fixed customer service times and inclusive windows around a feasible randomized depot-return tour; no optimality or real routing claim.
- Random Interval Scheduling Challenge Generator
Generate synthetic positive-duration half-open jobs and solve the declared count or weight objective exactly with finish-time dynamic programming, retaining one optimum with exclusion on objective ties.