import time
from dwave.system import DWaveCliqueSampler
from qiskit_optimization.algorithms import CplexOptimizer
from utilities.helpers import create_dwave_meo, create_quadratic_programs_from_paths
DIR = 'TEST_DATA' + "/" + time.strftime("%d_%m_%Y")
DIR

# select linear programs to solve
qps = create_quadratic_programs_from_paths(DIR + "/DENSE/", True)
qp_dense = qps['test_80']
qps = create_quadratic_programs_from_paths(DIR + "/SPARSE/", True)
qp_sparse = qps['test_100']

# init Optimizers
cplex = CplexOptimizer()
clique = create_dwave_meo(DWaveCliqueSampler())
clique.min_eigen_solver.sampler.set_label("clique_dense_80")
dwave_auto = create_dwave_meo()
dwave_auto.min_eigen_solver.sampler.set_label("dwave_sparse_100")

# solve classically
cplex.solve(qp_dense)

cplex.solve(qp_sparse)

# solve quantum clique embedding for dense problems
res_clique = clique.solve(qp_dense)
res_clique

# solve quantum: automatically searches for embedding 
res_dwave = dwave_auto.solve(qp_sparse)
res_dwave

