-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add result fallbacks #447
Add result fallbacks #447
Conversation
src/sets.jl
Outdated
@@ -306,6 +365,29 @@ end | |||
|
|||
dimension(s::PositiveSemidefiniteConeSquare) = s.side_dimension^2 | |||
|
|||
function square_dot(x::Vector{T}, y::Vector{T}, dim::Int, offset::Int) where T | |||
@show x |
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.
Debugging code?
src/sets.jl
Outdated
dimension(s::Union{LogDetConeSquare, RootDetConeSquare}) = 1 + s.side_dimension^2 | ||
#function set_dot(x::Vector, y::Vector, set::Union{LogDetConeSquare, |
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.
Commented code?
@@ -0,0 +1,196 @@ | |||
""" |
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.
Explain the purpose of this file and how solver wrappers should use it.
src/sets.jl
Outdated
Return the scalar product between a vector `x` of the set `set` and a vector | ||
`y` of the dual of the set `s`. | ||
""" | ||
function set_dot(x::Vector, y::Vector, set::AbstractVectorSet) |
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 think these methods belong in MOIU rather than MOI. They're helpers for implementing MOI and aren't necessary for the API.
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.
If someone defines a new set with a non-trivial inner product, he is forced to define set_dot
and dot_coefficients
otherwise all codes using these functions fails. As this is mandatory, this is part of the API, isn't it ?
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.
Is there code using these functions outside of MOIU? The get_fallback
should be opt-in by the solver and not automatic.
8e470e1
to
6daeee3
Compare
Codecov Report
@@ Coverage Diff @@
## master #447 +/- ##
==========================================
- Coverage 95.28% 95.26% -0.03%
==========================================
Files 42 43 +1
Lines 4983 5087 +104
==========================================
+ Hits 4748 4846 +98
- Misses 235 241 +6
Continue to review full report at Codecov.
|
6daeee3
to
64b7db4
Compare
Good to merge ? |
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.
Sorry for the delay, busy week.
src/Utilities/results.jl
Outdated
@@ -0,0 +1,283 @@ | |||
# This file contains the implementation of different methods for the | |||
# `get_fallback` function. These methods can be used by solver wrappers as | |||
# fallbacks for implemented the `get` method when the solver API does not |
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.
"for implemented" -> "for implementing"
src/Utilities/results.jl
Outdated
func = MOI.get(model, MOI.ConstraintFunction(), constraint_index) | ||
if (F == MOI.SingleVariable && func.variable == vi) || | ||
(F == MOI.VectorOfVariables && vi in func.variables) | ||
error("Fallback getter for variable constraint dual does not support other variable-wise constraints on the variable.") |
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.
Nit: line break the error message (using * to concat strings)
src/Utilities/results.jl
Outdated
::Type{<:Union{MOI.ScalarQuadraticFunction, | ||
MOI.VectorQuadraticFunction}}, | ||
::Type{<:MOI.AbstractSet}) | ||
error("Fallback getter for variable constraint dual only supports affine constraint functions.") |
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.
What happens if a user sees this error message? Does it indicate an internal error in the solver wrapper or that the user did something wrong? (Same with similar errors below.)
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.
An error on the wrapper, the wrapper shouldn't call this if there are double variable bounds or quadratic functions
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.
This should be reflected in the error messages to help users if they see it.
src/Utilities/results.jl
Outdated
return 0.0 | ||
end | ||
|
||
function variable_dual(::MOI.ModelLike, |
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.
This function has lots of methods that aren't obvious to understand. It needs a docstring or at least a comment.
@@ -380,6 +380,24 @@ it has non-integer coefficient and `F` is `ScalarAffineFunction{Int}`. | |||
""" | |||
struct ObjectiveFunction{F<:AbstractScalarFunction} <: AbstractModelAttribute end | |||
|
|||
""" | |||
ObjectiveFunctionType() |
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.
Add this to the list of attributes in the docs.
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.
Good to merge after tweaking the error message as discussed inline.
As discussed in #442 and JuliaOpt/LinQuadOptInterface.jl#41, some solver API do not contain any getters for result informations that can be deduced for variable primals and constraint duals of non-variablewise constraints.
These include the following:
This PR
get_fallback
function that is independent of the MockOptimizer.set_dot
anddot_coefficients
as new set functions that need to be implemented. They have a default implementation for non-triangle sets.evalobjective
toeval_objective_value
in MockOptimizer to make place toeval_objective_bound
TODO:
get_fallback