@@ -20,73 +20,12 @@ julia> y = model()
20
20
"""
21
21
abstract type SimModel{NT<: Real } end
22
22
23
- struct JacobianBuffer{
24
- NT<: Real ,
25
- FX<: Function ,
26
- FU<: Function ,
27
- FD<: Function ,
28
- HX<: Function ,
29
- HU<: Function ,
30
- CFX<: ForwardDiff.JacobianConfig ,
31
- CFU<: ForwardDiff.JacobianConfig ,
32
- CFD<: ForwardDiff.JacobianConfig ,
33
- CHU<: ForwardDiff.JacobianConfig ,
34
- CHX<: ForwardDiff.JacobianConfig
35
- }
36
- xnext:: Vector{NT}
37
- x:: Vector{NT}
38
- y:: Vector{NT}
39
- u:: Vector{NT}
40
- d:: Vector{NT}
41
- f_x!:: FX
42
- f_u!:: FU
43
- f_d!:: FD
44
- h_x!:: HX
45
- h_d!:: HU
46
- f_x_cfg:: CFX
47
- f_u_cfg:: CFU
48
- f_d_cfg:: CFD
49
- h_x_cfg:: CHX
50
- h_d_cfg:: CHU
51
- end
52
-
53
- """
54
- JacobianBuffer(NT::DataType, f!::Function, h!::Function, nx, nu, ny, nd)
55
-
56
- Buffer object for calling `ForwardDiff.jacobian!` on `SimModel` without any allocation.
57
- """
58
- function JacobianBuffer {NT} (
59
- f!:: Function , h!:: Function , nx:: Int , nu:: Int , ny:: Int , nd:: Int
60
- ) where NT <: Real
61
- xnext = Vector {NT} (undef, nx)
62
- x = Vector {NT} (undef, nx)
63
- y = Vector {NT} (undef, ny)
64
- u = Vector {NT} (undef, nu)
65
- d = Vector {NT} (undef, nd)
66
- f_x! (y, x) = f! (y, x, u, d)
67
- f_u! (y, u) = f! (y, x, u, d)
68
- f_d! (y, d) = f! (y, x, u, d)
69
- h_x! (y, x) = h! (y, x, d)
70
- h_d! (y, d) = h! (y, x, d)
71
- f_x_cfg = ForwardDiff. JacobianConfig (f_x!, xnext, x)
72
- f_u_cfg = ForwardDiff. JacobianConfig (f_u!, xnext, u)
73
- f_d_cfg = ForwardDiff. JacobianConfig (f_d!, xnext, d)
74
- h_x_cfg = ForwardDiff. JacobianConfig (h_x!, y, x)
75
- h_d_cfg = ForwardDiff. JacobianConfig (h_d!, y, d)
76
- return JacobianBuffer (
77
- xnext, x, y, u, d,
78
- f_x!, f_u!, f_d!, h_x!, h_d!,
79
- f_x_cfg, f_u_cfg, f_d_cfg, h_x_cfg, h_d_cfg
80
- )
81
- end
82
-
83
- struct SimModelBuffer{NT<: Real , JB<: Union{JacobianBuffer, Nothing} }
23
+ struct SimModelBuffer{NT<: Real }
84
24
u:: Vector{NT}
85
25
x:: Vector{NT}
86
26
y:: Vector{NT}
87
27
d:: Vector{NT}
88
28
empty:: Vector{NT}
89
- jacobian:: JB
90
29
end
91
30
92
31
@doc raw """
@@ -96,15 +35,13 @@ Create a buffer for `SimModel` objects for inputs, states, outputs, and disturba
96
35
97
36
The buffer is used to store intermediate results during simulation without allocating.
98
37
"""
99
- function SimModelBuffer {NT} (
100
- nu:: Int , nx:: Int , ny:: Int , nd:: Int , jacobian:: JB = nothing
101
- ) where {NT <: Real , JB <: Union{JacobianBuffer, Nothing} }
38
+ function SimModelBuffer {NT} (nu:: Int , nx:: Int , ny:: Int , nd:: Int ) where {NT <: Real }
102
39
u = Vector {NT} (undef, nu)
103
40
x = Vector {NT} (undef, nx)
104
41
y = Vector {NT} (undef, ny)
105
42
d = Vector {NT} (undef, nd)
106
43
empty = Vector {NT} (undef, 0 )
107
- return SimModelBuffer {NT, JB } (u, x, y, d, empty, jacobian )
44
+ return SimModelBuffer {NT} (u, x, y, d, empty)
108
45
end
109
46
110
47
0 commit comments