I want to know how to solve a 01 Knapsack problem (or any optimization problem) on real Quantum Hardware only. I don't want to use an Application class or any classical simulation technique.

If anyone has done it then please give me your code so that I can compare the solution time for classical and quantum solvers

  • $\begingroup$ Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. $\endgroup$
    – Community Bot
    Commented May 1 at 15:44
  • $\begingroup$ Hi thanks for your response. I agree with you that DWave quantum annealers are good choice for optimization problem. And I run a KP problem on their Hybrid CQM solver.I found that though the solution quality is compromised but computational time is far better than Classical computers. So inorder to have better comparison I want to run KP problem on circuit based QC as well. I have some idea about QAOA but don't know how to implement them for my problem. If you know how to do that then please. $\endgroup$
    – Maths_hawk
    Commented May 2 at 17:22

1 Answer 1


Current quantum hardware based on a quantum circuit model has a limited number of qubits, which are prone to errors and decoherence. So, comparing solutions from classical solvers with those produced by quantum hardware is almost pointless at the moment. Classical solvers that run on classical hardware will always outperform their quantum counterparts by a very large margin, at least in the near future.

If you still want to play with the real quantum hardware, then IBM has several publicly available backends where you can try running circuit-base quantum algorithms like QAOA or VQE. The QAOA and VQE codes are on their website.

Another venue that is perhaps slightly more mature for optimization is D-Wave's quantum annealer. It can handle relatively large problems with moderate success. For example, here is the implementation of the KP problem from D-Wave's repo. A basic Google search will also show you a number of GitHub repos that implement KP problems for annealers and circuit-based quantum computers.

Overall, I suggest reading basic information about the current state of quantum computers and quantum optimization before running any code. It is best to understand the most basic theory behind quantum algorithms before looking at the code.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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