prune_angles

Contents

prune_angles#

iqm.qaoa.tree_calculation.tree_calculation.prune_angles(layer, big_gamma, big_beta)#

The function to take the full array of Gamma / Beta angles and shorten them to those relevant for layer layer.

The arrays of Gamma / Beta angles are assumed to have the form described in equation (A8) in [7], that is \(\Gamma = (\gamma_1, ..., \gamma_p, 0, -\gamma_p, ..., -\gamma_1)\), where p is the total number of QAOA layers. This is pruned to only include angles relevant for QAOA layer layer and to remove the central 0. Note that only layer-1 Beta angles are relevant for layer layer.

Parameters:
  • layer (int) – Specifying up to which layer should the arrays of angles be trimmed.

  • big_gamma (ndarray[tuple[Any, ...], dtype[float64]]) – An array of the gamma QAOA angles (sorted ascedingly and descendingly in an array).

  • big_beta (ndarray[tuple[Any, ...], dtype[float64]]) – An array of the beta QAOA angles (sorted ascedingly and descendingly in an array).

Returns:

A tuple containing the pruned arrays of angles big_gamma and big_beta.

Raises:
  • ValueError – If the input layer is more than the number of QAOA layers.

  • ValueError – If the input layer is less than 1.

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]], ndarray[tuple[Any, …], dtype[float64]]]