qiskit/tools/apps/optimization.py
def trial_circuit_ry(n, m, theta, entangler_map, meas_string=None,
                     measurement=True):
    """Creates a QuantumCircuit object ocnsisting in layers of
    parametrized single-qubit Y rotations and CZ two-qubit gates

    Args:
        n (int): number of qubits
        m (int): depth of the circuit
        theta (array[float]): angles that parametrize the Y rotations
        entangler_map (dict): CZ connectivity, e.g. {0: [1], 1: [2]}
        meas_string (str): measure a given Pauli operator at the end of the
            circuit
        measurement (bool): whether to measure the qubit (register "q")
            on classical bits (register "c")
    Returns:
        QuantumCircuit: A QuantumCircuit object
    """
    q = QuantumRegister(n, "q")
    c = ClassicalRegister(n, "c")
    trial_circuit = QuantumCircuit(q, c)
    trial_circuit.h(q)
    if meas_string is None:
        meas_string = [None for x in range(n)]
    for i in range(m):
        trial_circuit.barrier(q)
        for node in entangler_map:
            for j in entangler_map[node]:
                trial_circuit.cz(q[node], q[j])
        for j in range(n):
            trial_circuit.ry(theta[n * i + j], q[j])
    trial_circuit.barrier(q)
    for j in range(n):
        if meas_string[j] == 'X':
            trial_circuit.h(q[j])
        elif meas_string[j] == 'Y':
            trial_circuit.s(q[j]).inverse()
            trial_circuit.h(q[j])
    if measurement:
        for j in range(n):
            trial_circuit.measure(q[j], c[j])
    return trial_circuit
Creates a QuantumCircuit object ocnsisting in layers of
    parametrized single-qubit Y rotations and CZ two-qubit gates

    Args:
        n (int): number of qubits
        m (int): depth of the circuit
        theta (array[float]): angles that parametrize the Y rotations
        entangler_map (dict): CZ connectivity, e.g. {0: [1], 1: [2]}
        meas_string (str): measure a given Pauli operator at the end of the
            circuit
        measurement (bool): whether to measure the qubit (register "q")
            on classical bits (register "c")
    Returns:
        QuantumCircuit: A QuantumCircuit object
    
Creates a QuantumCircuit object ocnsisting in layers of
parametrized single-qubit Y rotations and CZ two-qubit gates
Creates a QuantumCircuit object ocnsisting in layers of parametrized single - qubit Y rotations and CZ two - qubit gates
def trial_circuit_ry(n, m, theta, entangler_map, meas_string=None,
                     measurement=True):
    q = QuantumRegister(n, "q")
    c = ClassicalRegister(n, "c")
    trial_circuit = QuantumCircuit(q, c)
    trial_circuit.h(q)
    if meas_string is None:
        meas_string = [None for x in range(n)]
    for i in range(m):
        trial_circuit.barrier(q)
        for node in entangler_map:
            for j in entangler_map[node]:
                trial_circuit.cz(q[node], q[j])
        for j in range(n):
            trial_circuit.ry(theta[n * i + j], q[j])
    trial_circuit.barrier(q)
    for j in range(n):
        if meas_string[j] == 'X':
            trial_circuit.h(q[j])
        elif meas_string[j] == 'Y':
            trial_circuit.s(q[j]).inverse()
            trial_circuit.h(q[j])
    if measurement:
        for j in range(n):
            trial_circuit.measure(q[j], c[j])
    return trial_circuit
def trial_circuit_ry ( n , m , theta , entangler_map , meas_string = None , measurement = True ) : q = QuantumRegister ( n , "q" ) c = ClassicalRegister ( n , "c" ) trial_circuit = QuantumCircuit ( q , c ) trial_circuit . h ( q ) if meas_string is None : meas_string = [ None for x in range ( n ) ] for i in range ( m ) : trial_circuit . barrier ( q ) for node in entangler_map : for j in entangler_map [ node ] : trial_circuit . cz ( q [ node ] , q [ j ] ) for j in range ( n ) : trial_circuit . ry ( theta [ n * i + j ] , q [ j ] ) trial_circuit . barrier ( q ) for j in range ( n ) : if meas_string [ j ] == 'X' : trial_circuit . h ( q [ j ] ) elif meas_string [ j ] == 'Y' : trial_circuit . s ( q [ j ] ) . inverse ( ) trial_circuit . h ( q [ j ] ) if measurement : for j in range ( n ) : trial_circuit . measure ( q [ j ] , c [ j ] ) return trial_circuit
Creates a QuantumCircuit object ocnsisting in layers of
parametrized single-qubit Y rotations and CZ two-qubit gates
Creates a QuantumCircuit object ocnsisting in layers of parametrized single - qubit Y rotations and CZ two - qubit gates
"""Creates a QuantumCircuit object ocnsisting in layers of
    parametrized single-qubit Y rotations and CZ two-qubit gates

    Args:
        n (int): number of qubits
        m (int): depth of the circuit
        theta (array[float]): angles that parametrize the Y rotations
        entangler_map (dict): CZ connectivity, e.g. {0: [1], 1: [2]}
        meas_string (str): measure a given Pauli operator at the end of the
            circuit
        measurement (bool): whether to measure the qubit (register "q")
            on classical bits (register "c")
    Returns:
        QuantumCircuit: A QuantumCircuit object
    """
A QuantumCircuit object
A QuantumCircuit object
QuantumCircuit
n
number of qubits
number of qubits
m
depth of the circuit
depth of the circuit
theta
angles that parametrize the Y rotations
angles that parametrize the Y rotations
entangler_map
CZ connectivity, e.g.
CZ connectivity e . g .
meas_string
measure a given Pauli operator at the end of the
circuit
measure a given Pauli operator at the end of the circuit
measurement
whether to measure the qubit (register "q")
on classical bits (register "c")
whether to measure the qubit ( register " q " ) on classical bits ( register " c " )