Skip to content

QAOA

A builder for the QAOA ansatz

Source code in q3as/algo/vqe.py
class QAOA:
    """
    A builder for the QAOA ansatz
    """

    def __init__(self, postprocess: _PostProcessCallable = None, **kwargs):
        """
        Create a new QAOA builder. Arguments are passed to the QAOAAnsatz constructor in the Qiskit circuit library.
        """
        self.postprocess = postprocess
        self.kwargs = kwargs

    def __call__(self, obs: ObservablesArray) -> QuantumCircuit:
        ansatz = QAOAAnsatz(_observables_to_pauli(obs), **self.kwargs)
        if self.postprocess is not None:
            ansatz = self.postprocess(ansatz)
        return ansatz

__init__(postprocess=None, **kwargs)

Create a new QAOA builder. Arguments are passed to the QAOAAnsatz constructor in the Qiskit circuit library.

Source code in q3as/algo/vqe.py
def __init__(self, postprocess: _PostProcessCallable = None, **kwargs):
    """
    Create a new QAOA builder. Arguments are passed to the QAOAAnsatz constructor in the Qiskit circuit library.
    """
    self.postprocess = postprocess
    self.kwargs = kwargs