diff --git a/choosing_boxes_problem/index.html b/choosing_boxes_problem/index.html deleted file mode 100644 index 87a2fc5..0000000 --- a/choosing_boxes_problem/index.html +++ /dev/null @@ -1,363 +0,0 @@ - - - - - - - README - - - - - -
-

-
-
-
- - - -
-

1 Choosing Boxes

-

1.1 Problem

-

The problem “Choosing Boxes” is described in the D-Wave problem formulation guide in chapt. 4.4.

-
-

Choosing Boxes Problem Example

-

1.2 Example: Choosing Boxes

-

We’re given three boxes with different weights. We want to choose the two boxes with the smallest sum.

- - - - - - - - - - - - - - - - - -
Box 1Box 2Box 3
Weight152025
-

This is a simple problem – we know that the answer is to choose boxes 15 and 20. But how do we phrase this problem as a BQM?

-

1.2.1 Step 1: Write Objective and Constraints

-

Objective: We are looking for the smallest sum, so our objective is “minimize the sum of the boxes chosen”.
-Constraint: We are allowed to choose two boxes, so our constraint is “choose exactly two boxes”.

-

1.2.2 Step 2: Convert Objective and Constraints into Binary Math Expressions

-

Binary Variables. First, we need to define our binary variables. The answer that we are looking for is which boxes we should choose. For each box, we can ask “do we choose this box?”. This points us to how we should define our binary variables.

- - - - - - - - - - - - - - - - - - - - -
Use Box iDon’t use Box i
QUBO\(x_i = 1\)\(x_i = 0\)
Ising\(s_i = +1\)\(s_i = −1\)
-

Once we have defined our binary variables, we can convert our objective and constraint into math expressions.

-

Objective. We consider our objective for both QUBO and Ising forms.

-

QUBO: To figure out the sum of the boxes that are chosen, we can use a weighted sum: \(15x_1 + 20x_2 + 25x_3\). In this sum, the boxes that are chosen will have \(x_i = 1\) and the boxes that are not chosen will have \(x_i = 0\). In other words, the value of boxes that are not chosen will be multiplied by zero and so we will only be adding up the value of the boxes that are chosen. Our objective function becomes:

-

\[ -min(15x_1 + 20x_2 + 25x_3) -\]

-

Ising: Using our binary variables, we can convert our +1/-1 to 1/0 using the Ising to QUBO translation shown earlier, which maps +1 7→ 1 and −1 7→ 0. Our objective function can then be written as:

-

\[ -min \left ( - 15 \left ( \frac{s_1 + 1}{2} \right ) + - 20 \left ( \frac{s_2 + 1}{2} \right ) + - 25 \left ( \frac{s_3 + 1}{2} \right ) -\right ) -\]

-

Constraint. We consider our constraint for both QUBO and Ising forms.

-

QUBO: Our constraint “choose exactly two boxes” means that we need exactly two of our binary variables to have value 1, and the remaining binary variable will have value 0. In other words, our constraint can be written as:

-

\[x_1 + x_2 + x_3 = 2\]

-

Ising: Our constraint “choose exactly two boxes” means that we need exactly two of our binary variables to have value +1, and the remaining binary variable will have value -1. In other words, our constraint can be written as:

-

\[s_1 + s_2 + s_3 = 1\]

-

1.2.3 Step 3: Transform Math Expressions into a BQM

-

Our objective function is fine as written, so we only need to modify our constraint.

-

QUBO: To modify our constraint, we need to use the method for equalities. Original constraint: \[x_1 + x_2 + x_3 = 2\] Move everything to one side: \[x_1 + x_2 + x_3 − 2 = 0\] Square the expression: \[(x_1 + x_2 + x_3 − 2)^2\]

-

Ising: Following the same method, we can rewrite our constraint as follows. \[(s_1 + s_2 + s_3 − 1)^2\]

-

1.2.4 Step 4: Combine Expressions

-

Now that we have written our objective and constraint in BQM form, we can combine them together to make our final model using addition and adding in a Lagrange parameter. Both of these can be expanded and simplified to prepare for input to an Ocean python program.

-

QUBO: \[ -min \left ( - (15 x_1 + 20 x_2 + 25 x_3) + - γ (x_1 + x_2 + x_3 − 2)^2 -\right ) -\]

-

Ising:

-

\[ -min \left ( - 15 \left ( \frac{s_1 + 1}{2} \right ) + - 20 \left ( \frac{s_2 + 1}{2} \right ) + - 25 \left ( \frac{s_3 + 1}{2} \right ) + - γ (s_1 + s_2 + s_3 − 1)^2 -\right ) -\]

-
-

Also see: https://github.com/dwave-training/choosing-boxes

-

1.3 Code

-

The code for the problem is in choosing_boxes.ipynb which can be viewed at nbviewer.org or opened in the D-Wave Leap IDE

-

1.4 Visualization

-

The eigenspectrum and eigenvector for this problem are visualized for different Lagrange multipliers γ:

- -------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50 steps100 steps200 steps
Choose 2 out of 3Annealing Schedule starting
at 0 and ending at 0
Eigenspectrumlinklinklink
Eigenvectorslinklinklink
Annealing Schedule starting
above 0 and ending at 0 (like D-Wave)
Eigenspectrumlinklinklink
Eigenvectorslinklinklink
Choose 1 out of 2Annealing Schedule starting
at 0 and ending at 0
Eigenspectrumlinklinklink
Eigenvectorslinklinklink
Annealing Schedule starting
above 0 and ending at 0 (like D-Wave)
Eigenspectrumlinklinklink
Eigenvectorslinklinklink
Choose 2 out of 4Annealing Schedule starting
at 0 and ending at 0
Eigenspectrumlinklinklink
Eigenvectorslinklinklink
Annealing Schedule starting
above 0 and ending at 0 (like D-Wave)
Eigenspectrumlinklinklink
Eigenvectorslinklinklink
-

Old Plots:

- -

1.5 Sitemap Markdowns

- -

1.6 Sitemap HTMLs

- -
- - - - diff --git a/index.html b/index.html deleted file mode 100644 index 2954762..0000000 --- a/index.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - README - - - - - -
-

-
-
-
- - - -
-

1 QuantumAnnealingPlayground

-

1.1 Contents

- -

1.2 Sitemap Markdowns

- -

1.3 Sitemap HTMLs

- -
- - - -