# Definitions¶

## Binary Quadratic Model¶

The binary quadratic model (BQM) class of problems consists of Ising models and quadratic unconstrained binary optimization (QUBO) models. These two forms are mathematically equivalent, and our software tools allow you to work in either domain. In this guide, we will provide examples and exercises in both forms. Note that some problems may see better results with Ising over QUBO, and vice versa.

A BQM takes the following form.

The coefficients \(a_i\) and \(b_{i,j}\) are constant numbers we choose to define our problem, as is the constant term \(c\). The binary variables \(v_i\) and \(v_j\) are the values that we are looking for to solve our problem. The best solution for these variables is the value for each \(v_i\) that produces the smallest value for the overall expression. Searching for the variables that minimize an expression is called an “argmin” in mathematics.

Let’s break this expression down.

**Linear Terms:**

The first summation, \(\sum a_i v_i\), contains linear terms, with each having just one binary variable.

**Quadratic Terms:**

The second summation, \(\sum \sum b_{i,j} v_i v_j\), contains quadratic terms, with each term in the summation containing a product of two variables.

**Constants:**

In the general BQM form we may or may not include constants. Since we are looking for an argmin, any constant terms will not affect our final answer. However, it may be useful when interpreting the output from D-Wave solvers and samplers.

## Quadratic Unconstrained Binary Optimization¶

A QUBO model takes the following form.

The binary variables \(x_i\) and \(x_j\) may take values from \(\{0, 1\}\).

When we are ready to run a QUBO with the D-Wave Ocean software tool kit, one method is to store the QUBO in a matrix format for the Ocean SDK. We can map a QUBO to a matrix by placing linear terms along the diagonal and quadratic terms in the off-diagonal positions.

**Example:**

We can map \(x_1+2x_2+3x_3+12x_1 x_2+13x_1 x_3+14x_2 x_4\) to the following matrix.

In this matrix, we place coefficient \(a_i\) in matrix position \((i,i)\) and coefficient \(b_{i,j}\) in matrix position \((i,j)\).

## Ising Model¶

An Ising model takes the following form.

The binary variables \(s_i\) and \(s_j\) may take values from \(\{-1, +1\}\).

When it comes time to write Ocean programs, we will need to represent our Ising model as a matrix and a vector. We can map the quadratic terms of an Ising model to a matrix by placing them in the off-diagonal positions, and the linear terms to a vector as a list of coefficients as shown below.

**Example:**

We can map \(s_1+2s_2+3s_3+12s_1 s_2+13s_1 s_3+14s_2 s_4\) to the following list and matrix.

*Linear*

*Quadratic*

In this matrix, coefficient \(J_{i,j}\) in matrix position \((i,j)\).

## Equivalence of QUBO and Ising¶

The Ising and QUBO models are mathematically equivalent — we can translate from one model to the other using a simple substitution.

**QUBO to Ising**

To translate a QUBO model to an Ising model, we use the following substitution.

*Example*

**Ising to QUBO**

To translate an Ising model to a QUBO model, we use the following substitution.

*Example*

### Exercise¶

Convert the following QUBO model to an Ising model.

Convert the following Ising model to a QUBO model.

## Summary of Key Points¶

- A BQM can contain constant, linear, and quadratic terms, and no higher-order terms.
- We define the coefficients and constant in the expression.
- The solution is the value of each binary variable that minimizes the expression.