Skip to content

Remove canget #479

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
merged 9 commits into from
Aug 21, 2018
Merged

Remove canget #479

merged 9 commits into from
Aug 21, 2018

Conversation

blegat
Copy link
Member

@blegat blegat commented Aug 20, 2018

Here are the following changes:

  • If a constraint or variable attribute is set to a strict subset of the variables/constraints, it used to return canget equal to false and not be included in ListOf...AttributesSet. No, it is included in the list independently on the number of variables/constraints with this attribute set.
  • To check if a name was already present, one could use canget and this was used by the bridgeoptimizer and universalfallback to check whether it is the name of a bridged constraints or of a constraint of the internal model. This required 2 dictionary lookup: 1 for canget and 1 for get. If get is called with a name that does not exists an error was thrown. Now with this PR, get returns nothing in case the name does not exists. This allows bridges and fallback to have almost no overhead in case the name not the name of a bridged constraint as this is efficiently handled on Julia v1.0
  • NoSolution has been added as a new result status which specifies that the result has no primal or dual solution, e.g. a result could have only a dual solution in which case the primal status is NoSolution.

Closes #424
Closes #302

@codecov-io
Copy link

codecov-io commented Aug 20, 2018

Codecov Report

Merging #479 into master will decrease coverage by 0.12%.
The diff coverage is 98.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #479      +/-   ##
==========================================
- Coverage   95.44%   95.32%   -0.13%     
==========================================
  Files          46       46              
  Lines        5267     4640     -627     
==========================================
- Hits         5027     4423     -604     
+ Misses        240      217      -23
Impacted Files Coverage Δ
src/Test/contquadratic.jl 100% <ø> (ø) ⬆️
src/Bridges/rsocbridge.jl 100% <ø> (ø) ⬆️
src/attributes.jl 96.66% <ø> (-0.35%) ⬇️
src/Bridges/soctopsdbridge.jl 100% <ø> (ø) ⬆️
src/Test/intconic.jl 100% <ø> (ø) ⬆️
src/Test/UnitTests/objectives.jl 100% <ø> (ø) ⬆️
src/Test/contlinear.jl 100% <ø> (ø) ⬆️
src/Bridges/detbridge.jl 98.76% <ø> (-0.06%) ⬇️
src/Bridges/squarepsdbridge.jl 96.66% <ø> (-0.11%) ⬇️
src/Test/nlp.jl 0% <ø> (ø) ⬆️
... and 18 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 f2cbf24...7af8b06. Read the comment docs.

Copy link
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.

Removing 800 lines of code is amazing. Thanks for doing this work!

if config.infeas_certificates
@test MOI.get(model, MOI.TerminationStatus()) == MOI.Success
else
@test MOI.get(model, MOI.TerminationStatus()) in [MOI.InfeasibleNoResult, MOI.InfeasibleOrUnbounded]
end
if MOI.canget(model, MOI.PrimalStatus())
@test MOI.get(model, MOI.PrimalStatus()) == MOI.InfeasiblePoint
if config.infeas_certificates || MOI.get(model, MOI.ResultCount()) > 0
Copy link
Member

Choose a reason for hiding this comment

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

The 2 "or" statements here are a bit confusing: config.infeas_certificates || MOI.get(model, MOI.ResultCount()) > 0
and MOI.get(model, MOI.PrimalStatus()) in (MOI.NoSolution, MOI.InfeasiblePoint).

Could you untangle what is expected in what cases and/or add a comment about why these different cases can happen?

Doesn't config.infeas_certificates imply that we expect MOI.get(model, MOI.ResultCount()) > 0 and PrimalStatus to be NoSolution?

Same comment applies right below.

@test MOI.get(model, MOI.ConstraintPrimal(), gmc) ≈ ones(n+1) atol=atol rtol=rtol

@test MOI.canget(model, MOI.ConstraintPrimal(), typeof(c))
@test MOI.get(model, MOI.ConstraintPrimal(), c) ≈ n atol=atol rtol=rtol

# if config.duals
Copy link
Member

Choose a reason for hiding this comment

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

Since you're touching nearby code, could you add a comment explaining why this block is commented?

@@ -294,13 +260,10 @@ function qcp1test(model::MOI.ModelLike, config::TestConfig)
#
Copy link
Member

Choose a reason for hiding this comment

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

Why is this code commented?

return true
end
function MOI.get(model::CachingOptimizer, attr::MOI.AbstractModelAttribute)
if is_result_attribute(attr)
Copy link
Member

Choose a reason for hiding this comment

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

How would solver-specific result attributes work? Like GurobiIIS?

Copy link
Member Author

Choose a reason for hiding this comment

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

They should implement is_result_attribute.

Copy link
Member Author

Choose a reason for hiding this comment

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

We might make it an abstract subtype of AbstractModelAttribute, ... to make it clear that it should be specified. Or make is_result_attribute part of MOI

Copy link
Member

Choose a reason for hiding this comment

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

What about using supports to decide whether to ask the optimizer or the model cache (with priority to the optimizer)? I can't easily think of a case where this would give the wrong answer, and is much simpler.

Copy link
Member Author

Choose a reason for hiding this comment

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

supports is not currently defined for attributes that never appear in ListOf...AttributesSet so it does not make sense for result attibutes which are not settable

Copy link
Member

Choose a reason for hiding this comment

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

This points to a larger design issue that needs to be resolved before tagging 0.6, but maybe this PR isn't the best place to discuss. It's definitely not ok for solvers to be required to overload functions in MOIU to get correct behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussion moved to #480 for more visibility

@@ -174,52 +174,6 @@ function get!(output, model::ModelLike, attr::AnyAttribute, args...)
throw(ArgumentError("ModelLike of type $(typeof(model)) does not support accessing the attribute $attr"))
end
Copy link
Member

Choose a reason for hiding this comment

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

(Applies a few lines above.) The documentation for get needs to be updated to describe when it now returns nothing.

@blegat blegat mentioned this pull request Aug 21, 2018
@blegat blegat merged commit 19d85b0 into master Aug 21, 2018
@blegat blegat deleted the bl/rmcanget branch August 21, 2018 21:02
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.

3 participants