-
Notifications
You must be signed in to change notification settings - Fork 99
Improve error messages of various errors #3036
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
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1772,17 +1772,18 @@ function test_UnsupportedConstraint_when_it_cannot_be_bridged() | |
| mock = MOI.Utilities.MockOptimizer(NoRSOCModel{Float64}()) | ||
| bridged_mock = MOI.Bridges.LazyBridgeOptimizer(mock) | ||
| x = MOI.add_variables(bridged_mock, 4) | ||
| err = MOI.UnsupportedConstraint{ | ||
| MOI.VectorOfVariables, | ||
| MOI.RotatedSecondOrderCone, | ||
| }() | ||
| @test_throws err begin | ||
| @test_throws( | ||
| MOI.UnsupportedConstraint{ | ||
| MOI.VectorOfVariables, | ||
| MOI.RotatedSecondOrderCone, | ||
| }, | ||
| MOI.add_constraint( | ||
| bridged_mock, | ||
| MOI.VectorOfVariables(x), | ||
| MOI.RotatedSecondOrderCone(4), | ||
| ) | ||
| end | ||
| ), | ||
| ) | ||
| return | ||
| end | ||
|
|
||
| function test_MOI_runtests_No_RSOCModel() | ||
|
|
@@ -1839,17 +1840,17 @@ function test_bridge_selection() | |
| MOI.LogDetConeTriangle, | ||
| )) | ||
| x = MOI.add_variables(bridged_mock, 3) | ||
| err = MOI.UnsupportedConstraint{ | ||
| MOI.VectorAffineFunction{Float64}, | ||
| MOI.LogDetConeTriangle, | ||
| }() | ||
| @test_throws err begin | ||
| @test_throws( | ||
| MOI.UnsupportedConstraint{ | ||
| MOI.VectorAffineFunction{Float64}, | ||
| MOI.LogDetConeTriangle, | ||
| }, | ||
| MOI.Bridges.bridge_type( | ||
| bridged_mock, | ||
| MOI.VectorAffineFunction{Float64}, | ||
| MOI.LogDetConeTriangle, | ||
| ) | ||
| end | ||
| ), | ||
| ) | ||
| c = MOI.add_constraint( | ||
| bridged_mock, | ||
| MOI.VectorOfVariables(x), | ||
|
|
@@ -2703,6 +2704,47 @@ function test_custom_cost_model_bridge_selection() | |
| return | ||
| end | ||
|
|
||
| struct _UnsupportedSet <: MOI.AbstractScalarSet end | ||
|
|
||
| function test_bridge_unsupported_constraint() | ||
| model = MOI.instantiate( | ||
| MOI.Utilities.Model{Float64}; | ||
| with_bridge_type = Float64, | ||
| ) | ||
| x = MOI.add_variable(model) | ||
| err = MOI.UnsupportedConstraint{MOI.VariableIndex,_UnsupportedSet}(model) | ||
| @test_throws err MOI.add_constraint(model, x, _UnsupportedSet()) | ||
| @test_throws err MOI.add_constrained_variable(model, _UnsupportedSet()) | ||
| ret = """ | ||
| UnsupportedConstraint{ | ||
| MathOptInterface.VariableIndex, | ||
| $_UnsupportedSet, | ||
| } | ||
|
|
||
| This constraint type is not supported by the solver. | ||
|
|
||
| To fix this error you must choose a different solver. | ||
|
|
||
| ## More information | ||
|
|
||
| Bridges are enabled, but there are none that can rewrite the constraint into a form supported by the solver. | ||
|
|
||
| The model that we were unable to add the constraint to is: | ||
|
|
||
| MOIB.LazyBridgeOptimizer{MOIU.Model{Float64}} | ||
| ├ Variable bridges: none | ||
| ├ Constraint bridges: none | ||
| ├ Objective bridges: none | ||
| └ model: MOIU.Model{Float64} | ||
| ├ ObjectiveSense: FEASIBILITY_SENSE | ||
| ├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64} | ||
| ├ NumberOfVariables: 1 | ||
| └ NumberOfConstraints: 0 | ||
| """ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @araujoms here you go |
||
| @test sprint(showerror, err) == ret | ||
| return | ||
| end | ||
|
|
||
| end # module | ||
|
|
||
| TestBridgesLazyBridgeOptimizer.runtests() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just print the solver name instead of the whole model, since the solver is what makes the constraint unsupported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this isn't
print(model), but it'sshow(model). Which is the high level summary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which still has a lot of irrelevant information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SolverNamedrops a lot of relevant information.It looks through the bridging layer and the cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is the result, it's exactly the information I wanted to have, which is why I suggested it.
It's just a suggestion, feel free to ignore it.