TreeQAOA#
- class iqm.qaoa.tree_qaoa.TreeQAOA(problem, num_layers, *, betas=None, gammas=None, initial_angles=None)[source]#
Bases:
QUBOQAOAThe class for tree QAOA with QUBO cost function.
The class inherits everything from
QUBOQAOA, but adds one more methodset_tree_angles(), which setsanglesaccording to the tree schedule. The tree schedule uses QAOA angles precalculated numerically for a class of high-girth regular graph problems with uniform Hamiltonian. For more details see [7].- Parameters:
problem (QUBOInstance | ConstrainedQuadraticInstance) – A
QUBOInstanceobject 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] | ndarray | None) – An optional list of the initial beta angles of QAOA. Has to be provided together with
gammas.gammas (Sequence[float] | ndarray | None) – An optional list of the initial gamma angles of QAOA. Has to be provided together with
betas.initial_angles (Sequence[float] | ndarray | None) – An optional list of the initial QAOA angles as one variable. Shouldn’t be provided together with either
betasorgammas.
Attributes
Methods
A method for setting
iqm.qaoa.generic_qaoa.QAOA.anglesaccording to the tree schedule.- set_tree_angles()[source]#
A method for setting
iqm.qaoa.generic_qaoa.QAOA.anglesaccording to the tree schedule.The tree schedule is designed for problems with uniform 1-body local field, unit 2-body interactions and uniform node degree. Therefore, when given a generic problem, the algorithm first calculates the average degree
d_av, the average local fieldh_avand the average interaction strengthj_av(which is used to renormalize the local field). The angles are then looked up in the saved files for the nearest implemented degree and local field. For \(p > 6\) QAOA, the angles are interpolated from the calculated angles for \(p = 6\). The method doesn’t output anything, but it modifiesiqm.qaoa.generic_qaoa.QAOA.anglesin-place.- Raises:
ValueError – If the Hamiltonian contains ferromagnetic (i.e., negative) interactions between qubits. The tree schedule shouldn’t be used for such cases.
- Return type:
None