def generate_full_layer_circuit(n_qubits): circuit = QubitCircuit(n_qubits) for i in range(int(n_qubits / 2)): circuit.cnot(i * 2, (i * 2) + 1) return circuit
def generate_full_layer_circuit(n_qubits): """ Generates a Circuit object (in our framework) with all pairs interactions :param n_qubits: number of qubits :return: QubitCircuit, a circuit with all pairs interactions """ circuit = QubitCircuit(n_qubits) for i in range(int(n_qubits / 2)): circuit.cnot(i * 2, (i * 2) + 1) return circuit
def generate_completely_random_circuit(n_qubits, n_gates): circuit = QubitCircuit(n_qubits) for _ in range(n_gates): q1 = random.randint(0, n_qubits - 1) q2 = random.randint(0, n_qubits - 1) while q1 == q2: q1 = random.randint(0, n_qubits - 1) q2 = random.randint(0, n_qubits - 1) circuit.cnot(q1, q2) return circuit
def generate_completely_random_circuit(n_qubits, n_gates): """ Generates a Circuit with random gates :param n_qubits: int, number of qubits :param n_gates: int, number of random gates to add :return: QubitCircuit, randomly connected """ circuit = QubitCircuit(n_qubits) for _ in range(n_gates): q1 = random.randint(0, n_qubits - 1) q2 = random.randint(0, n_qubits - 1) while q1 == q2: q1 = random.randint(0, n_qubits - 1) q2 = random.randint(0, n_qubits - 1) circuit.cnot(q1, q2) return circuit