Skip to content

Conversation

@mtanneau
Copy link
Contributor

@mtanneau mtanneau commented Jul 11, 2022

Addresses #1936

I have created a RelativeGapTolerance attribute. If that's satisfactory code- and doc-wise, I'll do the same with AbsoluteGapTolerance.

TODO

  • RelativeGapTolerance attribute
  • AbsoluteGapTolerance attribute
  • Docs update?

@mtanneau
Copy link
Contributor Author

Is there anything I should change in the docs? Maybe around here?

## Optimizer attributes
```@docs
AbstractOptimizerAttribute
SolverName
SolverVersion
Silent
TimeLimitSec
RawOptimizerAttribute
NumberOfThreads
RawSolver
```

@mtanneau mtanneau marked this pull request as ready for review July 12, 2022 15:15
Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

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

Yip. That's the place to add the docstrings.

You could also add it to:
https://github.com/jump-dev/MathOptInterface.jl/blob/master/docs/src/tutorials/implementing.md#implement-attributes

The attribute value type should be tested:

@test MOI.attribute_value_type(MOI.RelativeGap()) == Float64

It also needs a test for solvers implementing this. Something like:

"""
test_attribute_TimeLimitSec(model::MOI.AbstractOptimizer, config::Config)
Test that the [`MOI.TimeLimitSec`](@ref) attribute is implemented for `model`.
"""
function test_attribute_TimeLimitSec(model::MOI.AbstractOptimizer, ::Config)
@requires MOI.supports(model, MOI.TimeLimitSec())
# Get the current value to restore it at the end of the test
value = MOI.get(model, MOI.TimeLimitSec())
MOI.set(model, MOI.TimeLimitSec(), 0.0)
@test MOI.get(model, MOI.TimeLimitSec()) == 0.0
MOI.set(model, MOI.TimeLimitSec(), 1.0)
@test MOI.get(model, MOI.TimeLimitSec()) == 1.0
MOI.set(model, MOI.TimeLimitSec(), value)
@test value == MOI.get(model, MOI.TimeLimitSec()) # Equality should hold
_test_attribute_value_type(model, MOI.TimeLimitSec())
return
end
test_attribute_TimeLimitSec(::MOI.ModelLike, ::Config) = nothing
function setup_test(
::typeof(test_attribute_TimeLimitSec),
model::MOIU.MockOptimizer,
::Config,
)
MOI.set(model, MOI.TimeLimitSec(), nothing)
return
end

@odow odow merged commit a60994e into jump-dev:master Jul 17, 2022
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