# Summary of Exercises with Solutions¶

Below you will find solutions to the exercises included in this “Learn to Formulate Problems” guide. For further discussion of these solutions, please visit our community forum in Leap.

## Introduction¶

Split the following problem into an objective and constraints.

A business is trying to figure out the best way to pack a box full of items. There are five items, with values 1, 5, 3, 4, and 2 dollars. These items have weights 2, 4, 4, 1, and 3 lbs, respectively. The contents of the box must weigh exactly 6 lbs. What is the best way to pack the box so that the box has the highest total value?

*Solution*

This problem can be split into an objective and constraints as follows.

**Objective**

- Maximize total value

**Constraint**

- Total weight of contents is exactly 6 lbs

## Definitions¶

### QUBO¶

Put the following QUBO into matrix form.

*Solution*

### Ising¶

Put the following Ising model into matrix form.

*Solution*

Linear

Quadratic

### Converting Between QUBO and Ising¶

QUBO to Ising:

Ising to QUBO:

## Small Problems with Two Variables¶

**QUBO:**

What is the QUBO model for the constraint \(x_1 \geq x_2\)?

*Solution*

**Ising:**

What is the Ising model for the constraint \(s_1 \geq s_2\)?

*Solution*

## Problems with Multiple Constraints¶

Write a BQM for the following problem.

A business is trying to figure out the best way to pack a box full of items. There are five items, with values 1, 5, 3, 4, and 2 dollars. These items have weights 2, 4, 4, 1, and 3 lbs, respectively. The contents of the box must weigh exactly 6 lbs. What is the best way to pack the box so that the box has the highest total value?

*Solution*

**QUBO:**

**Ising:**