solve_qaoa

fireopal.solve_qaoa(problem, credentials, problem_type=None, backend_name=None, run_options=None)

Run a hybrid quantum-classical QAOA solver that iterates between quantum circuit execution and classical parameter optimization until convergence.

For a detailed description of the methods used, see: Sachdeva et al. (2024).

Parameters

  • problem (Expr or nx.Graph) –

    The optimization problem to solve. Accepts two forms:

    • nx.Graph: A graph over binary node variables. Requires problem_type to be set to "maxcut".
    • sympy.Expr: A polynomial cost function with binary variables to minimize. Must contain at least one nonlinear (quadratic or higher-degree) term; purely linear problems are rejected (see Raises).
    • credentials (Credentials) – The credentials for running circuits on an IBM or IonQ backend. Use either make_credentials_for_ibm_cloud or make_credentials_for_ionq from the credentials module to generate properly formatted credentials.
    • problem_type (str , optional) – The class of graph problem to solve. Only used when problem is an nx.Graph; currently only "maxcut" is supported. Ignored for all other problem types.
    • backend_name (str , optional) – The backend device that should be used to run circuits. Defaults to None.
    • run_options (RunOptions or None , optional) – Additional options for circuit execution. See the run_options module for classes to store run options for your desired provider. Defaults to None.

Returns

FireOpalJob – A job object containing results and warnings from the execution. The results have the following keys:

solution_bitstring (str) : The solution bitstring with the best cost found, across all iterations.

solution_bitstring_cost (float) : The cost of the solution bitstring.

final_bitstring_distribution (dict[str, int]) : The bitstring counts dictionary associated with the minimum cost across all iterations.

iteration_count (int) : The total number of QAOA iterations performed by the optimizer.

variables_to_bitstring_index_map (dict[str, int]) : The mapping from the variables to the equivalent bit in the bitstring.

best_parameters (list[float]) : The optimized beta and gamma parameters across all iterations.

warnings (list[str]) : The warnings produced while compiling or running QAOA.

Raises

  • QctrlArgumentsValueError – If the problem polynomial has only degree-1 (linear) terms. Linear problems have trivially classical solutions and do not require quantum resources.
  • QctrlArgumentsValueError – If problem is an nx.Graph with fewer than 2 nodes.
  • QctrlArgumentsValueError – If problem is an nx.Graph and problem_type is not provided.

Was this useful?