Skip to content

Commit 10f9e56

Browse files
committed
distance_to_set supports Parameter set
1 parent f25bf63 commit 10f9e56

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Utilities/distance_to_set.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ function distance_to_set(
109109
return abs(set.value - x)
110110
end
111111

112+
# This is the minimal L2-norm.
113+
function distance_to_set(
114+
::ProjectionUpperBoundDistance,
115+
x::T,
116+
set::MOI.Parameter{T},
117+
) where {T<:Number}
118+
return abs(set.value - x)
119+
end
120+
112121
# This is the minimal L2-norm.
113122
function distance_to_set(
114123
::ProjectionUpperBoundDistance,

test/Utilities/distance_to_set.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ function test_equalto()
6161
return
6262
end
6363

64+
function test_parameter()
65+
_test_set(MOI.Parameter(2.0), 1.0 => 1.0)
66+
_test_set(MOI.Parameter(0.5), 1.0 => 0.5)
67+
end
68+
6469
function test_interval()
6570
_test_set(MOI.Interval(1.0, 2.0), 1.0 => 0.0, 0.5 => 0.5, 2.75 => 0.75)
6671
return

0 commit comments

Comments
 (0)