@@ -10,6 +10,7 @@ A symbolic index for a vertex state variable.
10
10
VIndex(1, :P) # vertex 1, variable :P
11
11
VIndex(1:5, 1) # first state of vertices 1 to 5
12
12
VIndex(7, (:x,:y)) # states :x and :y of vertex 7
13
+ VIndex(2) # references the second vertex model
13
14
```
14
15
15
16
Can be used to index into objects supporting the `SymbolicIndexingInterface`,
@@ -21,6 +22,7 @@ struct VIndex{C,S} <: SymbolicStateIndex{C,S}
21
22
compidx:: C
22
23
subidx:: S
23
24
end
25
+ VIndex (ci:: Union{Symbol,Int} ) = VIndex (ci, nothing )
24
26
"""
25
27
EIndex{C,S} <: SymbolicStateIndex{C,S}
26
28
idx = EIndex(comp, sub)
@@ -33,6 +35,7 @@ A symbolic index for an edge state variable.
33
35
EIndex(1, :P) # edge 1, variable :P
34
36
EIndex(1:5, 1) # first state of edges 1 to 5
35
37
EIndex(7, (:x,:y)) # states :x and :y of edge 7
38
+ EIndex(2) # references the second edge model
36
39
```
37
40
38
41
Can be used to index into objects supporting the `SymbolicIndexingInterface`,
@@ -44,6 +47,7 @@ struct EIndex{C,S} <: SymbolicStateIndex{C,S}
44
47
compidx:: C
45
48
subidx:: S
46
49
end
50
+ EIndex (ci:: Union{Symbol,Int} ) = EIndex (ci, nothing )
47
51
"""
48
52
VPIndex{C,S} <: SymbolicStateIndex{C,S}
49
53
idx = VPIndex(comp, sub)
@@ -1168,3 +1172,11 @@ end
1168
1172
1169
1173
Base. getindex (s:: NWState , idx:: ObservableExpression ) = SII. getu (s, idx)(s)
1170
1174
Base. getindex (s:: NWParameter , idx:: ObservableExpression ) = SII. getp (s, idx)(s)
1175
+
1176
+ # using getindex to access component models
1177
+ function Base. getindex (nw:: Network , i:: EIndex{<:Union{Symbol,Int}, Nothing} )
1178
+ return nw. im. edgem[resolvecompidx (nw,i)]
1179
+ end
1180
+ function Base. getindex (nw:: Network , i:: VIndex{<:Union{Symbol,Int}, Nothing} )
1181
+ return nw. im. vertexm[resolvecompidx (nw,i)]
1182
+ end
0 commit comments