Inconsistency for conflicting boundaries
JoelPasvolsky opened this issue · 1 comments
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
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.