import numpy as np
from qiskit.opflow import X, Z, I
from qiskit.algorithms.optimizers import L_BFGS_B
from qiskit.circuit.library import EfficientSU2

bfgs_optimizer = L_BFGS_B(maxiter=60)

a_1 = np.random.random_sample()
a_2 = np.random.random_sample()
J_21 = np.random.random_sample()

H_transverse_ising = a_1*(I^X) + a_2*(X^I) + J_21*(Z^Z)
print("========== Transverse Ising Model Hamiltonian for Two Qubits ==========\n")
print(H_transverse_ising.to_matrix())
print()

H2_molecule_Hamiltonian = -0.5053051899926562*(I^I) + \
                            -0.3277380754984016*(Z^I) + \
                            0.15567463610622564*(Z^Z) + \
                            -0.3277380754984016*(I^Z)
print("========== H2 Molecule Hamiltonian for Two Qubits ==========\n")
print(H2_molecule_Hamiltonian.to_matrix())
print()

def vqe(hamiltonian, anzatz, optimazer, min_dist):
    # Create the initial parameters
    params = np.random.rand(3)
    ret = optimizer.optimize(num_vars=3, objective_function=objective_function, initial_point=params)

    # Obtain the output distribution using the final parameters
    qc = get_var_form(ret[0])
    t_qc = transpile(qc, backend)
    qobj = assemble(t_qc, shots=NUM_SHOTS)
    counts = backend.run(qobj).result().get_counts(qc)
    output_distr = get_probability_distribution(counts)
    #calculate the target function
    old_res = old_state.dagger * hamiltonian * old_state
    print(old_res)
    #minimaize the target function
    
    #iterate the process
    
vqe((I^I).to_matrix(),)

(I^I).to_matrix()

