Before an optimisation problem can be handed to a quantum annealer, or to most quantum optimisation algorithms, it has to be rewritten in a form the machine accepts. QUBO is one of the most widely used of these forms. It is not a quantum concept in itself: it is ordinary mathematics that happens to match what the hardware does naturally.
What does the QUBO form look like?
Each word in the name describes one property:
- Binary: every variable is a yes/no decision that takes the value 0 or 1. “Is this vehicle assigned to this route?” is an example.
- Quadratic: the cost function contains only terms with a single variable and products of two variables, never products of three or more.
- Unconstrained: there are no separately stated rules. Any combination of 0s and 1s is a valid input, so everything that matters has to be part of the cost.
- Optimisation: the aim is to find the assignment with the lowest cost.
In compact notation, the task is to minimise xᵀQx, where x is a vector of binary variables and Q is a square matrix of numbers. The diagonal entries of Q give the cost of setting each variable to 1 on its own. The off-diagonal entries give the extra cost, or reward, when two variables are 1 together.
A close relative: the Ising model
The Ising model comes from the physics of magnetism. Its variables are “spins” that take the values −1 and +1 instead of 0 and 1, and its energy has terms for single spins and for pairs of spins. The substitution s = 2x − 1 turns one form into the other, so the two are different notations for the same class of problems.
Quantum annealing hardware is naturally described in Ising terms, while QUBO is often more convenient for modelling.
How do real constraints fit into an unconstrained form?
Real problems have rules: each job must go to exactly one machine, a budget must not be exceeded. In a QUBO, a rule becomes a penalty term: an expression that is zero when the rule is satisfied and positive when it is broken, multiplied by a weight and added to the cost.
For example, the rule “exactly one of x₁, x₂ and x₃ is 1” is written as the term P·(x₁ + x₂ + x₃ − 1)², where P is the weight. The term is zero only when exactly one variable is 1. Squaring a linear expression produces only pairwise products, so the model stays quadratic.
A small worked example: splitting numbers into two equal groups
Suppose the numbers 4, 3, 2 and 1 are to be split into two groups with equal sums.
- Variables: each number gets one binary variable, set to 1 for group A and 0 for group B.
- Target: the numbers add up to 10, so the groups are equal when the sum of group A, which is 4x₁ + 3x₂ + 2x₃ + x₄, is exactly 5.
- Cost: the expression (4x₁ + 3x₂ + 2x₃ + x₄ − 5)² is zero for a perfect split and positive otherwise.
- Expansion: multiplying out the square, with x² = x for a binary variable, leaves only single-variable terms, pairwise products and a constant that can be dropped. For instance, the coefficient of x₁ is −24 and that of the product x₁x₂ is +24. These coefficients fill the matrix Q.
- Solution: of the 16 possible assignments, two have zero cost: {4, 1} in one group and {3, 2} in the other, and its mirror image.
With n numbers there are 2ⁿ assignments, which is why solvers are needed.
Where is QUBO used?
- Quantum annealers: the QUBO or Ising form is the direct input.
- QAOA: this hybrid algorithm for gate-model machines turns the cost function into operations in a quantum circuit.
- Classical and hybrid solvers: heuristics such as simulated annealing and tabu search, quantum-inspired algorithms and hybrid solvers all use the same model.
Many well-known problems, including max-cut, graph colouring, the travelling salesman problem and portfolio selection, have QUBO formulations. Because the model is the same everywhere, different solvers can be compared on it directly. For the wider context, see the article on quantum optimisation.
What are the pitfalls?
- Penalty weights: if a weight is too small, the solver returns “cheap” solutions that break the rules. If it is too large, the penalties dominate and the real cost differences get lost in the limited precision of the hardware. The right value is usually found by experiment.
- Growth in the number of variables: encoding integers and inequality constraints takes extra binary variables. The usual formulation of a travelling salesman problem with n stops, for example, uses about n² variables.
How Q&Co can help
Problem formulation is one of the steps in Q&Co’s method: after a suitability assessment, an industrial problem is turned into a model such as a QUBO, addressed with hybrid algorithms and assessed for performance and resource needs. To discuss your own problem, contact us.