11using BenchmarkTools
2-
32using ModelPredictiveControl, ControlSystemsBase, LinearAlgebra
3+
44Ts = 400.0
55sys = [ tf (1.90 ,[1800.0 ,1 ]) tf (1.90 ,[1800.0 ,1 ]) tf (1.90 ,[1800.0 ,1 ]);
66 tf (- 0.74 ,[800.0 ,1 ]) tf (0.74 ,[800.0 ,1 ]) tf (- 0.74 ,[800.0 ,1 ]) ]
7- linmodel = setop! (LinModel (sys, Ts, i_d= [3 ]), uop= [10 ,50 ], yop= [50 ,30 ], dop= [5 ])
7+
8+ const SUITE = BenchmarkGroup ()
9+
10+ # # ================== SimModel benchmarks =========================================
11+ linmodel = setop! (LinModel (sys, Ts, i_d= [3 ]), uop= [10 , 50 ], yop= [50 , 30 ], dop= [5 ])
812function f! (ẋ, x, u, d, p)
913 mul! (ẋ, p. A, x)
1014 mul! (ẋ, p. Bu, u, 1 , 1 )
@@ -17,12 +21,9 @@ function h!(y, x, d, p)
1721 return nothing
1822end
1923nonlinmodel = NonLinModel (f!, h!, Ts, 2 , 4 , 2 , 1 , p= linmodel, solver= nothing )
20- nonlinmodel = setop! (nonlinmodel, uop= [10 ,50 ], yop= [50 ,30 ], dop= [5 ])
21- u, d = [10 , 50 ], [5 ]
24+ nonlinmodel = setop! (nonlinmodel, uop= [10 , 50 ], yop= [50 , 30 ], dop= [5 ])
25+ u, d, y = [10 , 50 ], [5 ], [ 50 , 30 ]
2226
23- const SUITE = BenchmarkGroup ()
24-
25- # # ================== SimModel benchmarks =========================================
2627SUITE[" SimModel" ][" allocation" ] = BenchmarkGroup ([" allocation" ])
2728SUITE[" SimModel" ][" allocation" ][" LinModel_updatestate!" ] = @benchmarkable (
2829 updatestate! ($ linmodel, $ u, $ d),
@@ -47,3 +48,15 @@ SUITE["SimModel"]["allocation"]["NonLinModel_linearize!"] = @benchmarkable(
4748)
4849
4950# # ================== StateEstimator benchmarks ================================
51+ skf = SteadyKalmanFilter (linmodel)
52+
53+ SUITE[" StateEstimator" ][" allocation" ] = BenchmarkGroup ([" allocation" ])
54+ SUITE[" StateEstimator" ][" allocation" ][" SteadyKalmanFilter_preparestate!" ] = @benchmarkable (
55+ preparestate! ($ skf, $ y, $ d),
56+ samples= 1
57+ )
58+ SUITE[" StateEstimator" ][" allocation" ][" SteadyKalmanFilter_update!" ] = @benchmarkable (
59+ updatestate! ($ skf, $ u, $ y, $ d),
60+ setup= preparestate! ($ skf, $ y, $ d),
61+ samples= 1
62+ )
0 commit comments