View on GitHub
Open this notebook in GitHub to run it yourself
- Define problem classically with pyomo
- We have a limited number of antennas defined by .
- We have a set of potential locations: , where
- We limit certain locations with an overlap, not to use 2 antennas.
Mathematical definition
Each location is a binary variable that is 1 if we put antenna there and 0 if we don’t put in that location. Each location is charachterized with certain consumption . Mathematically, it is translated into objective function which aims to maximized its coverage: Now, we add the constraints, such as the number of antennas: We can also add a constraint that prevent an ovelap between antennas. All sets of neighboring antenna sites will have only 1 anntenna on the ground:Defining Pyomo model
Define QAOA parameters and synthesize
In order to solve the Pyomo model defined above, we use the Classiq combinatorial optimization engine. For the quantum part of the QAOA algorithm (QAOAConfig) - define the number of repetitions (num_layers) and the penalty_energy to get results that satisfy your constraints. Be careful! large enrgy also can bring you away from the optimized solution:
Output:
Output:
Executing the hybrid algorithm
We now solve the problem using the generated circuit by using the execute method:
Analyze results
We can also examine the statistics of the algorithm:| probability | cost | solution | count | |
|---|---|---|---|---|
| 916 | 0.000333 | 5.117951 | [0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1] | 1 |
| 562 | 0.000333 | 2.448870 | [0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1] | 1 |
| 1519 | 0.000333 | 2.197017 | [0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0] | 1 |
| 342 | 0.000333 | 2.016968 | [0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1] | 1 |
| 708 | 0.000333 | 1.991353 | [0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1] | 1 |
Output:
