entropicalabs / openqaoa

Multi-backend SDK for quantum optimisation
MIT License
119 stars 58 forks source link

Warning if `0` is passed in `numbers_list` in `NumberPartition` problem #209

Open vishal-ph opened 1 year ago

vishal-ph commented 1 year ago

Prerequisites

Before raising this issue, I have already checked that I am:

Describe the bug

Upon creating an instance of the NumberPartition problem with a 0 entry in the list, the problem is created with redundant qubit and terms. These terms then manifest as extra cost gates with angle=0.

To Reproduce

Steps to reproduce the behavior:

from openqaoa.problems import NumberPartition
np = NumberPartition([0,2,3,5,8])
np_qubo = np.qubo()
np_qubo.hamiltonian.expression

Expected behavior

The problem class should catch 0 in the list and raise a warning while removing the zero from the list, and create a problem with the remaining qubits.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

lumapools commented 1 year ago

Hi, I just created a PR that handles this issue. Could a maintainer please assign me to this ? (I had to close the previous PR as it contained a different not-yet-merged PR modifications)