qubithubknapsack

Solves the 0/1 Knapsack problem using the Quantum Approximate Optimization Algorithm (QAOA) with QUBO penalty method. Select items to maximize total value without exceeding weight capacity. Default: 4 items with optimal solution {1,2} yielding value 35 at weight 18/18. Uses quadratic penalty P*(Σwᵢxᵢ - C)² to enforce the capacity constraint via RZZ interactions.

RunCite

No licence specified, so all rights are reserved by default — forking copies this circuit but grants you no rights to reuse it.

Framework
Qiskit
Qubits
3
Depth
6
Gate set
H, RZZ, RX
Licence
Not specified
Version
v1
Updated
3 days ago
Last run
3 months ago

Circuit

circuit.py · Qiskit · depth 6
Loading circuit diagram…

qubithub.toml · 338 B

Code

Loading qubithub.toml

Lineage

Not a fork.

No forks yet.

Suggested citation

@software{qubithub_knapsack_2026,
  author = {QubitHub Circuits},
  title = {QAOA for Knapsack},
  year = {2026},
  version = {v1},
  url = {https://qubithub.co/qubithub/knapsack},
}

Generated from this circuit's metadata. QubitHub does not mint DOIs, so this is not a registered identifier — check it against your venue's requirements before publishing.