SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.04915 · 2024

Moco: A Learnable Meta Optimizer for Combinatorial Optimization

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 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; 0 honoured the contract we drafted, 2 violated it and 0 have no contract verdict; 7 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2402.04915.json · badge: /api/ran/2402.04915.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
timd3/moco canonical (classifier label)
classifier basis: census
9 ran · 1 no recorded run
FunctionStatusWhere it lives
action_infeasibility Ran
ran, violated the contract we drafted
timd3/moco/moco/environments.py
code served (permissive licence) · get_code("2ee4d5ac33cd45bc")
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 ArrayImpl, ndim 0, dtype family float, shape () 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 jax.numpy as jnp
import numpy as np

class State:
    def __init__(self, adjacency_matrix, assignment):
        self.adjacency_matrix = adjacency_matrix
        self.assignment = assignment

# Create small test data
# adjacency_matrix: shape (num_actions, num_nodes) - boolean matrix
# assignment: shape (num_nodes,) - boolean array indicating assigned nodes
adjacency_matrix = jnp.array([
    [True, False, True, False],
    [False, True, False, True],
    [True, True, False, False]
], dtype=bool)

assignment = jnp.array([True, False, True, False], dtype=bool)

state = State(adjacency_matrix=adjacency_matrix, assignment=assignment)
action = 0

ARGS = {
    "state": state,
    "action": action
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 0, dtype family float, shape () — shape () 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
batched_two_opt_python Ran
ran; our contract draft was wrong, not the code
timd3/moco/moco/two_opt.py
code served (permissive licence) · get_code("346a796484d63082")
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. The image it ran in was not recorded. If your copy returns the same type 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 numpy as np
import numba as nb
import concurrent.futures
from functools import partial

@nb.njit(nb.float32(nb.float32[:, :], nb.uint16[:], nb.uint16, nb.boolean), nogil=True)
def two_opt_once(distmat, tour, fixed_i=0, first_accept=True):
    """in-place operation"""
    n = tour.shape[0]
    p = q = 0
    delta = 0
    for i in range(1, n - 1) if fixed_i == 0 else range(fixed_i, fixed_i + 1):
        for j in range(i + 1, n):
            node_i, node_j = (tour[i], tour[j])
            node_prev, node_next = (tour[i - 1], tour[(j + 1) % n])
            if node_prev == node_j or node_next == node_i:
                continue
            change = distmat[node_prev, node_j] + distmat[node_i, node_next] - distmat[node_prev, node_i] - distmat[node_j, node_next]
            if change < delta:
                p, q, delta = (i, j, change)
                if first_accept and delta < -1e-06:
                    tour[p:q + 1] = np.flip(tour[p:q + 1])
                    return delta
    if delta < -1e-06:
        tour[p:q + 1] = np.flip(tour[p:q + 1])
        return delta
    else:
        return 0.0

@nb.njit(nb.types.Tuple((nb.uint16[:], nb.float32))(nb.float32[:, :], nb.uint16[:], nb.int64, nb.boolean), nogil=True)
def _two_opt_python(distmat, tour, max_iterations=1000, first_accept=True):
    iterations = 0
    tour = tour.copy()
    cumulative_change = 0.0
    min_change = -1.0
    while min_change < -1e-06 and iterations < max_iterations:
        min_change = two_opt_once(distmat, tour, 0, first_accept=first_accept)
        cumulative_change += min_change
        iterations += 1
    return (tour, cumulative_change)

def batched_two_opt_python(dist: np.ndarray, tours: np.ndarray, max_iterations=1000, first_accept=True):
    dist = dist.astype(np.float32)
    tours = tours.astype(np.uint16)
    with concurrent.futures.ThreadPoolExecutor() as executor:
        futures = []
        for tour in tours:
            future = executor.submit(partial(_two_opt_python, distmat=dist, max_iterations=max_iterations, first_accept=first_accept), tour=tour)
            futures.append(future)
        return (np.stack([f.result()[0] for f in futures]), np.stack([f.result()[1] for f in futures]))

np.random.seed(0)

n_cities = 4
n_tours = 2

dist = np.random.rand(n_cities, n_cities).astype(np.float32)
dist = (dist + dist.T) / 2.0

tours = np.array([[0, 1, 2, 3], [0, 2, 1, 3]], dtype=np.uint16)

ARGS = {
    "dist": dist,
    "tours": tours,
    "max_iterations": 100,
    "first_accept": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numba, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
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
greedy_actor Ran
ran; our contract draft was wrong, not the code
timd3/moco/moco/rl_utils.py
code served (permissive licence) · get_code("23d6bb6df9587d9c")
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 ArrayImpl, ndim 1, dtype family int, shape (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 distrax
import jax
import jax.numpy as jnp

torch.manual_seed(0)

# Create logits tensor - shape (batch_size=2, num_actions=4)
logits = jnp.array([[1.0, 2.0, 3.0, 0.5],
                     [0.5, 1.5, 2.5, 3.5]], dtype=jnp.float32)

# Create a JAX random key
key = jax.random.PRNGKey(0)

ARGS = {
    "logits": logits,
    "key": key
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
distrax, jax, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family int, shape (2,) — shape (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
jax_two_opt_cb Ran
ran; our contract draft was wrong, not the code
timd3/moco/moco/two_opt.py
code served (permissive licence) · get_code("6ac6fa00f37ce1be")
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. The image it ran in was not recorded. If your copy returns the same type 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 numpy as np

# Create a small distance matrix (4x4 for a small TSP problem)
num_cities = 4
np.random.seed(0)
distances = np.random.rand(num_cities, num_cities).astype(np.float32)
# Make it symmetric
distances = (distances + distances.T) / 2
# Zero diagonal
np.fill_diagonal(distances, 0)

# Create a batch of tours (2 feasible tours, 1 infeasible)
# Each tour is a permutation of cities
batch_size = 3
tours = np.array([
    [0, 1, 2, 3],
    [0, 2, 3, 1],
    [0, 1, 2, -1]  # infeasible tour (marked with -1)
], dtype=np.int32)

ARGS = {
    "distances": distances,
    "tours": tours,
    "max_iterations": 100,
    "first_accept": True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numba, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
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
nearest_neighbor Ran
ran, violated the contract we drafted
timd3/moco/moco/tsp_actors.py
code served (permissive licence) · get_code("02ad115e2c22c22b")
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 ArrayImpl, ndim 0, dtype family int, shape () 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 jax
import jax.numpy as jnp
import numpy as np

# Create small coordinates array (5 locations in 2D space)
coordinates = jnp.array([
    [0.0, 0.0],
    [1.0, 1.0],
    [2.0, 0.5],
    [0.5, 2.0],
    [3.0, 3.0]
], dtype=jnp.float32)

# Current position index
position = 0

# Visited mask - marks which nodes have been visited (True = visited, exclude from selection)
visited_mask = jnp.array([True, False, False, False, False], dtype=jnp.bool_)

ARGS = {
    "coordinates": coordinates,
    "position": position,
    "visited_mask": visited_mask
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 0, dtype family int, shape () — shape () 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
plot_tsp_grid Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
timd3/moco/moco/plot_utils.py
code served (permissive licence) · get_code("bfa020fcc852866f")
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. The image it ran in was not recorded. If your copy returns the same type 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 numpy as np
import matplotlib.pyplot as plt

torch.manual_seed(0)

# Create a batch of TSP problems
# coordinates should be a batch of coordinate arrays
# Shape: (batch_size, num_cities, 2) where 2 is for x,y coordinates
batch_size = 2
num_cities = 4

coordinates = np.random.rand(batch_size, num_cities, 2).astype(np.float32)

# Create tours as lists of indices for each problem
# Each tour should visit each city exactly once
tours = [
    [0, 1, 2, 3],
    [0, 2, 1, 3]
]

ARGS = {
    "coordinates": coordinates,
    "tours": tours
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
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
random_actor Ran
ran; our contract draft was wrong, not the code
timd3/moco/moco/rl_utils.py
code served (permissive licence) · get_code("87e63bb80f1e943a")
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 ArrayImpl, ndim 1, dtype family int; 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
import jax
import jax.numpy as jnp
import distrax

torch.manual_seed(0)

# Create logits tensor for the Softmax distribution
# Shape: (batch_size=2, num_classes=4)
logits = jnp.array([
    [1.0, 2.0, 0.5, -1.0],
    [-0.5, 1.5, 2.5, 0.0]
], dtype=jnp.float32)

# Create a JAX random key
key = jax.random.PRNGKey(42)

ARGS = {
    "logits": logits,
    "key": key
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
distrax, jax, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family int — no output shape is stated: observe_signature.py could not observe it (import:ModuleNotFoundError)
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
sample_tsp Ran
ran; our contract draft was wrong, not the code
timd3/moco/moco/data_utils.py
code served (permissive licence) · get_code("94fbd8d077bfb945")
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 ArrayImpl, ndim 2, dtype family float, shape (5, 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 jax
import jax.random

# Create a JAX PRNGKey for the key parameter
key = jax.random.PRNGKey(0)

# Define problem_size
problem_size = 5

# Construct the ARGS dictionary
ARGS = {
    "key": key,
    "problem_size": problem_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 2, dtype family float, shape (5, 2) — shape (5, 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
two_opt_once Ran
ran; our contract draft was wrong, not the code
timd3/moco/moco/two_opt.py
code served (permissive licence) · get_code("d9bb9f73eef30c33")
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 float, ndim 0, dtype family float, shape () 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 numpy as np
import numba as nb

# Create a small distance matrix (4x4)
distmat = np.array([
    [0.0, 1.5, 2.3, 3.1],
    [1.5, 0.0, 1.2, 2.8],
    [2.3, 1.2, 0.0, 1.4],
    [3.1, 2.8, 1.4, 0.0]
], dtype=np.float32)

# Create a tour as a sequence of node indices
tour = np.array([0, 1, 2, 3], dtype=np.uint16)

# Define the arguments dictionary
ARGS = {
    "distmat": distmat,
    "tour": tour,
    "fixed_i": np.uint16(0),
    "first_accept": True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numba, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
load_and_process Not yet run
unverified (harvested, no recorded run)
timd3/moco/moco/data_utils.py
code served (permissive licence) · get_code("36598a73c467f39c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 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 10 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-22.

Repositories linked to this paper

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

Abstract

Relevant combinatorial optimization problems (COPs) are often NP-hard. While they have been tackled mainly via handcrafted heuristics in the past, advances in neural networks have motivated the development of general methods to learn heuristics from data. Many approaches utilize a neural network to directly construct a solution, but are limited in further improving based on already constructed solutions at inference time. Our approach, Moco, defines a lightweight solution construction procedure, guided by a single continuous vector $θ$ (called heatmap) and learns a neural network to update $θ$ for a single instance of a COP at inference time. The update is based on various features of the current search state. The training procedure is budget aware, targeting the overall best solution found during the entire search. Moco is a fully learnable meta optimizer not utilizing problem specific heuristics or requiring optimal solutions for training. We test Moco on the Traveling Salesman Problem (TSP) and Maximum Independent Set (MIS) and show that it significantly improves over other heatmap based methods.

For agents

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

get_harvested_code_for_paper("2402.04915")
get_code_for_paper("2402.04915")
have("2402.04915")

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

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

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

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

Connect an agent — have() is free.