Skip to content

Commit d9c7de5

Browse files
committed
EMPC added to precompile calls
1 parent 1f39b48 commit d9c7de5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/precompile_calls.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
sys = [ tf(1.90, [18, 1]) tf(1.90, [18, 1]);
2-
tf(-0.74,[8, 1]) tf(0.74, [8, 1]) ]
1+
sys = [
2+
tf(1.90, [18, 1]) tf(1.90, [18, 1]);
3+
tf(-0.74,[8, 1]) tf(0.74, [8, 1])
4+
]
35
Ts = 4.0
46
model = setop!(LinModel(sys, Ts), uop=[10, 10], yop=[50, 30])
57
y = model()
@@ -65,7 +67,7 @@ initstate!(nmpc_im, nlmodel.uop, y)
6567
u = nmpc_im([55, 30], ym=y)
6668
sim!(nmpc_im, 3, [55, 30])
6769

68-
nmpc_ukf = setconstraint!(NonLinMPC(UnscentedKalmanFilter(nlmodel), Hp=10, Cwt=Inf), ymin=[45, -Inf])
70+
nmpc_ukf = setconstraint!(NonLinMPC(UnscentedKalmanFilter(nlmodel), Hp=10, Cwt=1e3), ymin=[45, -Inf])
6971
initstate!(nmpc_ukf, nlmodel.uop, y)
7072
u = nmpc_ukf([55, 30])
7173
sim!(nmpc_ukf, 3, [55, 30])
@@ -74,3 +76,12 @@ nmpc_ekf = setconstraint!(NonLinMPC(ExtendedKalmanFilter(model), Cwt=Inf), ymin=
7476
initstate!(nmpc_ekf, model.uop, model())
7577
u = nmpc_ekf([55, 30])
7678
sim!(nmpc_ekf, 3, [55, 30])
79+
80+
function JE( _ , ŶE, _ )
81+
= ŶE[3:end]
82+
Eŷ = repeat([55; 30], 10) -
83+
return dot(Eŷ, I, Eŷ)
84+
end
85+
empc = setconstraint!(NonLinMPC(nlmodel, Mwt=[0, 0], Hp=10, Cwt=Inf, Ewt=1, JE=JE), ymin=[45, -Inf])
86+
u = empc()
87+
sim!(empc, 3)

0 commit comments

Comments
 (0)