Main Content

qaoaResult

Result of solving QUBO problem using QAOA

Since R2024b

    Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.

    Description

    The properties of the qaoaResult object provide information about the QAOA solution process for solving a QUBO problem. If you solve a QUBO problem using the solve function with Algorithm set to a qaoa object, then the resulting solution is a quboResult object that contains a qaoaResult object.

    Properties

    expand all

    This property is read-only.

    Solution point with the smallest objective function value, returned as a real vector. BestX corresponds to an entry in AllX with the smallest objective function value.

    This property is read-only.

    Smallest objective function value found, returned as a real scalar. BestFunctionValue is the smallest entry in AllFunctionValues.

    This property is read-only.

    Solutions returned when using QAOA, returned as a real matrix. Each column of the matrix represents one potential solution. The associated objective function value is in the corresponding entry of AllFunctionValues.

    This property is read-only.

    Objective function values returned when using QAOA, returned as a real vector. The objective function values correspond to the columns of AllX.

    This property is read-only.

    Circuit angle optimization results, returned as a structure containing the fields in this table.

    Field NameDescription
    AllProbabilitiesVector containing the probabilities of each unique solution being sampled from the circuit using the angles returned by the optimization solver, BestCircuitAngles
    BestCircuitAnglesArray of cost and mixer gate angles returned by the optimization solver
    BestExpectedValueBest expected value returned by the optimization solver
    Exitflagexitflag returned by the optimization solver
    Outputoutput structure returned by the optimization solver
    CircuitquantumCircuit object used in the optimization with angles set to BestCircuitAngles

    This property is read-only.

    Duration that the algorithm runs in seconds, returned as a real scalar. ClockTime is measured internally using tic and toc.

    Examples

    collapse all

    Create and solve a QUBO problem using QAOA.

    Q = [0 -1 2; ...
        -1 0 4; ...
        2 4 0];
    c = [-5 6 -4];
    d = 12;
    qprob = qubo(Q,c,d);
    result = solve(qprob,Algorithm=qaoa)
     
    Exiting: Maximum number of function evaluations has been exceeded
             - increase MaxFunEvals option.
             Current function value: -0.970000 
    
    result = 
      quboResult with properties:
    
                    BestX: [3×1 double]
        BestFunctionValue: 7
          AlgorithmResult: [1×1 qaoaResult]
    
    

    Examine the algorithm-specific result details.

    result.AlgorithmResult
    ans = 
      qaoaResult with properties:
    
                       BestX: [3×1 double]
           BestFunctionValue: 7
                        AllX: [3×8 double]
           AllFunctionValues: [12 8 18 22 7 7 11 19]
        AlgorithmInformation: [1×1 struct]
                   ClockTime: 0.7632
    
    

    Examine the details of the circuit angle optimization.

    result.AlgorithmResult.AlgorithmInformation
    ans = struct with fields:
         AllProbabilities: [0.2279 0.1630 0.1234 0.1091 0.0105 0.1296 0.2094 0.0271]
        BestCircuitAngles: [2×1 double]
        BestExpectedValue: -0.9700
                 Exitflag: 0
                   Output: [1×1 struct]
                  Circuit: [1×1 quantumCircuit]
    
    

    Algorithms

    QAOA is a quantum-classical hybrid approach to solving optimization problems. In general, a quantum circuit represents possible solutions to the problem and a classical optimizer iteratively adjusts the angles in the circuit to improve the quality of the solution. The quantum circuit uses alternating layers of cost and mixer gates to approximately solve the provided problem. For details, see Solve Max-Cut Problem Using QAOA.

    References

    [1] Farhi, Edward, Jeffrey Goldstone, and Sam Gutmann. “A Quantum Approximate Optimization Algorithm.” arXiv, November 14, 2014. https://doi.org/10.48550/arXiv.1411.4028.

    Version History

    Introduced in R2024b