SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.09395 · 2023

H-TSP: Hierarchically Solving the Large-Scale Travelling Salesman Problem

arXiv · PDF · Open in the Atlas

Code that ran

2 of 2 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2304.09395.json · badge: /api/ran/2304.09395.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Learning4Optimization-HUST/H-TSP canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
readDataFile Ran
ran, honoured the contract we drafted
Learning4Optimization-HUST/H-TSP/h_tsp.py
code served (permissive licence) · get_code("f35840a19833ebe0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 2) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import tempfile
import os

torch.manual_seed(0)

# Create a temporary file with TSP data in the expected format
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file_path = temp_file.name

# Write sample data in the format: "x1 y1 x2 y2 ... xn yn o ..."
# The function splits by 'o' and takes the first part
sample_data_1 = "1.0 2.0 3.0 4.0 5.0 6.0 o extra_data"
sample_data_2 = "0.5 1.5 2.5 3.5 4.5 5.5 o more_extra"

temp_file.write(sample_data_1 + '\n')
temp_file.write(sample_data_2 + '\n')
temp_file.close()

ARGS = {
    'filePath': temp_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 2) — shape (2, 3, 2) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
update_buffer Ran
ran; our contract draft was wrong, not the code
Learning4Optimization-HUST/H-TSP/h_tsp.py
code served (permissive licence) · get_code("a429eeaf89951259")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Analyze the function:
# - buffer: needs to support indexing with [:] and indexing with [1]
#   It's used as: buffer[:] = cur_items (assignment)
#                 buffer[1] (access second element)
#   So buffer should be a list that can hold tensors
# 
# - traj_list: used with zip(*traj_list), so it's a sequence of sequences
#   The inner sequences get converted to lists and zipped together
#   Then each item is torch.cat'd on dim=0
#   So traj_list should be a list of tuples/lists of tensors

# Create buffer as a list with placeholder tensors
# buffer[1] is accessed and .mean() is called on it, so it needs to be a tensor
buffer = [
    torch.zeros(0, 4),  # placeholder for buffer[0]
    torch.zeros(0, 4),  # placeholder for buffer[1] - will be replaced
    torch.zeros(0, 4),  # placeholder for buffer[2]
]

# Create traj_list: a list of trajectories
# Each trajectory is a tuple/list of tensors that correspond to buffer elements
# When zipped, they should produce items that can be concatenated
# Create 2 trajectories, each with 3 components matching buffer structure
traj_list = [
    (torch.randn(2, 4), torch.randn(2, 4), torch.randn(2, 4)),  # trajectory 1
    (torch.randn(3, 4), torch.randn(3, 4), torch.randn(3, 4)),  # trajectory 2
]

ARGS = {
    "buffer": buffer,
    "traj_list": traj_list,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 2 samples lifted from this paper's linked repositories, 2 carry a function identity and 0 do not. Of the 2 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

We propose an end-to-end learning framework based on hierarchical reinforcement learning, called H-TSP, for addressing the large-scale Travelling Salesman Problem (TSP). The proposed H-TSP constructs a solution of a TSP instance starting from the scratch relying on two components: the upper-level policy chooses a small subset of nodes (up to 200 in our experiment) from all nodes that are to be traversed, while the lower-level policy takes the chosen nodes as input and outputs a tour connecting them to the existing partial route (initially only containing the depot). After jointly training the upper-level and lower-level policies, our approach can directly generate solutions for the given TSP instances without relying on any time-consuming search procedures. To demonstrate effectiveness of the proposed approach, we have conducted extensive experiments on randomly generated TSP instances with different numbers of nodes. We show that H-TSP can achieve comparable results (gap 3.42% vs. 7.32%) as SOTA search-based approaches, and more importantly, we reduce the time consumption up to two orders of magnitude (3.32s vs. 395.85s). To the best of our knowledge, H-TSP is the first end-to-end deep reinforcement learning approach that can scale to TSP instances of up to 10000 nodes. Although there are still gaps to SOTA results with respect to solution quality, we believe that H-TSP will be useful for practical applications, particularly those that are time-sensitive e.g., on-call routing and ride hailing service.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2304.09395")
get_code_for_paper("2304.09395")
have("2304.09395")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2304.09395.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2304.09395.svg)](https://syntology.ai/paper/2304.09395)

Connect an agent — have() is free.