This program is part of QOBLIB - Quantum Optimization Benchmarking Library and is designed to verify solutions to Minimum Birkhoff Decomposition Problems. It checks whether a given set of permutation matrices and weights correctly reconstruct the doubly stochastic matrix.
The Birkhoff-von Neumann theorem states that any doubly stochastic matrix can be expressed as a convex combination of permutation matrices. The Minimum Birkhoff Decomposition problem asks for the minimal number of permutation matrices needed for this representation.
Given a doubly stochastic matrix
subject to:
where
Given instance and solution files, this checker:
- Parses JSON-formatted instance and solution files.
- Validates each permutation matrix (ensures valid permutation of {1, ..., n}).
- Verifies that weights are non-negative and sum to the scale factor.
- Reconstructs the doubly stochastic matrix from the weighted permutation matrices.
- Compares the reconstruction against the original matrix.
- Reports the number of permutation matrices used (k value).
This program does not check for optimality.
A JSON file containing one or more instances, each with:
-
id: Instance identifier (e.g., "B3_9_5") -
n: Matrix dimension -
scale: Scaling factor (typically 1000 for integer arithmetic) -
scaled_doubly_stochastic_matrix: Flat array of$n^2$ integers representing the scaled doubly stochastic matrix (row-major order) -
weights: Array of integer weights (scaled) -
permutations: Array of integers representing permutation matrices
{
"_license": "...",
"001": {
"id": "B3_9_1",
"n": 3,
"scale": 1000,
"scaled_doubly_stochastic_matrix": [
197, 275, 528,
81, 723, 196,
722, 2, 276
],
"weights": [180, 127, 7, 315, 118],
"permutations": [
2, 1, 3,
3, 1, 2,
2, 1, 3,
3, 2, 1,
2, 1, 3
]
}
}Permutation Encoding: Each permutation of dimension [2, 1, 3, 3, 1, 2] represents two permutations:
- First:
$(2, 1, 3)$ meaning row 1→col 2, row 2→col 1, row 3→col 3 - Second:
$(3, 1, 2)$ meaning row 1→col 3, row 2→col 1, row 3→col 2
A JSON file with the same structure as the instance file, containing the proposed solutions. Each solution must have:
id: Must match an instance IDscaled_doubly_stochastic_matrix: Should match the instance (for verification)weights: Array of weights (should sum to scale)permutations: Array encoding the permutation matrices
The checker verifies all solutions found in the solution file against matching instances.
{
"001": {
"id": "B3_9_1",
"scaled_doubly_stochastic_matrix": [
197, 275, 528,
81, 723, 196,
722, 2, 276
],
"weights": [197, 79, 196, 526, 2],
"permutations": [
1, 2, 3,
2, 1, 3,
2, 3, 1,
3, 2, 1,
3, 1, 2
],
"n": 3,
"k": 5,
"scale": 1000,
"optimal": true
}
}First, build the checker using Cargo:
cargo build --release./target/release/check_birkhoff <instance-file> <solution-file>instance-file: Path to the JSON file containing instance datasolution-file: Path to the JSON file containing solution data
Check a single instance set:
./target/release/check_birkhoff ../instances/qbench_03_dense.json ../solutions/qbench_03_dense.jsonCheck all solutions:
./check_all.shThe checker produces output like:
QOBLIB Birkhoff Decomposition Solution Checker Version 1.0
Checking 50 solutions against 50 instances
Instance B3_9_1: k=5, valid
Instance B3_9_2: k=4, valid
...
VALID: All 50 instances verified successfully
For each solution, the checker reports:
- Instance ID
- k value: Number of permutation matrices used
- Validity status: Whether the decomposition correctly reconstructs the matrix
- Permutation validity: Each permutation must contain each number from 1 to n exactly once
- Weight sum: All weights must be non-negative and sum to the scale factor
- Matrix reconstruction: The weighted sum of permutation matrices must equal the doubly stochastic matrix
- 0: All solutions are valid
- 1: One or more solutions are invalid
- 2: Error (e.g., file not found, parsing error)
- The checker uses integer arithmetic with a scale factor (typically 1000) to avoid floating-point precision issues
- Instance files may contain multiple instances; the checker matches solutions by ID
- Missing solutions for some instances is acceptable; the checker only validates provided solutions
- The
optimalfield in solutions is informational only and not verified by the checker
Part of QOBLIB, released under Apache 2.0.
Maximilian Schicker © 2025