How to add a benchmark problem and instance¶
This guide shows you how to register a benchmark problem in Algorithm Nexus and add a concrete instance of that problem.
A benchmark problem (also called a logical benchmark) is the abstract task you want algorithms or models compared on. A benchmark instance is one concrete realisation of that task — a specific graph, dataset, workload, or other input.
The steps below add a graph-coloring problem and one instance of it. After that walk-through, Alternatives covers artifact files, extra instances, and other property domains.
Prerequisites¶
Work from a local checkout of your Algorithm Nexus fork with the CLI extra installed:
1. Create the problem definition¶
Create the problem folder and write benchmark.yaml. This file names the
problem and declares the instance properties and metrics that every instance —
and later experiment binding — will share.
Create benchmarks/graph_coloring/benchmark.yaml:
benchmarkIdentifier: graph_coloring
title: Graph Coloring
description: >
Evaluates graph-coloring algorithms on their ability to produce valid
k-colorings with a small chromatic number. Instances span random
Erdős–Rényi graphs and structured benchmark graphs at varying densities.
problemProperties:
- identifier: graph_family
metadata:
description: Graph family (erdos_renyi, planar, random_regular).
propertyDomain:
variableType: CATEGORICAL_VARIABLE_TYPE
values: [erdos_renyi, planar, random_regular]
- identifier: num_vertices
metadata:
description: Number of vertices in the graph.
propertyDomain:
variableType: DISCRETE_VARIABLE_TYPE
values: [50, 100, 250, 500]
- identifier: edge_density
metadata:
description: Edge probability / density parameter.
propertyDomain:
variableType: CONTINUOUS_VARIABLE_TYPE
metrics:
- identifier: num_colors_used
- identifier: is_valid_coloring
- identifier: elapsed_ms
ranking:
metric: num_colors_used
order: asc
owner: "@graph-team"
The problemProperties list is the vocabulary for every instance of this problem.
metrics and ranking are the vocabulary for results and leaderboard order.
The full field list is in Logical Benchmarks and Instances.
2. Add an instance¶
Create one instance folder and write instance.yaml. Use the property
identifiers from the problem definition, and give each a concrete value.
Create benchmarks/graph_coloring/instances/erdos_renyi_50_02/instance.yaml:
instanceIdentifier: erdos_renyi_50_02
benchmarkIdentifier: graph_coloring
description: 50-node Erdos-Renyi graph with edge density 0.2
problemPropertyValues:
- property:
identifier: graph_family
value: erdos_renyi
- property:
identifier: num_vertices
value: 50
- property:
identifier: edge_density
value: 0.2
The full field list is in Logical Benchmarks and Instances.
You now have:
benchmarks/graph_coloring/
├── benchmark.yaml
└── instances/
└── erdos_renyi_50_02/
└── instance.yaml
3. Validate¶
A successful run lists the problem folder with status success. The problem and
instance are ready to commit.
4. Open a pull request¶
git add benchmarks/graph_coloring
git commit -s -m "feat(benchmark): Add graph_coloring problem and instance"
git push origin add-graph-coloring-benchmark
Open a pull request from your fork to the Algorithm Nexus main branch.
To register an experiment that evaluates this problem, continue with How to add a benchmark experiment. To bind that experiment to this problem, continue with How to bind an experiment to a benchmark instance. To apply an experiment to this instance, continue with How to add a benchmark submission.
Alternatives¶
Add an instance that includes artifact files¶
To ship input files with an instance (graphs, datasets, prompts), create a
subfolder inside the instance directory that holds those files, then declare
instanceArtifacts in instance.yaml pointing to that subfolder. Artifacts
are defined on the instance itself and do not need to be listed in the
benchmark's problemProperties.
In the instance directory, create the subfolder and the files, then reference it
from instance.yaml:
instanceIdentifier: erdos_renyi_50_02
benchmarkIdentifier: graph_coloring
description: 50-node Erdos-Renyi graph with edge density 0.2
problemPropertyValues:
- property:
identifier: graph_family
value: erdos_renyi
- property:
identifier: num_vertices
value: 50
- property:
identifier: edge_density
value: 0.2
instanceArtifacts:
- property:
identifier: graph
artifactsLocation: graph_files
The instance directory then looks like this:
benchmarks/graph_coloring/instances/erdos_renyi_50_02/
├── instance.yaml
└── graph_files/
├── graph.dimacs
└── graph.json
Cover several values of a property with variants¶
When the files of one instance differ by the value of a problem property (e.g. a
sweep over edge_density), define a single instance with variants instead of
one instance per value. A property that varies is omitted from
problemPropertyValues and given a value in every variant. Each variant
lists the artifact files, in the artifact's artifactsLocation, that belong to
it:
instanceIdentifier: erdos_renyi_50
benchmarkIdentifier: graph_coloring
description: 50-node Erdos-Renyi graphs with different edge densities
problemPropertyValues:
- property:
identifier: graph_family
value: erdos_renyi
- property:
identifier: num_vertices
value: 50
instanceArtifacts:
- property:
identifier: graph
artifactsLocation: graph_files
variants:
- problemPropertyValues:
- property:
identifier: edge_density
value: 0.2
instanceArtifactValues:
- property:
identifier: graph
values:
- graph_02.dimacs
- graph_02.json
- problemPropertyValues:
- property:
identifier: edge_density
value: 0.5
instanceArtifactValues:
- property:
identifier: graph
values:
- graph_05.dimacs
- graph_05.json
The instance directory then looks like this:
benchmarks/graph_coloring/instances/erdos_renyi_50/
├── instance.yaml
└── graph_files/
├── graph_02.dimacs
├── graph_02.json
├── graph_05.dimacs
└── graph_05.json
- Every value a property can take for this instance must be declared in a variant.
- For artifacts that change with the variant, list all combinations of interest for each property that has variants.
Validation fails if a variant is missing a value, redefines a property that has a top-level value, duplicates another variant, or lists a file that does not exist. Bindings need no changes; see Instances with variants.
Record where a benchmark comes from¶
To record the source of a problem that comes from a public benchmark library,
add the source keys to the metadata block of benchmark.yaml:
metadata:
benchmark-source-name: QOBLIB
benchmark-source-url: https://zib-aopt.github.io/QOBLIB/problem/07/
To also point to the matching instance in that source, set the instance keys
in the metadata block of instance.yaml. Repeat benchmark-source-name,
since an instance does not inherit the metadata of its benchmark:
metadata:
benchmark-source-name: QOBLIB
benchmark-instance-source-name: ibm32
benchmark-instance-source-url: https://zib-aopt.github.io/QOBLIB/instance.html?problem=07&name=ibm32
See Benchmark source metadata for the list of keys.
Add an instance to an existing problem¶
To add another instance of a problem that is already registered, create a new
folder under that problem's instances/ directory and write an instance.yaml
that uses the same property identifiers.
Then validate as in step 3.
Describe the problem in a README¶
To give a fuller problem statement — formulation, references, or instance
structure — add benchmarks/<problem-id>/README.md next to benchmark.yaml.
Use other property domains¶
The walk-through uses a mix of categorical, discrete, and continuous properties.
To constrain a continuous property to a range, set domainRange:
To leave a categorical property open, omit propertyDomain. See the
ado property domain documentation
and
section 2 of Logical Benchmarks and Instances.
Start from the repository templates¶
To begin from placeholders instead of the graph-coloring example, copy the
templates and replace every <...> marker:
mkdir -p benchmarks/<problem-id>
cp templates/logical-benchmark/benchmark.yaml \
benchmarks/<problem-id>/benchmark.yaml
cp -R templates/logical-benchmark/instances \
benchmarks/<problem-id>/instances
Rename instances/instance-name/ to your instance id, then continue from
step 3.
Validate a single problem folder¶
To validate one problem:
See also¶
- Logical Benchmarks and Instances — schema, bindings, and how results are aggregated
- How to add a benchmark experiment
- How to bind an experiment to a benchmark instance
- How to add a benchmark submission
nexus validate logical-benchmarks