Angle Precomputation

Tasks

class AnglePrecomputationTask(dataset_id: str, generation_task: Union[recirq.qaoa.experiments.problem_generation_tasks.HardwareGridProblemGenerationTask, recirq.qaoa.experiments.problem_generation_tasks.SKProblemGenerationTask, recirq.qaoa.experiments.problem_generation_tasks.ThreeRegularProblemGenerationTask], p: int)

Pre-compute optimized angles classically for a given problem.

dataset_id

A unique identifier for this dataset.

generation_task

The input task which specifies the problem.

p

QAOA depth hyperparameter p. The number of parameters is 2*p.

Task execution functions

precompute_angles(task: recirq.qaoa.experiments.angle_precomputation_tasks.AnglePrecomputationTask, base_dir=None, problem_generation_base_dir=None)

Execute a AnglePrecomputationTask() task.

Library Functions

optimize_instance_interp_heuristic(graph: networkx.classes.graph.Graph, p_max: int = 10, param_guess_at_p1=None, node_to_index_map=None, dtype=<class 'numpy.complex128'>, verbose=False)

Given a graph, find QAOA parameters that minimizes C=sum_{<ij>} w_{ij} Z_i Z_j

Uses the interpolation-based heuristic from arXiv:1812.01041

Parameters
  • graph – The problem.

  • p_max – Optimize each p up to this value.

  • param_guess_at_p1 – Initial angles at p=1. If None, try 10 initial parameter guesses and keep the best one. The first guess will be beta=gamma=pi/8. The following guesses will be random.

  • node_to_index_map – dictionary that maps nodes to 0-based integer indices (optional, default None, which means use mapping based on iteration)

  • dtype – The numpy datatype used during construction of the Hamiltonian matrix.

  • verbose – Whether to print out status updates.

Returns

A list of OptimizationResult

class OptimizationResult(p: int, f_val: float, gammas: numpy.ndarray, betas: numpy.ndarray, min_c: float, max_c: float)

The result of a classical angle optimization for QAOA.

You may want to use optimize_instance_interp_heuristic().

p

QAOA depth hyperparameter p. The number of parameters is 2*p.

f_val

The value of the <C> at the optimal angles

gammas

An array of p gamma angles

betas

An array of p beta angles

min_c

The minimum value of C over all bitstrings

max_c

The maximum value of C over all bitstrings