File tree Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -7,26 +7,43 @@ Abstract supertype for set objects used to encode constraints.
7
7
"""
8
8
abstract type AbstractSet end
9
9
10
+ """
11
+ dimension(s::AbstractSet)
12
+
13
+ Return the output dimension that an [`AbstractFunction`](@ref) should have to be used with the set `s`.
14
+
15
+ ### Examples
16
+
17
+ ```julia-repl
18
+ julia> dimension(Reals(4))
19
+ 4
20
+
21
+ julia> dimension(LessThan(3.0))
22
+ 1
23
+
24
+ julia> dimension(PositiveSemidefiniteConeTriangle(2))
25
+ 3
26
+ ```
27
+
28
+ """
29
+ function dimension end
30
+
10
31
"""
11
32
AbstractScalarSet
12
33
13
34
Abstract supertype for subsets of ``\\ mathbb{R}``.
14
35
"""
15
36
abstract type AbstractScalarSet <: AbstractSet end
16
37
38
+ dimension (s:: AbstractScalarSet ) = 1
39
+
17
40
"""
18
41
AbstractVectorSet
19
42
20
43
Abstract supertype for subsets of ``\\ mathbb{R}^n`` for some ``n``.
21
44
"""
22
45
abstract type AbstractVectorSet <: AbstractSet end
23
46
24
- """
25
- dimension(s::AbstractVectorSet)
26
-
27
- Return the underlying dimension (number of vector components) in the set `s`, i.e.,
28
- ``n`` if the set is a subset of ``\\ mathbb{R}^n``.
29
- """
30
47
dimension (s:: AbstractVectorSet ) = s. dimension # .dimension field is conventional, overwrite this method if not applicable
31
48
32
49
"""
Original file line number Diff line number Diff line change 3
3
@test MOIU. getconstant (MOI. GreaterThan (6 )) == 6
4
4
@test MOIU. getconstant (MOI. LessThan (2 )) == 2
5
5
end
6
+
7
+ @testset " Set dimension" begin
8
+ @test MOI. dimension (MOI. EqualTo (3.0 )) === 1
9
+ @test MOI. dimension (MOI. Reals (8 )) === 8
10
+ @test MOI. dimension (MOI. DualExponentialCone ()) === 3
11
+ @test MOI. dimension (MOI. PositiveSemidefiniteConeTriangle (4 )) === 10
12
+ @test MOI. dimension (MOI. PositiveSemidefiniteConeSquare (5 )) === 25
13
+ @test MOI. dimension (MOI. RootDetConeTriangle (6 )) === 22
14
+ @test MOI. dimension (MOI. LogDetConeTriangle (6 )) === 22
15
+ @test MOI. dimension (MOI. RootDetConeSquare (4 )) === 17
16
+ @test MOI. dimension (MOI. LogDetConeSquare (4 )) === 17
17
+ @test MOI. dimension (MOI. SOS2 (collect (1 : 6 ))) === 6
18
+ end
You can’t perform that action at this time.
0 commit comments