Skip to content

Commit

Permalink
Remove ExponentialCone support
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Feb 2, 2023
1 parent 1618245 commit c3689b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
30 changes: 4 additions & 26 deletions src/Utilities/distance_to_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,35 +204,13 @@ function distance_to_set(
# Parikh, N., & Boyd, S. (2014). Proximal algorithms. Foundations and
# trends in Optimization, page 184, section 6.3.2.
t, rhs = x[1], LinearAlgebra.norm(@views x[2:end])
if t >= rhs
return zero(T) # The point is feasible!
end
if rhs <= -t # Projection to the point (0, [0])
return LinearAlgebra.norm(x)
elseif t >= rhs # Projection to the point (t, x)
return zero(T)
end
# Projection to the point (t, x) + 0.5 * (|x|_2 - t, (t/|x|_2 - 1) * x)
c = t / rhs - one(T)
return sqrt((rhs - t)^2 + sum((c * x[i])^2 for i in 2:length(x))) / 2
end

"""
distance_to_set(::ProjectionUpperBoundDistance, x, ::MOI.ExponentialCone)
Given `x = (u, v, w)`, this is distance:
return sqrt(2) / 2 * abs(t - rhs)

* `d`, such that `v * exp(u / v) <= w + d`, if `v > 0`
* `√(1^2 + d^2)`, such that `1 * exp(u / 1) <= w + d`, if `v <= 0`.
"""
function distance_to_set(
::ProjectionUpperBoundDistance,
x::AbstractVector{T},
set::MOI.ExponentialCone,
) where {T<:Real}
_check_dimension(x, set)
u, v, w = x[1], x[2], x[3]
if v <= 0
# Projection to the point (u, 1, max(w, exp(u)))
return sqrt((1 - v)^2 + max(zero(T), exp(u) - w)^2)
end
# Projection to the point (u, v, max(w, v * exp(u / v)))
return max(zero(T), v * exp(u / v) - w)
end
14 changes: 0 additions & 14 deletions test/Utilities/distance_to_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,6 @@ function test_secondordercone()
return
end

function test_exponentialcone()
@test_throws(
DimensionMismatch,
MOI.Utilities.distance_to_set([-1.0, 1.0], MOI.ExponentialCone())
)
set = MOI.ExponentialCone()
@test MOI.Utilities.distance_to_set([1, 1, exp(1)], set) 0.0
@test MOI.Utilities.distance_to_set([2, 3, 3], set) 3 * exp(2 / 3) - 3
@test MOI.Utilities.distance_to_set([2, -1, 3], set)
sqrt(2^2 + (exp(2) - 3)^2)
@test MOI.Utilities.distance_to_set([10.0, 0.01, 0.0], set) Inf
return
end

end

TestFeasibilityChecker.runtests()

0 comments on commit c3689b0

Please sign in to comment.