@@ -5,7 +5,7 @@ using DataInterpolations
5
5
using BlockArrays: BlockedArray
6
6
using ModelingToolkit: t_nounits as t, D_nounits as D
7
7
using ModelingToolkit: MTKParameters, ParameterIndex, NONNUMERIC_PORTION
8
- using SciMLStructures: Tunable, Discrete, Constants
8
+ using SciMLStructures: Tunable, Discrete, Constants, Initials
9
9
using StaticArrays: SizedVector
10
10
using SymbolicIndexingInterface: is_parameter, getp
11
11
@@ -204,7 +204,7 @@ connections = [[state_feedback.input.u[i] ~ model_outputs[i] for i in 1:4]
204
204
S = get_sensitivity (closed_loop, :u )
205
205
206
206
@testset " Indexing MTKParameters with ParameterIndex" begin
207
- ps = MTKParameters (collect (1.0 : 10.0 ),
207
+ ps = MTKParameters (collect (1.0 : 10.0 ), collect ( 11.0 : 20.0 ),
208
208
(BlockedArray ([true , false , false , true ], [2 , 2 ]),
209
209
BlockedArray ([[1 2 ; 3 4 ], [2 4 ; 6 8 ]], [1 , 1 ])),
210
210
# (BlockedArray([[true, false], [false, true]]), BlockedArray([[[1 2; 3 4]], [[2 4; 6 8]]])),
@@ -213,6 +213,9 @@ S = get_sensitivity(closed_loop, :u)
213
213
@test ps[ParameterIndex (Tunable (), 1 )] == 1.0
214
214
@test ps[ParameterIndex (Tunable (), 2 : 4 )] == collect (2.0 : 4.0 )
215
215
@test ps[ParameterIndex (Tunable (), reshape (4 : 7 , 2 , 2 ))] == reshape (4.0 : 7.0 , 2 , 2 )
216
+ @test ps[ParameterIndex (Initials (), 1 )] == 11.0
217
+ @test ps[ParameterIndex (Initials (), 2 : 4 )] == collect (12.0 : 14.0 )
218
+ @test ps[ParameterIndex (Initials (), reshape (4 : 7 , 2 , 2 ))] == reshape (14.0 : 17.0 , 2 , 2 )
216
219
@test ps[ParameterIndex (Discrete (), (2 , 1 , 2 , 2 ))] == 4
217
220
@test ps[ParameterIndex (Discrete (), (2 , 2 ))] == [2 4 ; 6 8 ]
218
221
@test ps[ParameterIndex (Constants (), (1 , 1 ))] == 5
@@ -221,8 +224,12 @@ S = get_sensitivity(closed_loop, :u)
221
224
ps[ParameterIndex (Tunable (), 1 )] = 1.5
222
225
ps[ParameterIndex (Tunable (), 2 : 4 )] = [2.5 , 3.5 , 4.5 ]
223
226
ps[ParameterIndex (Tunable (), reshape (5 : 8 , 2 , 2 ))] = [5.5 7.5 ; 6.5 8.5 ]
227
+ ps[ParameterIndex (Initials (), 1 )] = 11.5
228
+ ps[ParameterIndex (Initials (), 2 : 4 )] = [12.5 , 13.5 , 14.5 ]
229
+ ps[ParameterIndex (Initials (), reshape (5 : 8 , 2 , 2 ))] = [15.5 17.5 ; 16.5 18.5 ]
224
230
ps[ParameterIndex (Discrete (), (2 , 1 , 2 , 2 ))] = 5
225
231
@test ps[ParameterIndex (Tunable (), 1 : 8 )] == collect (1.0 : 8.0 ) .+ 0.5
232
+ @test ps[ParameterIndex (Initials (), 1 : 8 )] == collect (11.0 : 18.0 ) .+ 0.5
226
233
@test ps[ParameterIndex (Discrete (), (2 , 1 , 2 , 2 ))] == 5
227
234
end
228
235
0 commit comments