SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.01854 · 2021

Optimization-Based Algebraic Multigrid Coarsening Using Reinforcement Learning

arXiv · PDF · Open in the Atlas

Code that ran

11 of 11 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, 0 violated it and 11 have no contract verdict; 0 failures of our instrument; 0 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/2106.01854.json · badge: /api/ran/2106.01854.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
compdyn/rl_grid_coarsen canonical (classifier label)
classifier basis: census
11 ran · 0 no recorded run
FunctionStatusWhere it lives
Coloring Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/Lloyd_Unstructured.py
code served (permissive licence) · get_code("8185b20fffe1e7c1")
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 torch.nn as nn

torch.manual_seed(0)

class MockGraph(nn.Module):
    def __init__(self):
        super().__init__()
        self.x = torch.randn(6, 4)
    
graph = MockGraph()

regions = [
    [0, 1],
    [2, 3],
    [4, 5]
]

list_neighbours = [
    [1, 2],
    [0, 3],
    [1, 4],
    [2, 5],
    [3, 5],
    [4]
]

ARGS = {
    "graph": graph,
    "regions": regions,
    "list_neighbours": list_neighbours
}
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 — 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
check_mesh Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/fem.py
code served (permissive licence) · get_code("61a0bd66b46ac92d")
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 bool, 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

# Construct a simple 2D mesh with 3 vertices forming a triangle
# V should be an Nx2 array of vertex coordinates
V = np.array([
    [0.0, 0.0],
    [1.0, 0.0],
    [0.5, 1.0]
], dtype=np.float32)

# E should be an Mx3 array of triangle indices (each row contains 3 vertex indices)
# This single triangle with vertices indexed 0, 1, 2 in counter-clockwise order
E = np.array([
    [0, 1, 2]
], dtype=np.int32)

ARGS = {
    "V": V,
    "E": E
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, 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
cycle Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/Cycle.py
code served (permissive licence) · get_code("10bee4c9c4b2927a")
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 csc_matrix. 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
from scipy import sparse

class Grid:
    def __init__(self, A, fine_nodes, coarse_nodes):
        self.A = A
        self.fine_nodes = fine_nodes
        self.coarse_nodes = coarse_nodes

# Create a small sparse matrix for testing
# Using a 7x7 matrix with 5 fine nodes and 2 coarse nodes
n = 7
lenfpts = 5
lencpts = 2

# Create a simple sparse matrix (symmetric for AMG context)
row = np.array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
                0, 1, 2, 3, 4, 5, 6])
col = np.array([0, 1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6,
                1, 2, 3, 4, 5, 6, 0])
data = np.array([2.0, -0.5, 2.0, -0.5, 2.0, -0.5, 2.0, -0.5, 2.0, -0.5, 2.0, -0.5, 2.0, -0.5,
                 -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5], dtype=float)

A = sparse.csr_matrix((data, (row, col)), shape=(n, n))

# Define fine and coarse node indices
fine_nodes = np.array([0, 1, 2, 3, 4], dtype=np.int64)
coarse_nodes = np.array([5, 6], dtype=np.int64)

# Create the grid object
grid = Grid(A, fine_nodes, coarse_nodes)

ARGS = {
    'grid_': grid
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type csc_matrix — a csc_matrix output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a csc_matrix output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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
diameter Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/fem.py
code served (permissive licence) · get_code("c20f9b6bbfd1f7a4")
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 float64, ndim 0, 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 numpy as np

# Construct valid arguments for the diameter function
# V: nv x 2 array of coordinates (vertices)
# E: ne x 3 array of triangle indices (elements)

# Create a simple mesh with 4 vertices
V = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]])

# Create 2 triangles, each defined by 3 vertex indices
E = np.array([[0, 1, 2], [2, 3, 1]])

ARGS = {
    'V': V,
    'E': E
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
from_networkx Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/Optim.py
code served (permissive licence) · get_code("984e964c5c619025")
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 Data. 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 networkx as nx
import torch_geometric

torch.manual_seed(0)

# Create a simple networkx graph with node and edge features
G = nx.Graph()

# Add nodes with features
G.add_node(0, x=1.0, y=2.0)
G.add_node(1, x=3.0, y=4.0)
G.add_node(2, x=5.0, y=6.0)

# Add edges with features
G.add_edge(0, 1, weight=0.5)
G.add_edge(1, 2, weight=0.7)
G.add_edge(0, 2, weight=0.3)

ARGS = {
    'G': G
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx, torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Data — a Data 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
from_networkx Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/Unstructured.py
code served (permissive licence) · get_code("a86f4b0a23ef9e06")
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 Data. 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 torch_geometric
import networkx as nx

torch.manual_seed(0)

# Create a simple networkx graph with node and edge features
G = nx.Graph()

# Add nodes with feature dictionaries
G.add_node(0, x=1.0, y=2.0)
G.add_node(1, x=3.0, y=4.0)
G.add_node(2, x=5.0, y=6.0)

# Add edges with feature dictionaries
G.add_edge(0, 1, weight=0.5, attr=1)
G.add_edge(1, 2, weight=0.7, attr=2)
G.add_edge(0, 2, weight=0.3, attr=3)

ARGS = {
    'G': G
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx, torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Data — a Data 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
from_scipy_sparse_matrix Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/Optim.py
code served (permissive licence) · get_code("b582e1bdd6e50099")
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 scipy.sparse as sp
import numpy as np

torch.manual_seed(0)

# Create a small scipy sparse matrix in COO format
# 4x3 matrix with a few non-zero entries
row = np.array([0, 1, 2, 3])
col = np.array([0, 1, 2, 0])
data = np.array([1.5, 2.5, 3.5, 4.5], dtype=np.float32)
A = sp.coo_matrix((data, (row, col)), shape=(4, 3))

ARGS = {
    "A": A
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, 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
generate_quadratic Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/fem.py
code served (permissive licence) · get_code("9683a6a8b9c21319")
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 small test data for the function
V = np.array([
    [0.0, 0.0],
    [1.0, 0.0],
    [0.0, 1.0],
    [1.0, 1.0]
], dtype=float)

E = np.array([
    [0, 1, 2],
    [2, 3, 1]
], dtype=int)

ARGS = {
    'V': V,
    'E': E,
    'return_edges': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — 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
hop_neigh Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/Lloyd_Unstructured.py
code served (permissive licence) · get_code("120cd40b07b3a506")
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 list, 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 copy

def hop_neigh(K, region, list_neighbours):
    set_all = set([])
    set_all = set_all.union(set(region))
    prev_set = copy.deepcopy(set_all)
    this_hop = region
    for i in range(K):
        for node in this_hop:
            set_all = set_all.union(set(list_neighbours[node]))
        this_hop = list(set_all.difference(prev_set))
        prev_set = copy.deepcopy(set_all)
    return list(set_all)


# Setup code to construct valid arguments
K = 2
region = [0, 1]
list_neighbours = {
    0: [2, 3],
    1: [3, 4],
    2: [0, 5],
    3: [1, 6],
    4: [1, 7],
    5: [2],
    6: [3],
    7: [4]
}

ARGS = {
    "K": K,
    "region": region,
    "list_neighbours": list_neighbours
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list 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
is_pos_def Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/Solve_MG.py
code served (permissive licence) · get_code("37bb1126cefd3957")
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 ndarray, ndim 1, dtype family float, 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 numpy as np

# The function is_pos_def takes a matrix x and computes its eigenvalues
# It expects a numpy array (or array-like) that can be passed to np.linalg.eigvals

# Create a small positive definite matrix
# A simple way is to create a matrix A and compute A @ A.T, which is always positive semi-definite
# Or use a symmetric matrix with positive eigenvalues

np.random.seed(0)
x = np.array([[4.0, 1.0], [1.0, 3.0]])  # Simple 2x2 positive definite matrix

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, 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
relax_wjacobif Ran
ran on a synthesized input
compdyn/rl_grid_coarsen/Solve_MG.py
code served (permissive licence) · get_code("caf1e3fe849bd5c5")
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 ndarray, ndim 1, dtype family float, 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 numpy as np

torch.manual_seed(0)

# Analyze the function:
# - B: has .dot(u) method, so it's a matrix-like object
# - f: used in subtraction (f - B.dot(u)), so array-like
# - u: used in arithmetic operations, array-like
# - Minv: has .diagonal() method, so matrix-like

# Create small test matrices and vectors
# Let's use numpy arrays which support .dot() and .diagonal()

# B is a matrix that will be dotted with u
# u is a vector
# f is a vector (same shape as result of B.dot(u))
# Minv is a square matrix with a diagonal

B = np.array([[1.0, 0.5], [0.3, 0.8]])  # 2x2 matrix
u = np.array([1.0, 2.0])  # 2-element vector
f = np.array([3.0, 4.0])  # 2-element vector (same shape as B.dot(u))
Minv = np.array([[2.0, 0.0], [0.0, 1.5]])  # 2x2 diagonal matrix

ARGS = {
    "B": B,
    "f": f,
    "u": u,
    "Minv": Minv
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, 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

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 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

Large sparse linear systems of equations are ubiquitous in science and engineering, such as those arising from discretizations of partial differential equations. Algebraic multigrid (AMG) methods are one of the most common methods of solving such linear systems, with an extensive body of underlying mathematical theory. A system of linear equations defines a graph on the set of unknowns and each level of a multigrid solver requires the selection of an appropriate coarse graph along with restriction and interpolation operators that map to and from the coarse representation. The efficiency of the multigrid solver depends critically on this selection and many selection methods have been developed over the years. Recently, it has been demonstrated that it is possible to directly learn the AMG interpolation and restriction operators, given a coarse graph selection. In this paper, we consider the complementary problem of learning to coarsen graphs for a multigrid solver, a necessary step in developing fully learnable AMG methods. We propose a method using a reinforcement learning (RL) agent based on graph neural networks (GNNs), which can learn to perform graph coarsening on small planar training graphs and then be applied to unstructured large planar graphs, assuming bounded node degree. We demonstrate that this method can produce better coarse graphs than existing algorithms, even as the graph size increases and other properties of the graph are varied. We also propose an efficient inference procedure for performing graph coarsening that results in linear time complexity in graph size.

For agents

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

get_harvested_code_for_paper("2106.01854")
get_code_for_paper("2106.01854")
have("2106.01854")

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

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

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

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

Connect an agent — have() is free.