import time

from dwave.system import LeapHybridSampler

from qiskit.optimization.algorithms import CplexOptimizer

from random_lp.lp_random_gen import create_models
from utilities.helpers import create_dwave_meo

DIR = 'TEST_DATA' + "/" + time.strftime("%d_%m_%Y") + "/SPARSE/"
DIR

# select linear program to solve
qps = create_models(DIR)
qp = qps['test_38']

# init Optimizers
cplex = CplexOptimizer()
leap = create_dwave_meo(LeapHybridSampler())
dwave_auto = create_dwave_meo()

# solve classically
cplex.solve(qp)

# solve hybrid
leap.min_eigen_solver.sampler.set_label("leap_test_38")
res_leap = leap.solve(qp)
res_leap

# solve quantum
dwave_auto.min_eigen_solver.sampler.set_label("dwave_test_38")
res_dwave = dwave_auto.solve(qp)
res_dwave

qp.to_docplex().prettyprint()

