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

Errors in a @constraints block reported with incorrect line numbers #1174

Open
niclasmattsson opened this issue Feb 3, 2018 · 2 comments
Open
Milestone

Comments

@niclasmattsson
Copy link

@niclasmattsson niclasmattsson commented Feb 3, 2018

If you make an error in a @constraints block the line number reported to cause the error is the line of the @constraints statement. For example:

m = Model(solver=ClpSolver())

@variables m begin
    0 <= x <= 4
    0 <= y <= 30
end

@constraints m begin        # <- error reported on this line
    region1, 1x + 5y <= 3.0
    region2, x - undeclared_variable <= 2.0
end

@objective(m, Max, 5x + 3y)

print(m)
status = solve(m)

In this example the error is ERROR: LoadError: UndefVarError: undeclared_variable not defined, so you would easily find the problem anyway. But I often get more generic errors which don't have an immediately obvious cause, and if you have 20+ constraints then it becomes extremely difficult to identify the problem.

This greatly limits the usability of the @constraints syntax for large models - the precise situation in which it is intended to be convenient.

@mlubin

This comment has been minimized.

Copy link
Member

@mlubin mlubin commented Feb 3, 2018

Thanks for the report. This should be fixed for JuMP 1.0 but has less priority than the ongoing MOI transition.

@niclasmattsson

This comment has been minimized.

Copy link
Author

@niclasmattsson niclasmattsson commented Feb 4, 2018

Excellent! No hurry, I want the MOI stuff and the changes to JuMPcontainers done before this too. :) But that said I'm glad to see you tagged this for the 1.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.