greedy_router

Contents

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_bqm and a QPU qpu and 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 BinaryQuadraticModel of the problem we’re trying to solve.

  • qpu (QPU) – The QPU that 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_pairs is greater than 1. This should be a function that takes iqm.qaoa.transpiler.routing.Routing on input and returns something comparable (typically a float or an int). It is assumed that this key is minimized. The default is lambda o: len(o.layers), i.e., the routing with the minimal number of layers. Another recommended option is lambda o: o.count_swap_gates().

Returns:

A routing object containing all the swap and interaction layers needed to execute one QAOA layer.

Return type:

Routing