🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Quantum Combinatorial Optimization

Quantum ComputingQuantum OptimizationđŸŸĸ Free Lesson

Combinatorial Optimization

Combinatorial optimization problems ask for the best solution from a finite set of candidates:

where is a discrete solution space. The counts grow fast enough that intuition fails early: a 10-city tour problem has distinct routes, 15 cities has about 43 billion, and 20 cities passes . Exhaustive search is therefore a luxury reserved for instances with fewer than about 25 binary variables.

Most of these problems are NP-hard, which means two things that get conflated. No known algorithm solves every instance to optimality in polynomial time, yet real instances are often easy — solvers close 10,000-vertex scheduling cases daily by combining linear relaxations, cutting planes and clever pruning. The interesting question is therefore never whether quantum can beat brute force, which it can, but whether it can beat a well-tuned commercial solver running on one core.

Quantum approaches target two distinct niches: providing a better approximation ratio than a classical heuristic within a fixed time budget, or offering a different scaling curve whose constant factors only pay off beyond some instance size that hardware has not reached yet.

MaxCut

MaxCut partitions the vertices of a graph to maximise the weight of edges crossing between the two sides:

where . For an unweighted graph with edges the optimum is at most , and the Goemans-Williamson randomised rounding of a semidefinite program guarantees of it in polynomial time — a bound that has stood since 1995.

Work a four-vertex cycle plus one chord: vertices – in a square with an extra edge –. The square alone can be cut 4 ways with 4 edges crossed; adding the chord forces a choice, and the optimum is a cut of size 3 crossing edges , and . Five edges, 16 possible assignments, optimum 3 — small enough to check by hand, which is exactly why MaxCut instances of this size are the standard smoke test for a QAOA implementation.

QAOA approaches the same objective from the other direction: the cost Hamiltonian encodes as a diagonal operator, the mixer spreads amplitude over feasible assignments, and the classical optimizer searches the angle pairs. Measured performance must be quoted against 0.878, not against the trivial 0.5 of a random partition.

Turning Constraints into Penalty Terms

Any problem with constraints needs a penalty term before a quantum annealer can see it. The recipe has three steps and one tuning parameter that decides whether the encoding works at all.

  1. Write each constraint as for binary .
  2. Square it and add to the objective.
  3. Choose larger than the largest possible objective improvement, so violating a constraint is never worth it.

For MaxCut the variables are unconstrained, so no penalty is needed. For TSP the constraint "every city is visited exactly once" becomes a row-sum penalty and a column-sum penalty; for portfolio selection the budget constraint becomes one quadratic term. If is too small the solver returns an infeasible solution that scores better than any legal one, and if it is far too large the matrix condition number degrades and the annealer's precision budget gets consumed by the penalty rather than the objective.

Traveling Salesman Problem (TSP)

TSP asks for the shortest tour visiting every city exactly once and returning to the start:

The standard binary encoding uses variables meaning city is visited at position . For 10 cities that is 100 qubits — a useful reminder that qubit count, not algorithmic cleverness, is usually the binding constraint. Two constraints dominate: each position holds exactly one city, and each city appears exactly once.

The result is a QUBO (Quadratic Unconstrained Binary Optimization) problem:

where combines the distance objective with the two penalty blocks. The encoding is quadratic because the distance term is a product of two binaries, and both constraints square into products as well.

Portfolio Optimization

Portfolio optimization maximises expected return for a given level of risk:

subject to and . Classically this is a convex quadratic program solved in time — 500 assets takes milliseconds, so quantum advantage here cannot come from solving the same convex problem faster.

The quantum angle discretises the weight vector. Round each weight to one of five levels in and 10 assets give million feasible portfolios; the encoding needs binary variables to express the level of each asset. The bet is that the discretised, non-convex landscape is where an annealer finds good solutions faster than a branch-and-bound solver proving optimality. Reported results on this formulation are mixed: small instances favour quantum annealing on time-to-solution, and most published speedups evaporate once the classical solver is allowed warm starts.

QUBO Formulation

Many combinatorial problems collapse into the single canonical form:

where and is upper triangular — the diagonal of is indistinguishable from for binary variables, so conventionally the linear terms are folded into the diagonal.

That single form is why QUBO matters: it is the input language of D-Wave's annealers, the target of QAOA's cost Hamiltonian, and the interface of hybrid solvers such as dimod and neal. Porting a problem between them becomes a matrix exercise rather than a reformulation.

ProblemObjective termsConstraint termsQubits for a typical instance
MaxCutedge products noneone per vertex
TSPdistance products row and column sums
Portfolioreturn and covariancebudget, cardinalityassets times levels
Graph colouringsame-colour productsone colour per vertexvertices times colours

Quantum Speedups

The claimed advantages differ sharply by problem class, and the honest version of the table is more useful than the optimistic one:

ProblemClassical baselineQuantum candidateRealistic status
MaxCut0.878 guarantee (GW)QAOA about 0.69 on 3-regularbelow classical guarantee at low depth
TSP exactQAOA or annealing heuristicheuristic only, instance dependent
Portfolio convex QPdiscretised QAOAnon-convex variant, mixed results
SAT exhaustiveGrover quadratic, but gates cost too
Simulation of dynamicsexponential in native quantum simulationthe one clean asymptotic win

The pattern is worth internalising: quantum shows genuine asymptotic gains where the quantum device mirrors the structure of the problem — simulating Hamiltonians — and mostly heuristic, constant-factor gains where it is asked to solve a classical combinatorial problem.

Python: MaxCut QUBO

Building the QUBO matrix and checking it against brute force on a five-vertex instance:

python
import numpy as np

def maxcut_qubo(edges, n):
    # MaxCut as a QUBO: minimising x^T Q x equals maximising the cut.
    Q = np.zeros((n, n))
    for i, j in edges:
        Q[i, i] += 1
        Q[j, j] += 1
        Q[i, j] -= 2
        Q[j, i] -= 2
    return Q

def cut_value(edges, x):
    # Objective evaluated directly on a bitstring.
    return sum(x[i] ^ x[j] for i, j in edges)

edges = [(0, 1), (1, 2), (2, 3), (3, 0), (0, 2)]
n = 4
Q = maxcut_qubo(edges, n)

best_energy, best_x, visited = float('inf'), None, 0
for code in range(2 ** n):
    x = np.array([(code >> i) & 1 for i in range(n)])
    energy = x @ Q @ x
    visited += 1
    if energy < best_energy:
        best_energy, best_x = energy, x

print(f"assignments searched: {visited}")
print(f"best bitstring: {best_x}")
print(f"QUBO energy: {best_energy:.1f}")
print(f"cut value: {cut_value(edges, best_x)}")
print(f"ratio vs optimum: {cut_value(edges, best_x) / 3:.3f}")

Brute force reports an energy of and a cut of 3 on this instance, matching the optimum found by hand earlier. Note that maxcut_qubo symmetrises and ; solvers that assume an upper-triangular matrix will happily read only one triangle and produce a matrix whose quadratic form differs by a factor of two.

Python: TSP QUBO with Penalties

The same pattern with constraints added, showing the tuning step in code rather than in prose:

python
import numpy as np

def tsp_qubo(dist, lam=10.0):
    # Order-preserving TSP encoding: n cities, n positions, n^2 binaries.
    n = len(dist)
    N = n * n
    Q = np.zeros((N, N))
    idx = lambda city, pos: city * n + pos

    # Objective: distance travelled between consecutive positions.
    for pos in range(n):
        nxt = (pos + 1) % n
        for a in range(n):
            for b in range(n):
                Q[idx(a, pos), idx(b, nxt)] += dist[a][b]

    # Penalty 1: exactly one city per position.
    for pos in range(n):
        for a in range(n):
            Q[idx(a, pos), idx(a, pos)] += lam
            for b in range(a + 1, n):
                Q[idx(a, pos), idx(b, pos)] += 2 * lam

    # Penalty 2: each city used exactly once.
    for a in range(n):
        for pos in range(n):
            Q[idx(a, pos), idx(a, pos)] += lam
            for t in range(pos + 1, n):
                Q[idx(a, pos), idx(a, t)] += 2 * lam
    return Q

dist = [[0, 2, 9, 10],
        [1, 0, 6, 4],
        [15, 7, 0, 8],
        [6, 3, 12, 0]]
lam = 20.0
Q = tsp_qubo(dist, lam=lam)
print(f"encoding size: {Q.shape[0]} variables")
print(f"penalty scale lambda: {lam} (2*lambda = {2*lam} on penalty pairs)")
print(f"largest distance entry: {max(max(r) for r in dist)}")
print(f"largest |Q| entry: {np.abs(Q).max():.1f}")

With four cities the encoding needs 16 variables, and the penalty contributes per constraint-violating pair against a largest single-leg distance of 15, so no constraint violation can beat a legal tour. Raising further is not free: the penalty entries grow while the distances stay between 1 and 15, the dynamic range the annealer must resolve widens, and on real hardware that ratio is the difference between finding feasible tours and returning plausible-looking garbage.

Common Mistakes

Quoting a QAOA approximation ratio without the classical baseline beside it

Fix: Always report random assignment, the 0.878 Goemans-Williamson guarantee and the exact optimum together so a 0.69 result is read in its proper frame

Setting the penalty coefficient lambda by guesswork

Fix: Bound it above the largest possible objective swing, then check the returned solution satisfies every constraint before trusting its cost

Assuming discretised portfolio optimisation is the same convex problem a classical solver already closes instantly

Fix: State the discretisation explicitly — the QUBO is non-convex, and that non-convexity is the only part where quantum could plausibly compete

Feeding a non-symmetric QUBO matrix to a solver that reads only the upper triangle

Fix: Upper-triangularise on purpose and add each off-diagonal term once, since writing both Q[i,j] and Q[j,i] silently doubles the quadratic contribution

Key Takeaways

  • Combinatorial problems become quantum-usable only after constraints are folded into penalty terms, and the penalty must exceed the largest objective swing without overwhelming the matrix
  • MaxCut has a 0.878 classical guarantee that low-depth QAOA does not beat, so claimed quantum advantage has to be measured against that number rather than against random assignment
  • TSP needs n squared binary variables for n cities — 10 cities is already 100 qubits — which makes qubit count the binding constraint long before algorithm quality does
  • Every QUBO problem shares one canonical form, which is why D-Wave, QAOA and hybrid solvers all consume the same matrix with only formatting differences
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-15

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Quantum Computing Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement