Quadratic unconstrained binary optimization

From HandWiki

Quadratic unconstrained binary optimization (QUBO), also known as unconstrained binary quadratic programming (UBQP), is a combinatorial optimization problem with a wide range of applications from finance and economics to machine learning.[1] QUBO is an NP hard problem, and for many classical problems from theoretical computer science, like maximum cut, graph coloring and the partition problem, embeddings into QUBO have been formulated.[2][3] Embeddings for machine learning models include support-vector machines, clustering and probabilistic graphical models.[4] Moreover, due to its close connection to Ising models, QUBO constitutes a central problem class for adiabatic quantum computation, where it is solved through a physical process called quantum annealing.[5]

Definition

The set of binary vectors of a fixed length [math]\displaystyle{ n\gt 0 }[/math] is denoted by [math]\displaystyle{ \mathbb{B}^n }[/math], where [math]\displaystyle{ \mathbb{B}=\lbrace 0,1\rbrace }[/math] is the set of binary values (or bits). We are given a real-valued upper triangular matrix [math]\displaystyle{ Q\in\mathbb{R}^{n\times n} }[/math], whose entries [math]\displaystyle{ Q_{ij} }[/math] define a weight for each pair of indices [math]\displaystyle{ i,j\in\lbrace 1,\dots,n\rbrace }[/math] within the binary vector. We can define a function [math]\displaystyle{ f_Q: \mathbb{B}^n\rightarrow\mathbb{R} }[/math] that assigns a value to each binary vector through

[math]\displaystyle{ f_Q(x) = x^\top Qx = \sum_{i=1}^n \sum_{j=i}^n Q_{ij} x_i x_j }[/math]

Intuitively, the weight [math]\displaystyle{ Q_{ij} }[/math] is added if both [math]\displaystyle{ x_i }[/math] and [math]\displaystyle{ x_j }[/math] have value 1. When [math]\displaystyle{ i=j }[/math], the values [math]\displaystyle{ Q_{ii} }[/math] are added if [math]\displaystyle{ x_i=1 }[/math], as [math]\displaystyle{ x_ix_i=x_i }[/math] for all [math]\displaystyle{ x_i\in\mathbb{B} }[/math].

The QUBO problem consists of finding a binary vector [math]\displaystyle{ x^* }[/math] that is minimal with respect to [math]\displaystyle{ f_Q }[/math], namely

[math]\displaystyle{ \forall x\in\mathbb{B}^n: ~f_Q(x^*)\leq f_Q(x) }[/math]

In general, [math]\displaystyle{ x^* }[/math] is not unique, meaning there may be a set of minimizing vectors with equal value w.r.t. [math]\displaystyle{ f_Q }[/math]. The complexity of QUBO arises from the number of candidate binary vectors to be evaluated, as [math]\displaystyle{ |\mathbb{B}^n|=2^n }[/math] grows exponentially in [math]\displaystyle{ n }[/math].

Sometimes, QUBO is defined as the problem of maximizing [math]\displaystyle{ f_Q }[/math], which is equivalent to minimizing [math]\displaystyle{ f_{-Q}=-f_Q }[/math].

Properties

QUBO is scale invariant for positive factors [math]\displaystyle{ \alpha\gt 0 }[/math], which leave the optimum [math]\displaystyle{ x^* }[/math] unchanged:

[math]\displaystyle{ f_{\alpha Q}(x) = \sum_{i\leq j}(\alpha Q_{ij})x_ix_j = \alpha\sum_{i\leq j}Q_{ij}x_ix_j = \alpha f_Q(x) }[/math]

In its general form, QUBO is NP-hard and cannot be solved efficiently by any polynomial-time algorithm.[6] However, there are polynomially-solvable special cases, where [math]\displaystyle{ Q }[/math] has certain properties,[7] for example:

  • If all coefficients are positive, the optimum is trivially [math]\displaystyle{ x^*=(0,\dots,0) }[/math]. Similarly, if all coefficients are negative, the optimum is [math]\displaystyle{ x^*=(1,\dots,1) }[/math].
  • If [math]\displaystyle{ Q }[/math] is diagonal, the bits can be optimized independently, and the problem is solvable in [math]\displaystyle{ \mathcal{O}(n) }[/math]. The optimal variable assignments are simply [math]\displaystyle{ x^*_i=1 }[/math] if [math]\displaystyle{ Q_{ii}\lt 0 }[/math], and [math]\displaystyle{ x^*_i=0 }[/math] otherwise.
  • If all off-diagonal elements of [math]\displaystyle{ Q }[/math] are non-positive, the corresponding QUBO problem is solvable in polynomial time.[8]

QUBO can be solved using integer linear programming solvers like CPLEX or Gurobi Optimizer. This is possible since QUBO can be reformulated as a linear constrained binary optimization problem. To achieve this, substitute the product [math]\displaystyle{ x_ix_j }[/math] by an additional binary variable [math]\displaystyle{ z_{ij}\in\{0,1\} }[/math] and add the constraints [math]\displaystyle{ x_i\ge z_{ij} }[/math], [math]\displaystyle{ x_j\ge z_{ij} }[/math] and [math]\displaystyle{ x_i+x_j-1\le z_{ij} }[/math]. Note that [math]\displaystyle{ z_{ij} }[/math] can also be relaxed to continuous variables within the bounds zero and one.

Applications

QUBO is a structurally simple, yet computationally hard optimization problem. It can be used to encode a wide range of optimization problems from various scientific areas.[9]

Cluster Analysis

Binary Clustering with QUBO
20 points with random cluster assignment
A bad cluster assignment.
20 points with sensible cluster assignment
A good cluster assignment.
Visual representation of a clustering problem with 20 points: Circles of the same color belong to the same cluster. Each circle can be understood as a binary variable in the corresponding QUBO problem.

As an illustrative example of how QUBO can be used to encode an optimization problem, we consider the problem of cluster analysis. Here, we are given a set of 20 points in 2D space, described by a matrix [math]\displaystyle{ D\in\mathbb{R}^{20\times 2} }[/math], where each row contains two cartesian coordinates. We want to assign each point to one of two classes or clusters, such that points in the same cluster are similar to each other. For two clusters, we can assign a binary variable [math]\displaystyle{ x_i\in\mathbb{B} }[/math] to the point corresponding to the [math]\displaystyle{ i }[/math]-th row in [math]\displaystyle{ D }[/math], indicating whether it belongs to the first ([math]\displaystyle{ x_i=0 }[/math]) or second cluster ([math]\displaystyle{ x_i=1 }[/math]). Consequently, we have 20 binary variables, which form a binary vector [math]\displaystyle{ x\in\mathbb{B}^{20} }[/math] that corresponds to a cluster assignment of all points (see figure).

One way to derive a clustering is to consider the pairwise distances between points. Given a cluster assignment [math]\displaystyle{ x }[/math], one of [math]\displaystyle{ x_ix_j }[/math] or [math]\displaystyle{ (1-x_i)(1-x_j) }[/math] evaluates to 1 if points [math]\displaystyle{ i }[/math] and [math]\displaystyle{ j }[/math] are in the same cluster. Similarly, one of [math]\displaystyle{ x_i(1-x_j) }[/math] or [math]\displaystyle{ (1-x_i)x_j }[/math] indicates that they are in different clusters. Let [math]\displaystyle{ d_{ij}\geq 0 }[/math] denote the Euclidean distance between points [math]\displaystyle{ i }[/math] and [math]\displaystyle{ j }[/math]. In order to define a cost function to minimize, when points [math]\displaystyle{ i }[/math] and [math]\displaystyle{ j }[/math] are in the same cluster we add their positive distance [math]\displaystyle{ d_{ij} }[/math], and subtract it when they are in different clusters. This way, an optimal solution tends to place points which are far apart into different clusters, and points that are close into the same cluster. The cost function thus comes down to

[math]\displaystyle{ \begin{align} f(x) &= \sum_{i\lt j}d_{ij}(x_ix_j + (1-x_i)(1-x_j))-d_{ij}(x_i(1-x_j)+(1-x_i)x_j) \\ &= \sum_{i\lt j}\left[4d_{ij}x_ix_j-2d_{ij}x_i-2d_{ij}x_j+d_{ij}\right] \end{align} }[/math]

From the second line, the QUBO parameters can be easily found by re-arranging to be:

[math]\displaystyle{ \begin{align} Q_{ij} &= \begin{cases} d_{ij} &\text{if } i\neq j \\ -\left(\sum\limits_{k=1}^{i-1} d_{ki} +\sum\limits_{\ell=i+1}^n d_{i\ell}\right)&\text{if } i=j \end{cases} \end{align} }[/math]

Using these parameters, the optimal QUBO solution will correspond to an optimal cluster w.r.t. above cost function.

Connection to Ising models

QUBO is very closely related and computationally equivalent to the Ising model, whose Hamiltonian function is defined as

[math]\displaystyle{ H(\sigma) = -\sum_{\langle i~j\rangle} J_{ij} \sigma_i \sigma_j - \mu \sum_j h_j \sigma_j }[/math]

with real-valued parameters [math]\displaystyle{ h_j, J_{ij}, \mu }[/math] for all [math]\displaystyle{ i,j }[/math]. The spin variables [math]\displaystyle{ \sigma_j }[/math] are binary with values from [math]\displaystyle{ \lbrace -1,+1\rbrace }[/math] instead of [math]\displaystyle{ \mathbb{B} }[/math]. Moreover, in the Ising model the variables are typically arranged in a lattice where only neighboring pairs of variables [math]\displaystyle{ \langle i~j\rangle }[/math] can have non-zero coefficients. Applying the identity [math]\displaystyle{ \sigma\mapsto 2x-1 }[/math] yields an equivalent QUBO problem:[2]

[math]\displaystyle{ \begin{align}f(x) &= \sum_{\langle i~j\rangle} -J_{ij}(2x_i-1)(2x_j-1) +\sum_{j}\mu h_j(2x_j-1) \\ &= \sum_{\langle i~j\rangle} (-4J_{ij}x_ix_j +2J_{ij}x_i +2J_{ij}x_j -J_{ij}) +\sum_{j}(2\mu h_jx_j-\mu h_j) &&\text{using } x_j=x_jx_j\\ &= \sum_{\langle i~j\rangle} (-4J_{ij}x_ix_j) + \sum_{\langle i~j\rangle}2J_{ij}x_i + \sum_{\langle i~j\rangle}2J_{ij}x_j +\sum_{j}2\mu h_jx_j -\sum_{\langle i~j\rangle}J_{ij} -\sum_{j}\mu h_j\\ &= \sum_{\langle i~j\rangle} (-4J_{ij}x_ix_j) + \sum_{\langle j~i\rangle}2J_{ji}x_j + \sum_{\langle i~j\rangle}2J_{ij}x_j +\sum_{j}2\mu h_jx_j -\sum_{\langle i~j\rangle}J_{ij} -\sum_{j}\mu h_j &&\text{using } \sum_{\langle i~j\rangle}=\sum_{\langle j~i\rangle}\\ &= \sum_{\langle i~j\rangle} (-4J_{ij}x_ix_j) + \sum_j\sum_{\langle k=j~i\rangle}2J_{ki}x_j + \sum_j\sum_{\langle i~k=j\rangle}2J_{ik}x_j +\sum_{j}2\mu h_jx_j -\sum_{\langle i~j\rangle}J_{ij} -\sum_{j}\mu h_j\\ &= \sum_{\langle i~j\rangle} (-4J_{ij}x_ix_j) + \sum_j \left(\sum_{\langle i~k=j\rangle}(2J_{ki} + 2J_{ik}) + 2\mu h_j \right)x_j -\sum_{\langle i~j\rangle}J_{ij} -\sum_{j}\mu h_j &&\text{using } \sum_{\langle k=j~i\rangle}=\sum_{\langle i~k=j\rangle}\\ &= \sum_{i=1}^n\sum_{j=1}^i Q_{ij}x_ix_j + C\end{align} }[/math]

where

[math]\displaystyle{ \begin{align}Q_{ij} &= \begin{cases}-4J_{ij} &\text{if } i\neq j \\ \sum_{\langle i~k=j\rangle}(2J_{ki} + 2J_{ik}) + 2\mu h_j &\text{if } i=j\end{cases} \\ C &= -\sum_{\langle i~j\rangle}J_{ij} -\sum_{j}\mu h_j\end{align} }[/math]

and using the fact that for a binary variable [math]\displaystyle{ x_j = x_j x_j }[/math].

As the constant [math]\displaystyle{ C }[/math] does not change the position of the optimum [math]\displaystyle{ x^* }[/math], it can be neglected during optimization and is only important for recovering the original Hamiltonian function value.

References

  1. Kochenberger, Gary; Hao, Jin-Kao; Glover, Fred; Lewis, Mark; Lu, Zhipeng; Wang, Haibo; Wang, Yang (2014). "The unconstrained binary quadratic programming problem: a survey.". Journal of Combinatorial Optimization 28: 58–81. doi:10.1007/s10878-014-9734-0. http://leeds-faculty.colorado.edu/glover/454%20-%20xQx%20survey%20article%20as%20published%202014.pdf. 
  2. 2.0 2.1 Glover, Fred; Kochenberger, Gary (2019). "A Tutorial on Formulating and Using QUBO Models". arXiv:1811.11538 [cs.DS].
  3. Lucas, Andrew (2014). "Ising formulations of many NP problems". Frontiers in Physics 2: 5. doi:10.3389/fphy.2014.00005. Bibcode2014FrP.....2....5L. 
  4. Mücke, Sascha; Piatkowski, Nico; Morik, Katharina (2019). "Learning Bit by Bit: Extracting the Essence of Machine Learning". LWDA. https://pdfs.semanticscholar.org/f484/b4a789e1563b91a416a7cfabbf72f0aa3b2a.pdf. 
  5. Tom Simonite (8 May 2013). "D-Wave's Quantum Computer Goes to the Races, Wins". MIT Technology Review. http://www.technologyreview.com/view/514686/d-waves-quantum-computer-goes-to-the-races-wins/. 
  6. A. P. Punnen (editor), Quadratic unconstrained binary optimization problem: Theory, Algorithms, and Applications, Springer, Springer, 2022.
  7. Çela, E., Punnen, A.P. (2022). Complexity and Polynomially Solvable Special Cases of QUBO. In: Punnen, A.P. (eds) The Quadratic Unconstrained Binary Optimization Problem. Springer, Cham. https://doi.org/10.1007/978-3-031-04520-2_3
  8. See Theorem 3.16 in Punnen (2022); note that the authors assume the maximization version of QUBO.
  9. Ratke, Daniel (2021-06-10). "List of QUBO formulations". https://blog.xa0.de/post/List-of-QUBO-formulations/. 

External links

  • QUBO Benchmark (Benchmark of software packages for the exact solution of QUBOs; part of the well-known Mittelmann benchmark collection)