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

Inconsistency for conflicting boundaries #1309

Open
JoelPasvolsky opened this issue Feb 3, 2023 · 1 comment
Open

Inconsistency for conflicting boundaries #1309

JoelPasvolsky opened this issue Feb 3, 2023 · 1 comment

Comments

@JoelPasvolsky
Copy link
Contributor

Description
I can first add a constraint that acts as an upper bound and then set an upper bound on the variable but I am not allowed to do the same thing in reverse order:

>>> cqm = dimod.ConstrainedQuadraticModel()
>>> cqm.add_constraint(j <= 3, "Max j")
>>> cqm.set_upper_bound('j', 5)
>>> print(cqm)
Constrained quadratic model: 1 variables, 1 constraints, 1 biases

Objective
  0

Constraints
  Max j: Integer('j') <= 3.0

Bounds
  0.0 <= Integer('j') <= 5.0
>>> cqm = dimod.ConstrainedQuadraticModel()
>>> cqm.add_variable('INTEGER', 'j', upper_bound=10)
>>> cqm.add_constraint(j <= 3, "Max j")
ValueError: conflicting upper bounds: 'j'

The first makes sense to me despite the redundant bounds in practice, it might be easier for users to set both generic upper bounds on variables and then to have some constraints that tighten those bounds.

Steps To Reproduce
See above

Expected Behavior
I don't like getting a conflicting bounds error when I chose to set a constraint on a single variable.

Environment

  • OS: WIN10
  • Python version: 3.10
@JoelPasvolsky
Copy link
Contributor Author

Just noticed something interesting: for order 1, if I then add an objective that uses variable j, the ValueError: conflicting upper bounds: 'i' error pops up, That's not good.

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

No branches or pull requests

1 participant