|
1 | 1 | using BenchmarkTools |
2 | 2 |
|
3 | | -using ModelPredictiveControl, ControlSystemsBase |
| 3 | +using ModelPredictiveControl, ControlSystemsBase, LinearAlgebra |
4 | 4 | Ts = 400.0 |
5 | 5 | sys = [ tf(1.90,[1800.0,1]) tf(1.90,[1800.0,1]) tf(1.90,[1800.0,1]); |
6 | 6 | tf(-0.74,[800.0,1]) tf(0.74,[800.0,1]) tf(-0.74,[800.0,1]) ] |
7 | 7 | linmodel = setop!(LinModel(sys, Ts, i_d=[3]), uop=[10,50], yop=[50,30], dop=[5]) |
| 8 | +function f!(ẋ, x, u, d, p) |
| 9 | + mul!(ẋ, p.A, x) |
| 10 | + mul!(ẋ, p.Bu, u, 1, 1) |
| 11 | + mul!(ẋ, p.Bd, d, 1, 1) |
| 12 | + return nothing |
| 13 | +end |
| 14 | +function h!(y, x, d, p) |
| 15 | + mul!(y, p.C, x) |
| 16 | + mul!(y, p.Dd, d, 1, 1) |
| 17 | + return nothing |
| 18 | +end |
| 19 | +nonlinmodel = NonLinModel(f!, h!, Ts, 2, 4, 2, 1, p=linmodel, solver=nothing) |
| 20 | +nonlinmodel = setop!(nonlinmodel, uop=[10,50], yop=[50,30], dop=[5]) |
8 | 21 | u, d = [10, 50], [5] |
9 | 22 |
|
10 | 23 | const SUITE = BenchmarkGroup() |
11 | 24 |
|
12 | 25 | ## ================== SimModel benchmarks ========================================= |
13 | 26 | SUITE["SimModel"]["allocation"] = BenchmarkGroup(["allocation"]) |
14 | | -SUITE["SimModel"]["allocation"]["updatestate!"] = @benchmarkable( |
| 27 | +SUITE["SimModel"]["allocation"]["LinModel_updatestate"] = @benchmarkable( |
15 | 28 | updatestate!($linmodel, $u, $d), |
16 | 29 | samples=1 |
17 | 30 | ) |
18 | | -SUITE["SimModel"]["allocation"]["evaloutput"] = @benchmarkable( |
| 31 | +SUITE["SimModel"]["allocation"]["LinModel_evaloutput"] = @benchmarkable( |
19 | 32 | evaloutput($linmodel, $d), |
20 | 33 | samples=1 |
21 | 34 | ) |
| 35 | +SUITE["SimModel"]["allocation"]["NonLinModel_updatestate"] = @benchmarkable( |
| 36 | + updatestate!($nonlinmodel, $u, $d), |
| 37 | + samples=1 |
| 38 | +) |
| 39 | +SUITE["SimModel"]["allocation"]["NonLinModel_evaloutput"] = @benchmarkable( |
| 40 | + evaloutput($nonlinmodel, $d), |
| 41 | + samples=1 |
| 42 | +) |
22 | 43 |
|
23 | 44 | ## ================== StateEstimator benchmarks ================================ |
24 | 45 |
|
|
0 commit comments