dwavesystems / dwavesystems/dimod

Prevent adding empty constraints to the CQM model

Open
#1,177 1 comment 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
Python
Stars
143
Forks
91
Avg merge
1h 24m
Merged PRs (30d)
3

Description

Not sure if this is a bug or a feature request. Since I didn't expect this to happen, I file it as a bug, please change to feature request if more appropriate.

I do not expect to be able to add an empty constraint to a CQM model.
```
import dimod
cqm = dimod.CQM()
cqm.add_constraint( dimod.quicksum([]) <= 0)
print(len(cqm.constraints))
```
While there might be some rare use cases for this, like creating a constraint first and filling it later, it would be better to prevent this as the empty constraint might be counted toward maximum constraint allowed by the HSS system.
I also suggest to remove empty constraints resulted from variable fixing or constraint removing.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the example through CQM.add_constraint with dimod.quicksum([]) <= 0, then inspect how empty constraints are represented. Check the variable-fixing and constraint-removing paths mentioned in the issue. Done means empty constraints are prevented or removed consistently and are not counted in cqm.constraints.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.