View on GitHub
Open this notebook in GitHub to run it yourself
- Pre-requirments
- Define the Optimization Problem
- Create your Ising model
- Optimize Using to Quantum Optimization Algorithm
num_layers) and the number of iterations for the optimizer (maxiter).
get_qprog command and show it
Output:
Output:
optimize function:
Output:

- Present Quantum Results
sample method to get samples with the optimzied parameters. We hereby present the optimization results.
Since this is a quantum solution with probabilistic results, there is a defined probability for each result to be obtained by a measurement (presented by an histogram), where the solution is chosen to be the most probable one.
We remind that in the notation of the solution “0” indicate “-1” spin value, and “1” indicates “1” spin value.
| solution | probability | cost | |
|---|---|---|---|
| 0 | {‘z’: [0, 0, 0, 0, 0, 0]} | 0.745117 | -180.0 |
| 17 | {‘z’: [0, 1, 0, 0, 0, 0]} | 0.004883 | -100.0 |
| 16 | {‘z’: [0, 0, 1, 0, 0, 0]} | 0.004883 | -100.0 |
| 15 | {‘z’: [0, 0, 0, 0, 0, 1]} | 0.005371 | -100.0 |
| 13 | {‘z’: [1, 0, 0, 0, 0, 0]} | 0.007324 | -100.0 |

Output: