greedy_router#
- iqm.qaoa.transpiler.sparse.greedy_router.greedy_router(problem_bqm, qpu, max_iter_color_pairs=1, key_best_route=None)[source]#
The function which takes a problem BQM
problem_bqmand a QPUqpuand returns a routing.This serves as a ‘wrapper’ for the entire greedy routing algorithm. For details of the algorithm, see [7].
- Parameters:
problem_bqm (BinaryQuadraticModel) – The
BinaryQuadraticModelof the problem we’re trying to solve.qpu (QPU) – The
QPUthat we’re going to solve the problem on.max_iter_color_pairs (int) – How many different starting color pairs (sorted by size) should be iterated over.
key_best_route (Callable[[Routing], SupportsLessThan] | None) – The key to determine which routing is the best if
max_iter_color_pairsis greater than 1. This should be a function that takesiqm.qaoa.transpiler.routing.Routingon input and returns something comparable (typically afloator anint). It is assumed that thiskeyis minimized. The default islambda o: len(o.layers), i.e., the routing with the minimal number of layers. Another recommended option islambda o: o.count_swap_gates().
- Returns:
A routing object containing all the swap and interaction layers needed to execute one QAOA layer.
- Return type: