Two binary quadratic optimization problems can have the same number of variables and require quite different computational resources. The reason is in the quadratic terms. A variable may interact with only a few neighbors or with nearly every other variable in the model.

For someone designing an optimization algorithm, the number and arrangement of these interactions are important. For someone building a model, they offer a way to understand why an apparently small change to a formulation can have a large effect on its computational cost.

The graph inside the model

Write the energy of a binary vector as

E(x) = ∑i ai xi + ∑i<jbijxixj.

Every nonzero quadratic coefficient defines an edge in an interaction graph. If the average degree is d and there are n variables, the number of undirected edges is nd/2. In a fully connected model there are n(n − 1)/2 distinct pairs. This difference has immediate consequences for storing, transmitting and evaluating the model.

Many graph problems produce sparse QUBOs directly. By contrast, a covariance matrix in portfolio selection may contain interactions between almost every pair of assets. A constraint expressed by squaring a sum of variables can also create a dense collection of quadratic terms, even when the original objective is sparse.

What happens during a local move?

Suppose that an algorithm changes only variable i. The energy difference is

Δi E = (1 − 2xi)(ai + ∑j≠ ibijxj),

where bij = bji denotes the coefficient of the unordered pair, whichever endpoint has the smaller index. The expression involves only the neighbors of i. This is an important computational property: the change can be evaluated without recalculating the entire objective.

An algorithm that evaluates each candidate move from scratch may read the incident coefficients each time. An algorithm that maintains incremental move costs can reuse earlier calculations, updating affected neighbors when a move is accepted. These are general search design choices. Their relative cost depends on how many moves are considered and accepted, how the graph is stored, and the structure of the interactions.

The following small example verifies the energy-change expression directly. It uses each undirected pair once. This convention matters when transferring coefficients from a symmetric matrix, where the off-diagonal contribution may otherwise be counted twice.

Illustration: standalone Python calculation.

a = [-1, 2, -3, 1]
b = {(0, 1): 4, (1, 2): -2, (2, 3): 3}
x = [1, 0, 1, 0]
def energy(x):
    return sum(ai*xi for ai, xi in zip(a, x)) + sum(w*x[i]*x[j] for (i,j),w in b.items())
def delta(x, i):
    local = a[i] + sum(w*x[v if u==i else u] for (u,v),w in b.items() if i in (u,v))
    return (1-2*x[i])*local
for i in range(len(x)):
    y=x.copy(); y[i]=1-y[i]
    print(i, delta(x,i))
    assert energy(y)-energy(x)==delta(x,i)

The example prints:

0 1
1 4
2 3
3 4

Estimate storage before constructing the matrix

An explicitly stored unordered pair list with s bytes per pair needs sm bytes for m interactions, before working arrays and indexing overhead. A dense n-variable model has at most n(n−1)/2 unordered pairs; a graph of average degree d has nd/2 edges. For an illustration with n = 1,000 and d = 4, the two counts are 499,500 and 2,000. Implicit or low-rank representations can avoid materializing some dense expressions.

Squaring a cardinality row introduces all pair terms algebraically, though some coefficients may cancel when combined with the objective. An explicit row keeps the original graph visible.

Designing a benchmark that isolates density

To understand how an optimization method responds to density, hold the number of variables fixed and generate families with different average degrees. Use a reproducible graph generator, several seeds, a consistent coefficient distribution and the same objective convention. Verify the actual degrees: merging repeated edges can change them.

Then measure solution quality at specified search budgets. If no proven optimum is available, report the best-known solution value as a reference, with the date and method used to establish it. A difference from that reference is not a proven optimality gap. Rescore returned solutions independently using the original coefficients.

The time spent preparing or transferring a model is a different measurement from the time spent searching. Both can matter for an application, particularly if a large model is solved repeatedly. A useful report states the boundary of the timing measurement clearly.

What a modeler can do

Before selecting a search method, inspect the degree distribution, connected components and the sources of dense interactions. An exact linear constraint may preserve a sparse objective that a squared penalty would make dense. Reconsidering the formulation can therefore improve the computational problem before an algorithm begins searching.

The 4colors Optimizer for QUBO supports binary quadratic optimization and explicit linear constraints. Try it with the structure of your own model in mind, and compare the quality of solutions at the search budgets that matter to your work.