Skip to content

Commit

Permalink
Remove old code
Browse files Browse the repository at this point in the history
  • Loading branch information
Elscrux committed Sep 28, 2023
1 parent 1074594 commit a848a0e
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions qiskit/qubo/qubo_qiskit.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import copy
import sys

from qiskit.algorithms.minimum_eigensolvers import QAOA
from qiskit.algorithms.optimizers import COBYLA
from qiskit.primitives import Sampler
from qiskit_optimization import QuadraticProgram
from qiskit_optimization.algorithms import MinimumEigenOptimizer
from qiskit_optimization.problems import VarType

if len(sys.argv) != 3:
raise TypeError('This script expects exactly 2 arguments. Input file (argument 1) and output file (argument 2).')
Expand All @@ -17,24 +15,11 @@
qp = QuadraticProgram()
qp.read_from_lp_file(input_path)


def relax_problem(problem):
"""Change all variables to continuous."""
relaxed_problem = copy.deepcopy(problem)
for variable in relaxed_problem.variables:
variable.vartype = VarType.CONTINUOUS

return relaxed_problem

qubo = qp
# qubo = relax_problem(QuadraticProgramToQubo().convert(qp))
# print(qp.prettyprint())

qaoa_mes = QAOA(Sampler(), optimizer=COBYLA(), initial_point=[0.0, 1.0])

qaoa = MinimumEigenOptimizer(qaoa_mes)

qaoa_result = qaoa.solve(qubo)
qaoa_result = qaoa.solve(qp)
print(qaoa_result.prettyprint())

f = open(output_path, 'w')
Expand Down

0 comments on commit a848a0e

Please sign in to comment.