Created
November 3, 2021 21:08
-
-
Save techwithshadab/84cd5d1fddb22e60a0d2c54ecab22b21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def vqe(qubitOp): | |
backend = Aer.get_backend('statevector_simulator') # You can switch to different backends by providing the name of backend. | |
seed = 50 | |
cobyla = COBYLA() | |
cobyla.set_options(maxiter=1000) | |
ry = TwoLocal(qubitOp.num_qubits, 'ry', 'cz', reps=3, entanglement='full') | |
vqe = VQE(qubitOp, ry, cobyla) | |
vqe.random_seed = seed | |
quantum_instance = QuantumInstance(backend=backend, seed_simulator=seed, seed_transpiler=seed) | |
result = vqe.run(quantum_instance) | |
selection, state, values, probabilities = print_result(result) | |
print(selection_to_picks(num_assets, selection)) | |
return state, values, probabilities |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment