QUBOQAOA#

Module: iqm.qaoa.qubo_qaoa

class iqm.qaoa.qubo_qaoa.QUBOQAOA(problem, num_layers, *, betas=None, gammas=None, initial_angles=None)[source]#

Bases: QAOA[QUBOInstance | ConstrainedQuadraticInstance]

The class for QAOA with quadratic unconstrained binary (QUBO) cost function.

The class inherits a lot of functionality from its parent iqm.qaoa.generic_qaoa.QAOA. One new addition is the attribute hamiltonian_bqm which stores the coefficient of the problem Hamiltonian.

Parameters:
  • problem (QUBOInstance | ConstrainedQuadraticInstance) – A QUBOInstance object describing the QUBO problem to be solved.

  • num_layers (int) – The number of QAOA layers, commonly referred to as p in the literature.

  • betas (Sequence[float] | np.ndarray | None) – An optional list of the initial beta angles of QAOA. Has to be provided together with gammas.

  • gammas (Sequence[float] | np.ndarray | None) – An optional list of the initial gamma angles of QAOA. Has to be provided together with betas.

  • initial_angles (Sequence[float] | np.ndarray | None) – An optional list of the initial QAOA angles as one variable. Shouldn’t be provided together with either betas or gammas. The gamma and beta angles are interleaved, so that the first pair of entries corresponds to \(\gamma_1\) and \(\beta_1\) (the angles of the first QAOA layer). The second pair of entries corresponds to \(\gamma_2\) and \(\beta_2\), etc. …

Attributes

hamiltonian_bqm

The BQM representation of the problem, taken from the input QUBOInstance.

hamiltonian_graph

The graph whose edges / nodes have weights bias equal to the coefficients in the problem Hamiltonian.

interactions

Returns an upper-triangular matrix of the ZZ interactions between the variables.

local_fields

Returns a ndarray of the local fields of the model (Z coefficients).

Methods

property hamiltonian_bqm: BinaryQuadraticModel#

The BQM representation of the problem, taken from the input QUBOInstance.

property hamiltonian_graph: Graph#

The graph whose edges / nodes have weights bias equal to the coefficients in the problem Hamiltonian.

property interactions: ndarray#

Returns an upper-triangular matrix of the ZZ interactions between the variables.

If the Hamiltonian representing the problem is

\[H = \sum_{i<j} J_{ij} Z_i Z_j + \sum_i h_i Z_i\]

then this method outputs \(J_{ij}\) as upper-triangular square matrix ndarray. Note that these are different from the off-diagonal elements of qubo_matrix of the input problem because the QUBO cost function has different coefficients than the Hamiltonian.

property local_fields: ndarray#

Returns a ndarray of the local fields of the model (Z coefficients).

If the Hamiltonian representing the problem is

\[H = \sum_{i<j} J_{ij} Z_i Z_j + \sum_i h_i Z_i\]

then this method outputs \(h_{i}\) as 1-dimensional ndarray. Note that these are different from the diagonal elements of qubo_matrix of the input problem because the QUBO cost function has different coefficients than the Hamiltonian.

Inheritance

Inheritance diagram of iqm.qaoa.qubo_qaoa.QUBOQAOA