Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Utilities/distance_to_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ function distance_to_set(
return abs(set.value - x)
end

# This is the minimal L2-norm.
function distance_to_set(
::ProjectionUpperBoundDistance,
x::T,
set::MOI.Parameter{T},
) where {T<:Number}
return abs(set.value - x)
end

# This is the minimal L2-norm.
function distance_to_set(
::ProjectionUpperBoundDistance,
Expand Down
5 changes: 5 additions & 0 deletions test/Utilities/distance_to_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ function test_equalto()
return
end

function test_parameter()
_test_set(MOI.Parameter(2.0), 1.0 => 1.0)
_test_set(MOI.Parameter(0.5), 1.0 => 0.5)
Comment thread
odow marked this conversation as resolved.
end

function test_interval()
_test_set(MOI.Interval(1.0, 2.0), 1.0 => 0.0, 0.5 => 0.5, 2.75 => 0.75)
return
Expand Down
Loading