Use this file to discover all available pages before exploring further.
View on GitHub
Open this notebook in GitHub to run it yourself
Radio Access Network (RAN) is an important part of network communication systems, responsible for connecting used devices such as smartphones and radio machines to a wireless network.Optimizing the Radio Access Network involves various tasks that make it challenging to optimize a network efficiently.These tasks include resource allocation, locating transmission devices, such as antennas, to enhance coverage according to the overall consumption. Ideally, the optimization of a RAN will maximize the resource utilization of the network, save operational costs to the owner of the network.In this case of RAN, the solution is the positions of the set of antennas we have in a region that that has consumers spread in various locations.Finding good positions of antennas with a limited number of antennas is very complex to optimize and find a good solution in polynomial time.
Each location is a binary variable xi 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 ci.Mathematically, it is translated into objective function which aims to maximized its coverage:xmaxi∑cixiNow, we add the constraints, such as the number of antennas:i∑xi≤NWe can also add a constraint that prevent an ovelap between antennas.All sets of neighboring antenna sites {n0,n1,...,nk} will have only 1 anntenna on the ground:i∑kxni==1
# Import relevant packagesimport matplotlib.pyplot as pltimport networkx as nx # noqaimport numpy as npimport pandas as pdimport pyomo.environ as pyo# potenital locationsM = 13# number of antennasN = 7# consumption coefficientc_vec = np.random.rand(1, M)[0]neighbors1 = [1, 3, 4]neighbors2 = [0, 5]neighbors3 = [6, 9]
model = pyo.ConcreteModel()# define the variablesmodel.x = pyo.Var(range(M), domain=pyo.Binary)x_variables = np.array(list(model.x.values()))# constriantsmodel.num_antennas = pyo.Constraint(expr=sum(x_variables[i] for i in range(M)) <= N)model.neigh1 = pyo.Constraint(expr=sum(x_variables[i] for i in neighbors1) == 1)model.neigh2 = pyo.Constraint(expr=sum(x_variables[i] for i in neighbors2) == 1)model.neigh3 = pyo.Constraint(expr=sum(x_variables[i] for i in neighbors3) == 1)model.obj = pyo.Objective(expr=x_variables @ c_vec, sense=pyo.maximize)
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:
We can now synthesize and view the QAOA circuit (ansatz) used to solve the optimization problem:
from classiq import show, synthesizeqprog = synthesize(qmod)show(qprog)
Output:
Exception in callback Task.__step() handle: <Handle Task.__step()> Traceback (most recent call last): File "/Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self._args) RuntimeError: cannot enter context: <_contextvars.Context object at 0x1082b9340> is already entered Exception in callback Task.__step() handle: <Handle Task.__step()> Traceback (most recent call last): File "/Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self._args) RuntimeError: cannot enter context: <_contextvars.Context object at 0x1082b9340> is already entered Exception in callback Task.__step() handle: <Handle Task.__step()> Traceback (most recent call last): File "/Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self._args) RuntimeError: cannot enter context: <_contextvars.Context object at 0x1082b9340> is already entered Exception in callback Task.__step() handle: <Handle Task.__step()> Traceback (most recent call last): File "/Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self._args) RuntimeError: cannot enter context: <_contextvars.Context object at 0x1082b9340> is already entered Exception in callback Task.__step() handle: <Handle Task.__step()> Traceback (most recent call last): File "/Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self._args) RuntimeError: cannot enter context: <_contextvars.Context object at 0x1082b9340> is already entered Task was destroyed but it is pending! task: <Task pending name='Task-13' coro=<_async_in_context.<locals>.run_in_context() done, defined at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/utils.py:57> wait_for=<Task pending name='Task-14' coro=<Kernel.shell_main() running at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/kernelbase.py:590> cb=[Task.__wakeup()]> cb=[ZMQStream._run_callback.<locals>._log_error() at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/zmq/eventloop/zmqstream.py:563]> /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/anyio/_core/_tasks.py:117: RuntimeWarning: coroutine 'Kernel.shell_main' was never awaited with get_async_backend().create_cancel_scope( RuntimeWarning: Enable tracemalloc to get the object allocation traceback Task was destroyed but it is pending! task: <Task pending name='Task-14' coro=<Kernel.shell_main() running at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/kernelbase.py:590> cb=[Task.__wakeup()]> Task was destroyed but it is pending! task: <Task pending name='Task-15' coro=<_async_in_context.<locals>.run_in_context() done, defined at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/utils.py:57> wait_for=<Task pending name='Task-16' coro=<Kernel.shell_main() running at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/kernelbase.py:590> cb=[Task.__wakeup()]> cb=[ZMQStream._run_callback.<locals>._log_error() at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/zmq/eventloop/zmqstream.py:563]> Task was destroyed but it is pending! task: <Task pending name='Task-16' coro=<Kernel.shell_main() running at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/kernelbase.py:590> cb=[Task.__wakeup()]> Task was destroyed but it is pending! task: <Task pending name='Task-17' coro=<_async_in_context.<locals>.run_in_context() done, defined at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/utils.py:57> wait_for=<Task pending name='Task-18' coro=<Kernel.shell_main() running at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/kernelbase.py:590> cb=[Task.__wakeup()]> cb=[ZMQStream._run_callback.<locals>._log_error() at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/zmq/eventloop/zmqstream.py:563]> Task was destroyed but it is pending! task: <Task pending name='Task-18' coro=<Kernel.shell_main() running at /Users/nadavyoran/.pyenv/versions/3.11.13/lib/python3.11/site-packages/ipykernel/kernelbase.py:590> cb=[Task.__wakeup()]>
Output:
Quantum program link: https://platform.classiq.io/circuit/36pyGdPoyltMPFVkjKVear2tfhr