@@ -57,6 +57,29 @@ function dual_set end
57
57
58
58
dual_set (s:: AbstractSet ) = error (" Dual of $s is not implemented." )
59
59
60
+ """
61
+ dual_set_type(S::Type{<:AbstractSet})
62
+
63
+ Return the type of dual set of sets of type `S`, as returned by
64
+ [`dual_set`](@ref). If the dual cone is not defined it returns an error.
65
+
66
+ ### Examples
67
+
68
+ ```jldocstest
69
+ julia> dual_set_type(Reals)
70
+ Zeros
71
+
72
+ julia> dual_set_type(SecondOrderCone)
73
+ SecondOrderCone
74
+
75
+ julia> dual_set_type(ExponentialCone)
76
+ DualExponentialCone
77
+ ```
78
+ """
79
+ function dual_set_type end
80
+
81
+ dual_set_type (S:: Type{<:AbstractSet} ) = error (" Dual type of $S is not implemented." )
82
+
60
83
"""
61
84
AbstractScalarSet
62
85
@@ -87,6 +110,7 @@ struct Reals <: AbstractVectorSet
87
110
end
88
111
89
112
dual_set (s:: Reals ) = Zeros (dimension (s))
113
+ dual_set_type (:: Type{Reals} ) = Zeros
90
114
91
115
"""
92
116
Zeros(dimension)
@@ -98,6 +122,7 @@ struct Zeros <: AbstractVectorSet
98
122
end
99
123
100
124
dual_set (s:: Zeros ) = Reals (dimension (s))
125
+ dual_set_type (:: Type{Zeros} ) = Reals
101
126
102
127
"""
103
128
Nonnegatives(dimension)
@@ -109,6 +134,7 @@ struct Nonnegatives <: AbstractVectorSet
109
134
end
110
135
111
136
dual_set (s:: Nonnegatives ) = copy (s)
137
+ dual_set_type (:: Type{Nonnegatives} ) = Nonnegatives
112
138
113
139
"""
114
140
Nonpositives(dimension)
@@ -120,6 +146,7 @@ struct Nonpositives <: AbstractVectorSet
120
146
end
121
147
122
148
dual_set (s:: Nonpositives ) = copy (s)
149
+ dual_set_type (:: Type{Nonpositives} ) = Nonpositives
123
150
124
151
"""
125
152
GreaterThan{T <: Real}(lower::T)
@@ -198,6 +225,7 @@ struct NormInfinityCone <: AbstractVectorSet
198
225
end
199
226
200
227
dual_set (s:: NormInfinityCone ) = NormOneCone (dimension (s))
228
+ dual_set_type (:: Type{NormInfinityCone} ) = NormOneCone
201
229
202
230
"""
203
231
NormOneCone(dimension)
@@ -209,6 +237,7 @@ struct NormOneCone <: AbstractVectorSet
209
237
end
210
238
211
239
dual_set (s:: NormOneCone ) = NormInfinityCone (dimension (s))
240
+ dual_set_type (:: Type{NormOneCone} ) = NormInfinityCone
212
241
213
242
"""
214
243
SecondOrderCone(dimension)
@@ -220,6 +249,7 @@ struct SecondOrderCone <: AbstractVectorSet
220
249
end
221
250
222
251
dual_set (s:: SecondOrderCone ) = copy (s)
252
+ dual_set_type (:: Type{SecondOrderCone} ) = SecondOrderCone
223
253
224
254
"""
225
255
RotatedSecondOrderCone(dimension)
@@ -231,6 +261,7 @@ struct RotatedSecondOrderCone <: AbstractVectorSet
231
261
end
232
262
233
263
dual_set (s:: RotatedSecondOrderCone ) = copy (s)
264
+ dual_set_type (:: Type{RotatedSecondOrderCone} ) = RotatedSecondOrderCone
234
265
235
266
"""
236
267
GeometricMeanCone(dimension)
@@ -249,6 +280,7 @@ The 3-dimensional exponential cone ``\\{ (x,y,z) \\in \\mathbb{R}^3 : y \\exp (x
249
280
struct ExponentialCone <: AbstractVectorSet end
250
281
251
282
dual_set (s:: ExponentialCone ) = DualExponentialCone ()
283
+ dual_set_type (:: Type{ExponentialCone} ) = DualExponentialCone
252
284
253
285
"""
254
286
DualExponentialCone()
@@ -258,6 +290,7 @@ The 3-dimensional dual exponential cone ``\\{ (u,v,w) \\in \\mathbb{R}^3 : -u \\
258
290
struct DualExponentialCone <: AbstractVectorSet end
259
291
260
292
dual_set (s:: DualExponentialCone ) = ExponentialCone ()
293
+ dual_set_type (:: Type{DualExponentialCone} ) = ExponentialCone
261
294
262
295
"""
263
296
PowerCone{T <: Real}(exponent::T)
@@ -269,6 +302,7 @@ struct PowerCone{T <: Real} <: AbstractVectorSet
269
302
end
270
303
271
304
dual_set (s:: PowerCone{T} ) where T <: Real = DualPowerCone {T} (s. exponent)
305
+ dual_set_type (:: Type{PowerCone{T}} ) where T <: Real = DualPowerCone{T}
272
306
273
307
"""
274
308
DualPowerCone{T <: Real}(exponent::T)
@@ -280,6 +314,7 @@ struct DualPowerCone{T <: Real} <: AbstractVectorSet
280
314
end
281
315
282
316
dual_set (s:: DualPowerCone{T} ) where T <: Real = PowerCone {T} (s. exponent)
317
+ dual_set_type (:: Type{DualPowerCone{T}} ) where T <: Real = PowerCone{T}
283
318
284
319
dimension (s:: Union{ExponentialCone, DualExponentialCone, PowerCone, DualPowerCone} ) = 3
285
320
@@ -308,6 +343,7 @@ struct NormSpectralCone <: AbstractVectorSet
308
343
end
309
344
310
345
dual_set (s:: NormSpectralCone ) = NormNuclearCone (s. row_dim, s. column_dim)
346
+ dual_set_type (:: Type{NormSpectralCone} ) = NormNuclearCone
311
347
312
348
"""
313
349
NormNuclearCone(row_dim, column_dim)
@@ -321,6 +357,7 @@ struct NormNuclearCone <: AbstractVectorSet
321
357
end
322
358
323
359
dual_set (s:: NormNuclearCone ) = NormSpectralCone (s. row_dim, s. column_dim)
360
+ dual_set_type (:: Type{NormNuclearCone} ) = NormSpectralCone
324
361
325
362
dimension (s:: Union{NormSpectralCone, NormNuclearCone} ) = 1 + s. row_dim * s. column_dim
326
363
@@ -498,6 +535,7 @@ struct PositiveSemidefiniteConeTriangle <: AbstractSymmetricMatrixSetTriangle
498
535
end
499
536
500
537
dual_set (s:: PositiveSemidefiniteConeTriangle ) = copy (s)
538
+ dual_set_type (:: Type{PositiveSemidefiniteConeTriangle} ) = PositiveSemidefiniteConeTriangle
501
539
502
540
"""
503
541
PositiveSemidefiniteConeSquare(side_dimension) <: AbstractSymmetricMatrixSetSquare
@@ -527,9 +565,15 @@ struct PositiveSemidefiniteConeSquare <: AbstractSymmetricMatrixSetSquare
527
565
side_dimension:: Int
528
566
end
529
567
530
- function dual_set (s:: PositiveSemidefiniteConeSquare )
531
- return error (""" Dual of $s is not defined in MathOptInterface.
532
- For more details see the comments in src/Bridges/Constraint/square.jl""" )
568
+ function _dual_set_square_error ()
569
+ error (""" Dual of `PositiveSemidefiniteConeSquare` is not defined in MathOptInterface.
570
+ For more details see the comments in `src/Bridges/Constraint/square.jl`.""" )
571
+ end
572
+ function dual_set (:: PositiveSemidefiniteConeSquare )
573
+ _dual_set_square_error ()
574
+ end
575
+ function dual_set_type (:: Type{PositiveSemidefiniteConeSquare} )
576
+ _dual_set_square_error ()
533
577
end
534
578
535
579
triangular_form (:: Type{PositiveSemidefiniteConeSquare} ) = PositiveSemidefiniteConeTriangle
0 commit comments