Skip to content

Define is_copyable and is_set_by_optimize #509

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 7 commits into from
Aug 28, 2018
Merged

Conversation

blegat
Copy link
Member

@blegat blegat commented Aug 27, 2018

Closes #480

@blegat blegat added this to the 0.6.0 milestone Aug 27, 2018
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.

This is a big improvement!


* it is either set when the model is created like [`SolverName`](@ref) and
[`RawSolver`](@ref),
* or explicitely when the model is copied like
Copy link
Member

Choose a reason for hiding this comment

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

Typo: explicitly


* it is either set when the model is created like [`SolverName`](@ref) and
[`RawSolver`](@ref),
* or explicitely when the model is copied like
Copy link
Member

Choose a reason for hiding this comment

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

Why the line break here? Does it actually exceed 80 characters?

[`RawSolver`](@ref),
* or explicitely when the model is copied like
[`ObjectiveSense`](@ref),
* or implicitely like [`NumberOfVariables`](@ref)
Copy link
Member

Choose a reason for hiding this comment

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

Typo: implicitly

[`RawSolver`](@ref),
* or explicitely when the model is copied like
[`ObjectiveSense`](@ref),
* or implicitely like [`NumberOfVariables`](@ref)
Copy link
Member

Choose a reason for hiding this comment

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

Another example of implicit setting is add_constraint

* or it is set to contain the result of the optimization during
[`optimize!`](@ref) like [`VariablePrimal`](@ref).

The following functions allows to distinguish between different some of these
Copy link
Member

Choose a reason for hiding this comment

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

"some of these different categories"

supports(::ModelLike, ::Union{AbstractVariableAttribute, AbstractConstraintAttribute}, ::Type{<:Index}) = false
function supports(::ModelLike, attr::Union{AbstractModelAttribute,
AbstractOptimizerAttribute})
@assert is_copyable(attr)
Copy link
Member

Choose a reason for hiding this comment

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

Prefer error messages over assert for checking user-facing inputs.

@@ -294,7 +307,9 @@ struct SolverName <: AbstractOptimizerAttribute end
"""
ListOfModelAttributesSet()

A model attribute for the `Vector{AbstractModelAttribute}` of all model attributes that were set to the model.
A model attribute for the `Vector{AbstractModelAttribute}` of all model
attributes `attr` such that `is_copyable(attr)` returns `true` that were set to
Copy link
Member

Choose a reason for hiding this comment

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

such that 1) is_copyable(attr) returns true and 2) the attribute was set.

@codecov-io
Copy link

codecov-io commented Aug 27, 2018

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #509      +/-   ##
=========================================
+ Coverage   95.59%   95.6%   +<.01%     
=========================================
  Files          46      46              
  Lines        4700    4707       +7     
=========================================
+ Hits         4493    4500       +7     
  Misses        207     207
Impacted Files Coverage Δ
src/Utilities/cachingoptimizer.jl 89.94% <100%> (-0.11%) ⬇️
src/Utilities/copy.jl 93.82% <100%> (+0.07%) ⬆️
src/Bridges/bridgeoptimizer.jl 96.93% <100%> (ø) ⬆️
src/attributes.jl 97.05% <100%> (+0.39%) ⬆️

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 c8e597e...846d463. Read the comment docs.

* or it is set to contain the result of the optimization during
[`optimize!`](@ref) like [`VariablePrimal`](@ref).

The following functions allows to distinguish between some of these different
Copy link
Member

Choose a reason for hiding this comment

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

"allows" -> "allow"

@blegat blegat merged commit 7c7f38b into master Aug 28, 2018
@blegat blegat deleted the bl/attibutescategories branch August 28, 2018 14:31
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