コード例 #1
0
def _get_qaoa_circuits_to_compile(graph_type,
                                  graph_N,
                                  graph_p,
                                  blockings,
                                  sampling_rate=None):
    assert graph_p in [1, 2, 3, 4, 5, 6, 7, 8], 'we only did p = 1...8'
    set_seeds()
    circuit = get_qaoa_circuit(graph_N, graph_p, graph_type)
    circuit = optimize_circuit(circuit)
    coupling_list = get_nearest_neighbor_coupling_list(2, int(graph_N / 2))
    circuit = optimize_circuit(circuit, coupling_list)
    slice_circuits_list = _get_slice_circuits_list(circuit, blockings)
    return _get_circuits_to_compile(slice_circuits_list,
                                    sampling_rate=sampling_rate)
コード例 #2
0
                   use_gpu=False,
                   sparse_H=False,
                   method='Adam',
                   maxA=maxA,
                   show_plots=False,
                   file_name=file_name,
                   data_path=data_path)
        if SS.l < SS.conv.conv_target:  # if converged, search lower half
            max_steps = mid_steps
        else:
            min_steps = mid_steps

    return mid_steps / 20


qaoa_circuit = qaoa.get_qaoa_circuit(graph_N, graph_p, 'ErdosRenyi')
qaoa_circuit = util.circuitutil.optimize_circuit(qaoa_circuit)
coupling_list = util.circuitutil.get_nearest_neighbor_coupling_list(
    2, int(graph_N / 2))
qaoa_circuit = util.circuitutil.optimize_circuit(qaoa_circuit, coupling_list)

from qiskit import QuantumCircuit, QuantumRegister
from copy import deepcopy


def indices(gate):
    return [qarg[1] for qarg in gate.qargs]


def gate_block_index(gate, blocking):
    if len(indices(gate)) == 1:
コード例 #3
0
                   use_gpu=False,
                   sparse_H=False,
                   method='Adam',
                   maxA=maxA,
                   show_plots=False,
                   file_name=file_name,
                   data_path=data_path)
        if SS.l < SS.conv.conv_target:  # if converged, search lower half
            max_steps = mid_steps
        else:
            min_steps = mid_steps

    return mid_steps / 20


qaoa_circuit = qaoa.get_qaoa_circuit(graph_N, graph_p, '3Reg')
qaoa_circuit = util.circuitutil.optimize_circuit(qaoa_circuit)
coupling_list = util.circuitutil.get_nearest_neighbor_coupling_list(
    2, int(graph_N / 2))
qaoa_circuit = util.circuitutil.optimize_circuit(qaoa_circuit, coupling_list)

from qiskit import QuantumCircuit, QuantumRegister
from copy import deepcopy


def indices(gate):
    return [qarg[1] for qarg in gate.qargs]


def gate_block_index(gate, blocking):
    if len(indices(gate)) == 1:
コード例 #4
0
ファイル: qaoa_exp.py プロジェクト: epiqc/PartialCompilation
    col = int(N / 2)
    d = 2  # this is the number of energy levels to consider (i.e. d-level qudits)
    max_iterations = (2**N) * 125
    decay = max_iterations / 2
    convergence = {
        'rate': 0.01,
        'max_iterations': max_iterations,
        'conv_target': 1e-3,
        'learning_rate_decay': decay,
        'min_grad': 1e-9,
        'update_step': 20
    }
    reg_coeffs = {}
    for p in range(1, 3):
        print("Running 3-regular graph N=%d, p=%d" % (N, p), flush=True)
        circuit = qaoa.get_qaoa_circuit(N, p, '3Reg')
        # TODO: average over 10 graphs
        U = util.circuitutil.get_unitary(circuit)
        connected_qubit_pairs = util.get_nearest_neighbor_coupling_list(
            row, col, directed=False)
        H0 = hamiltonian.get_H0(N, d)
        Hops, Hnames = hamiltonian.get_Hops_and_Hnames(N, d,
                                                       connected_qubit_pairs)
        states_concerned_list = hamiltonian.get_full_states_concerned_list(
            N, d)
        maxA = hamiltonian.get_maxA(N, d, connected_qubit_pairs)
        shortest_time = binary_search_for_shortest_pulse_time(
            10, int(90 * (N / 5) * p), convergence, reg_coeffs)
        full_times.append(shortest_time)

print(full_times, flush=True)