Skip to content

Commit 1effd93

Browse files
authored
Add support for distance_to_set and the Parameter set (#2889)
1 parent f25bf63 commit 1effd93

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ 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+
return
68+
end
69+
6470
function test_interval()
6571
_test_set(MOI.Interval(1.0, 2.0), 1.0 => 0.0, 0.5 => 0.5, 2.75 => 0.75)
6672
return

0 commit comments

Comments
 (0)