Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dimod dismisses part of the expression when both lower bound and higher bound are defined in a single line #1299

Open
elham-azd opened this issue Dec 9, 2022 · 2 comments
Labels

Comments

@elham-azd
Copy link

Description
dimod does not parse constraints correctly when we define both lower bound and higher bound in a single line. It dismisses the first part of the expression.

Steps To Reproduce

import dimod

v0, v1 = dimod.Integers('xy')

cqm = dimod.ConstrainedQuadraticModel()
cqm.set_objective(v0 + v1)
cqm.add_constraint(5 <= v0 <= 100)

print(cqm.constraints)

Output:
{'c08e0e6': Le(ConstraintView({'x': 1.0}, {}, 0.0, {'x': 'INTEGER'}), 100.0)}

Expected Behavior
The above expression should give the same output as:

import dimod

v0, v1 = dimod.Integers('xy')

cqm = dimod.ConstrainedQuadraticModel()
cqm.set_objective(v0 + v1)
cqm.add_constraint(v0 >= 5)
cqm.add_constraint(v0 <= 100)

print(cqm.constraints)

Output:
{'cb82aca': Ge(ConstraintView({'x': 1.0}, {}, 0.0, {'x': 'INTEGER'}), 5.0), 'cdcf213': Le(ConstraintView({'x': 1.0}, {}, 0.0, {'x': 'INTEGER'}), 100.0)}

Environment

  • OS: macOS 12.5.1
  • Python version: Python 3.10.7
@arcondello
Copy link
Member

Right. We don't currently support bounding on both sides, should either raise an error or support this feature.

@arcondello
Copy link
Member

arcondello commented Dec 9, 2022

I am inclined to go with raising an error, because we would treat this as two constraints under the hood, and the API expects only one (e.g. it returns a single variable label etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants