Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Canonical QUBO Problems

Maintained by the JuliaQUBO organization
SECQUOIA  ·  PSR Energy

Open In Colab

Original Julia derivations and independent checks for number partitioning, Max-Cut, and minimum vertex cover.

Setup

Local installation

From the repository root, instantiate the shared Julia environment before opening this notebook:

julia --project=notebooks_jl -e 'using Pkg; Pkg.instantiate()'

After that one-time environment step, every example below is credential-free and uses no network service.

Google Colab

Open the badge above, select a Julia runtime, and run the setup cells. The bootstrap clones this repository only when Colab does not already have it, then activates the same checked-in notebook project used locally.

Notebook Cell
Notebook Cell

Learning objectives

By the end of this notebook you will be able to:

  1. derive QUBOs for number partitioning, Max-Cut, and minimum vertex cover;

  2. distinguish raw QUBO energy from the corresponding application score;

  3. verify every binary state against an independently implemented scoring function; and

  4. decode all exact optima and explain complementary or symmetric degeneracy.

Prerequisites

Prior notebooks: Notebook 2 introduces JuMP and QUBO models; this notebook is also self-contained.

Mathematical background: Binary variables, finite sums, and basic graph terminology.

Software: Julia 1.10+ with the shared notebook project instantiated.

Accounts required: None.

Verification strategy

Each section first defines an application-level score that does not inspect a JuMP model. We then enumerate all states, evaluate the actual expanded JuMP objective (including its constant), and compare the two values. Finally, QUBO.ExactSampler independently enumerates the model so that its best energy and complete optimal-state degeneracy can be compared with our application enumeration. Every JuMP model is a minimization model.

same_states (generic function with 1 method)

Number partitioning

Given positive weights a1,…,ana_1,\ldots,a_n, divide them into two groups whose sums are as close as possible. Let xi=0x_i=0 place item ii in group A and xi=1x_i=1 place it in group B. We use the explicit spin/bit convention

si=1−2xi,s_i = 1 - 2x_i,

so the signed imbalance is

I(x)=∑iaisi=A−2∑iaixi,A=∑iai.I(x)=\sum_i a_i s_i=A-2\sum_i a_i x_i,\qquad A=\sum_i a_i.

Minimizing its square produces the QUBO

ENP(x)=A2+∑i(4ai2−4Aai)xi+8∑i<jaiajxixj.E_{\mathrm{NP}}(x)=A^2+\sum_i(4a_i^2-4Aa_i)x_i+8\sum_{i<j}a_i a_jx_ix_j.

The raw energy is the squared signed imbalance; the application score reported below is the absolute imbalance.

decode_partition (generic function with 1 method)
Loading...
x=[1, 1, 1, 0]: A=[8], B=[1, 3, 4], imbalance=0, raw energy=0
x=[0, 0, 0, 1]: A=[1, 3, 4], B=[8], imbalance=0, raw energy=0

The two optimal bit strings are complements: one names {1,3,4}\{1,3,4\} as group A and {8}\{8\} as group B, while the other swaps the labels. They represent the same unlabeled partition, each with application imbalance 0 and raw QUBO energy 0.

Max-Cut

Let xi∈{0,1}x_i\in\{0,1\} label the side of a cut containing vertex ii. For an edge (i,j)(i,j), the expression

xi+xj−2xixjx_i+x_j-2x_ix_j

is 1 exactly when the endpoints are separated. Thus the cut weight is

C(x)=∑(i,j)∈Ewij(xi+xj−2xixj).C(x)=\sum_{(i,j)\in E}w_{ij}(x_i+x_j-2x_ix_j).

Max-Cut maximizes CC. QUBO solvers minimize, so our raw QUBO energy is explicitly EMC(x)=−C(x)E_{\mathrm{MC}}(x)=-C(x).

decode_cut (generic function with 1 method)
Loading...
x=[1, 0, 1, 0]: S0=[2, 4], S1=[1, 3], cut weight=7, raw energy=-7
x=[0, 1, 1, 0]: S0=[1, 4], S1=[2, 3], cut weight=7, raw energy=-7
x=[1, 0, 0, 1]: S0=[2, 3], S1=[1, 4], cut weight=7, raw energy=-7
x=[0, 1, 0, 1]: S0=[1, 3], S1=[2, 4], cut weight=7, raw energy=-7

There are four optimal labeled bit strings. Complementing every bit swaps the two side labels without changing the cut, so the four strings form two complementary pairs. The application optimum is a cut weight of 7; the corresponding minimized QUBO energy is -7.

Image produced in Jupyter

Minimum vertex cover

A vertex cover selects vertices so every edge has at least one selected endpoint. With xi=1x_i=1 meaning selected, edge (i,j)(i,j) is uncovered exactly when (1−xi)(1−xj)=1(1-x_i)(1-x_j)=1. The penalized QUBO is

EVC(x)=∑ixi+P∑(i,j)∈E(1−xi)(1−xj).E_{\mathrm{VC}}(x)=\sum_i x_i+P\sum_{(i,j)\in E}(1-x_i)(1-x_j).

For this unweighted objective, P=2P=2 is sufficient: if an edge is uncovered, selecting either endpoint increases the cover size by at most 1 and removes at least one penalty of 2. Therefore repairing an uncovered edge strictly reduces the objective; no infeasible state can be optimal. This is a proof-based choice, not a trial-and-error parameter.

selected_vertices (generic function with 1 method)
Loading...
x=[1, 0, 1, 0]: selected=[1, 3], uncovered=Tuple{Int64, Int64}[], raw energy=2
x=[0, 1, 1, 0]: selected=[2, 3], uncovered=Tuple{Int64, Int64}[], raw energy=2

The two minimum covers are {1,3}\{1,3\} and {2,3}\{2,3\}. Every edge is checked directly, both covers have application size 2, and their raw penalized energy is also 2 because no penalty remains.

Practice checkpoints

  1. Change the partition weights to [1,2,3,7][1,2,3,7]. Before running the model, predict the minimum absolute imbalance and whether complement symmetry still doubles the labeled degeneracy.

  2. Add edge (1,4)(1,4) with weight 2 to the Max-Cut instance. Recompute the direct cut scores and explain any change in degeneracy.

  3. Replace P=2P=2 by P=1P=1 in the vertex-cover model. Find an infeasible state tied with a feasible optimum and explain why the strict inequality P>1P>1 matters.

For each change, rerun the all-state assertion before trusting the solver output.

Notebook Cell
Best imbalance: 1; labeled optima: [[1, 1, 1, 0], [0, 0, 0, 1]]
Notebook Cell
Best cut weight: 9; labeled optima: [[1, 0, 1, 0], [0, 1, 0, 1]]
Notebook Cell
With P=1, infeasible best-energy states include [[0, 0, 1, 0]]

Summary

Learning objectives met:

  • Number partitioning minimizes a squared signed imbalance; its raw energy is the square of the application imbalance.

  • Max-Cut is a maximization problem, so its cut weight enters the minimized QUBO with a negative sign.

  • Minimum vertex cover combines cardinality with an uncovered-edge penalty; a penalty strictly larger than one is sufficient here.

  • Exhaustive application scoring, full JuMP-objective evaluation, and ExactSampler agree for every example.

  • Complementary partition and cut bit strings can encode equivalent unlabeled solutions.

Next steps: Use the practice checkpoints to change one instance at a time while keeping the all-state assertions green.

Further reading:

  • The Five Starter Problems paper develops the application context for these formulations.

  • The QUBO.jl documentation describes the public modeling and sampling interfaces used here.

References

  1. A. R. Mazumder and S. Tayur, Five Starter Problems: Solving Quadratic Unconstrained Binary Optimization Models on Quantum Computers, TutORials in Operations Research (2025), pp. 145–183, Mazumder & Tayur (2025).

  2. Companion materials: https://github.com/arulrhikm/Solving-QUBOs-on-Quantum-Computers.

  3. QUBO.jl public API and ExactSampler: https://github.com/JuliaQUBO/QUBO.jl.

This notebook contains original Julia code, examples, prose, and figures. The companion repository is cited as context; no source cells, prose, saved output, or assets were copied from it.

References
  1. Mazumder, A. R., & Tayur, S. (2025). Five Starter Problems: Solving Quadratic Unconstrained Binary Optimization Models on Quantum Computers. In Tutorials in Operations Research: Advances in Analytics and Operations Research: Improving Decisions to Secure the Future (pp. 145–183). INFORMS. 10.1287/educ.2025.0288