Skip to content

Conversation

@blegat
Copy link
Member

@blegat blegat commented May 10, 2021

Needed for jump-dev/Clp.jl#111. With this PR, lower_bound and upper_bound are now part of the API since it's documented so Clp can use it directly.

_no_lower_bound(::Type{T}) where {T} = zero(T)
_no_lower_bound(::Type{T}) where {T<:AbstractFloat} = typemin(T)
_no_upper_bound(::Type{T}) where {T} = zero(T)
_no_upper_bound(::Type{T}) where {T<:AbstractFloat} = typemax(T)
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 zero(T) necessary and not just typemin(T) and typemax(T)?

Copy link
Member

Choose a reason for hiding this comment

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

Answered my own question:

julia> typemax(Complex{Int})
ERROR: MethodError: no method matching typemax(::Type{Complex{Int64}})

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, typemax(Int) is a bit scary with overflows. Maybe we can say that we don't guarantee anything for non-AbstractFloat so that we can change our mind in the future

Copy link
Member

Choose a reason for hiding this comment

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

The other option is to make the bound vectors Union{Nothing,T}?

Copy link
Member

Choose a reason for hiding this comment

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

Who uses AbstractModel with something other than an AbstractFloat at present?

Copy link
Member Author

Choose a reason for hiding this comment

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

The advantage here is that Clp can directly take the Vector{Float64} and pass it to the inner solver without the need to do any transformation: https://github.com/jump-dev/Clp.jl/pull/111/files#diff-18c6af231f3facc5ba10dd45231da349efda22ecd8d68a4661dee8027bc413a7R279-R280.
We already have a vector of flags that contains the information on whether a bound is set or not.
So the value of the bound if it is not set does not alter the MOI API.
Using Union{Nothing,T} would make things slower, unallow Clp and friends to use it directly and would not bring any advantage.

@blegat blegat force-pushed the bl/unset_bounds branch from e9ff9df to 77d3252 Compare May 12, 2021 02:43
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.

For now, this is at least just a copy of existing behavior for non-floats.

@blegat blegat merged commit ab6d3ac into master May 12, 2021
@blegat blegat deleted the bl/unset_bounds branch May 12, 2021 10:16
@blegat blegat added this to the v0.10 milestone May 22, 2021
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