from qiskit.aqua.operators import WeightedPauliOperator

pauli_dict = {
    'paulis': [{"coeff": {"imag": 0.0, "real": -1.052373245772859}, "label": "II"},
              {"coeff": {"imag": 0.0, "real": 0.39793742484318045}, "label": "ZI"},
              {"coeff": {"imag": 0.0, "real": -0.39793742484318045}, "label": "IZ"},
              {"coeff": {"imag": 0.0, "real": -0.01128010425623538}, "label": "ZZ"},
              {"coeff": {"imag": 0.0, "real": 0.18093119978423156}, "label": "XX"}
              ]
}

qubit_op = WeightedPauliOperator.from_dict(pauli_dict)

from qiskit.aqua.algorithms import NumPyMinimumEigensolver

ee = NumPyMinimumEigensolver(qubit_op)
result = ee.run()
print(result.eigenvalue.real)

from qiskit import BasicAer
from qiskit.aqua.algorithms import VQE
from qiskit.circuit.library import TwoLocal
from qiskit.aqua.components.optimizers import L_BFGS_B

var_form = TwoLocal(qubit_op.num_qubits, ['ry', 'rz'], 'cz', reps=3, entanglement='linear')
optimizer = L_BFGS_B(maxfun=1000)
vqe = VQE(qubit_op, var_form, optimizer)
backend = BasicAer.get_backend('statevector_simulator')
result = vqe.run(backend)
print(result.eigenvalue.real)

from qiskit.aqua import QuantumInstance

var_form = TwoLocal(qubit_op.num_qubits, ['ry', 'rz'], 'cz', reps=3, entanglement='linear')
optimizer = L_BFGS_B(maxfun=1000)
vqe = VQE(qubit_op, var_form, optimizer)
backend = BasicAer.get_backend('statevector_simulator')
qi = QuantumInstance(backend=backend)
result = vqe.run(qi)
print(result.eigenvalue.real)