qubithubknapsack
Applies the Quantum Approximate Optimization Algorithm (QAOA) to the 0/1 Knapsack problem with a QUBO penalty method: select items to maximize total value within a weight capacity. Default: 4 items, capacity 18, optimal value 35 (items {1,2} or {0,3}). A quadratic penalty P*(Σwᵢxᵢ - C)², which favors filling exactly to C, folds the capacity into a cost layer of RZ and RZZ rotations.
- Framework
- Qiskit
- Qubits
- 4
- Depth
- 9
- Gate set
- H, RZZ, RX
- Licence
- Apache-2.0
- Version
- v1
- Updated
- 58 minutes ago
- Runs
- 1 completed
Circuit
circuit.py · Qiskit · depth 9Loading circuit diagram…
circuit.py · 22 KB
Code
Loading circuit.py…
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/circuits/9c4ef001-628d-5254-9d54-40054bf3547f},
note = {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.