View on GitHub
Open this notebook in GitHub to run it yourself
Building the Problem
Output:

Output:
Solving with Classiq
Take the specific example outlined above.Generating Parameters for the Quantum Circuit
Synthesizing the QAOA Circuit and Solving the Problem
Synthesize and view the QAOA circuit (ansatz) used to solve the optimization problem:Output:
Output:
optimize method of the CombinatorialProblem object.
For the classical optimization part of QAOA, define the maximum number of classical iterations (maxiter) and the -parameter (quantile) for running CVaR-QAOA, an improved variation of the QAOA algorithm [3]:
Output:

Best Solution Statistics
Compare the optimized results to uniformly sampled results:

Best Solution
Output:
Output:
| B1 | B2 | B3 | B4 | |
|---|---|---|---|---|
| A1 | 0 | 1 | 0 | 0 |
| A2 | 1 | 0 | 0 | 1 |
| A3 | 0 | 0 | 1 | 0 |

Comparing to a Classical Solver
Output:
Output:
| B1 | B2 | B3 | B4 | |
|---|---|---|---|---|
| A1 | 1.000000 | 0.000000 | 0.000000 | 0.000000 |
| A2 | 0.000000 | 1.000000 | 0.000000 | 1.000000 |
| A3 | 0.000000 | -0.000000 | 1.000000 | 0.000000 |
