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

Improve error message when querying a variable bound that does not exist #1587

Merged
merged 2 commits into from Nov 8, 2018

Conversation

odow
Copy link
Member

@odow odow commented Nov 7, 2018

Closes #1509

@@ -257,7 +257,9 @@ function has_lower_bound(v::VariableRef)
end

function lower_bound_index(v::VariableRef)
@assert has_lower_bound(v) # TODO error message
if !has_lower_bound(v)
error("Variable $(v) does not have a lower bound.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be misleading. Consider a polyhedral feasible set, if you eliminate all variables except v then it might be a set that is bounded from below.
Maybe lower bound constraint ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message will almost always be called when users run JuMP.lower_bound(x) if x is missing a lower bound.

There might be other constraints that enforce a lower bound on the variable, but that is a different kettle of fish.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is a different kettle of fish.

That is clear for us, but is that clear for a user that has just started using JuMP and has no idea what JuMP.lower_bound is ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who reads the doc if it is not thrown on your face :-P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a user that has done @constraint model x >= 0 will not understand why there is no lower bound.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relates to #1586. I feel that if the user writes @constraint, we should add a constraint (e.g., a row) to the problem.

Then we make "variable bound" mean a bound that was introduced in @variable or via JuMP.set_lower_bound and JuMP.set_upper_bound.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error message is sufficiently clear given that has_lower_bound is a documented concept in JuMP.

@codecov
Copy link

codecov bot commented Nov 7, 2018

Codecov Report

Merging #1587 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1587      +/-   ##
=========================================
+ Coverage    90.8%   90.8%   +<.01%     
=========================================
  Files          28      28              
  Lines        3696    3698       +2     
=========================================
+ Hits         3356    3358       +2     
  Misses        340     340
Impacted Files Coverage Δ
src/variables.jl 93.25% <100%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6daac7a...b3c34f6. Read the comment docs.

@odow odow merged commit f2583ef into master Nov 8, 2018
@odow odow deleted the od/fix_bond_error_msg branch November 8, 2018 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants