Is it possible to solve the following kind of optimization using Quantum Computing?

5*x1 - 7*x2


If yes, is it possible to have a sample code using QISKit?

  • $\begingroup$ Are you sure you want linear polynomial here? Not even quadratic $x1^2$, $x2^2$ or $x1*x2$ terms? $\endgroup$
    – AHusain
    Aug 26, 2020 at 21:51
  • $\begingroup$ Well as a beginner, I'm trying to learn to solve simple linear problems. Next, with multiple constraints, then non-linear and so on... Shall I include them in this question? $\endgroup$
    – Dr.PB
    Aug 27, 2020 at 7:27

1 Answer 1


Qiskit has an optimization module and you can find tutorials that illustrate its functionality here.

To solve the example you posted, e.g., with the Quantum Approximate Optimization Algorithm (QAOA), you can do the following:

from qiskit import Aer
from qiskit.optimization import QuadraticProgram
from qiskit.aqua.algorithms import QAOA
from qiskit.optimization.algorithms import MinimumEigenOptimizer

# construct optimization problem
qp = QuadraticProgram()
qp.minimize(linear=[5, -7])

# initialize optimizer
qaoa_mes = QAOA(quantum_instance=Aer.get_backend('statevector_simulator'))
qaoa = MinimumEigenOptimizer(qaoa_mes)

# solve problem
result = qaoa.solve(qp)

which prints:

optimal function value: -7.0
optimal value: [0. 1.]
status: SUCCESS

Qiskit's optimization module also provides other quantum optimization algorithms for quadratic programs and you can find a more detailed description here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.