Skip to content

SingleVariable constraint have same index as the variable#732

Merged
blegat merged 14 commits intomasterfrom
bl/single_variable_index
May 17, 2019
Merged

SingleVariable constraint have same index as the variable#732
blegat merged 14 commits intomasterfrom
bl/single_variable_index

Conversation

@blegat
Copy link
Copy Markdown
Member

@blegat blegat commented May 11, 2019

  • Update universal fallback

Closes #570

@blegat blegat added this to the v0.9 milestone May 11, 2019
Copy link
Copy Markdown
Member

@mlubin mlubin left a comment

Choose a reason for hiding this comment

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

Note the test failures.

Comment thread src/Utilities/model.jl
Comment thread src/Utilities/model.jl Outdated
Comment thread src/Utilities/model.jl
Comment thread src/Utilities/model.jl Outdated
Comment thread src/Utilities/model.jl Outdated
Comment thread test/Utilities/universalfallback.jl Outdated
@codecov-io
Copy link
Copy Markdown

codecov-io commented May 14, 2019

Codecov Report

Merging #732 into master will decrease coverage by 0.21%.
The diff coverage is 96.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #732      +/-   ##
==========================================
- Coverage   94.24%   94.02%   -0.22%     
==========================================
  Files          55       55              
  Lines        5852     6124     +272     
==========================================
+ Hits         5515     5758     +243     
- Misses        337      366      +29
Impacted Files Coverage Δ
src/Bridges/lazybridgeoptimizer.jl 97.43% <ø> (ø) ⬆️
src/Bridges/singlebridgeoptimizer.jl 60% <ø> (ø) ⬆️
src/Test/nlp.jl 0% <0%> (ø) ⬆️
src/attributes.jl 94.66% <100%> (+0.07%) ⬆️
src/Test/UnitTests/variables.jl 81.31% <100%> (+0.85%) ⬆️
src/indextypes.jl 85.71% <100%> (+2.38%) ⬆️
src/Test/contlinear.jl 100% <100%> (ø) ⬆️
src/Test/UnitTests/constraints.jl 100% <100%> (ø) ⬆️
src/Utilities/universalfallback.jl 97.56% <100%> (-0.58%) ⬇️
src/Utilities/mockoptimizer.jl 90.76% <100%> (+0.04%) ⬆️
... and 17 more

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 7ad908b...89ce9e1. Read the comment docs.

@blegat blegat force-pushed the bl/single_variable_index branch from b3961d6 to a784423 Compare May 15, 2019 09:28
Comment thread src/Bridges/bridgeoptimizer.jl Outdated
Comment thread src/Bridges/bridgeoptimizer.jl Outdated
Comment thread src/Bridges/bridgeoptimizer.jl Outdated
function MOI.get(b::AbstractBridgeOptimizer,
attr::MOI.ListOfConstraintIndices{F, S}) where {F, S}
# List of indices of all constraints, even those bridged
function get_all_even_bridged(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does _remove_bridged have an underscore and this function doesn't?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't want to user to call _remove_bridged as it could corrupt the integrity of the object.
get_all_including_bridged provides a well defined information which could be useful for inspecting and debugging.

Comment thread src/Test/UnitTests/modifications.jl Outdated
Comment thread src/Test/contconic.jl
a = MOI.add_variable(model)
b = MOI.add_variable(model)
vc1 = MOI.add_constraint(model, MOI.SingleVariable(a), MOI.EqualTo(0.5))
@test vc1.value == a.value
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we should litter the longer tests with this check after every SingleVariable() constraint. This distracts from the focus of the test which is to check that the solution is correct. Other tests check the value of the indices.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Which other tests ? Some solvers do not call all the tests and many implementation would get singlevariable indices equal to the variables indices just by chances so I wanted to optimize the chance to catch it by checking it in as many corner cases as possible.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's good to catch it in corner cases, but this can be done by creating standalone unit tests. If solvers aren't running the right tests, that's a separate issue that should be addressed.

Doing the check here interferes with the readability of the tests. Tests should have a clear purpose and limited scope so that it's easy to understand what they're doing, how to modify them, and if they're correct. This is a particularly bad experience for someone who wants to add a new test and tries to copy the existing style. Are they responsible for adding these checks for every SingleVariable constraint in the test?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's good to catch it in corner cases, but this can be done by creating standalone unit tests
If solvers aren't running the right tests, that's a separate issue that should be addressed

The right tests might be using constraints that are bridged so even if the optimizer runs these tests, it will work just because the bridgeoptimizer is correct. If the solver only supports SingleVariable for a specific constraint and has a bug when this constraint is added in some order, it needs to be tested on that test in that order. We cannot create every corner case in unit tests.

This is a particularly bad experience for someone who wants to add a new test and tries to copy the existing style.

I understand this concern but I feel like having a good testing coverage of indices of SingleVariable constraints is more important.
In the long term, we might replace these tests with reading from a problem described in text like in unit tests and the check could be done automatically in a common function that calls the reading and then do common checks. The coverage for some attributes is currently not ideal, e.g. all the tests pass although we have this bug #693 because this bug only happens in corner cases and we don't check MOI.ListOfVariableIndices very often.

Are they responsible for adding these checks for every SingleVariable constraint in the test?

I think we should but it already has a decent coverage with existing tests so it might not be critical for new tests if they do not test new scalar sets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the long term, we might replace these tests with reading from a problem described in text like in unit tests and the check could be done automatically in a common function that calls the reading and then do common checks.

Sounds like a good idea.

I'll withdraw my objection if you add an explanatory comment on the first appearance in every file of @test vc1.value == a.value (or the equivalent) in a large solve-and-check-solution test (like rotatedsoc1test and int1test). I think this amount of documentation is proportional to the violation of readability that these tests incur.

@blegat blegat merged commit ecf6915 into master May 17, 2019
@odow odow deleted the bl/single_variable_index branch June 15, 2019 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Indices of SingleVariable constraints

3 participants