Skip to content

Commit 073f2eb

Browse files
committed
added: preparestate! where needed in precompile file to avoid warnings
1 parent ca55d25 commit 073f2eb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/precompile.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,56 @@ y = model()
99
mpc_im = setconstraint!(LinMPC(InternalModel(model)), ymin=[45, -Inf])
1010
initstate!(mpc_im, model.uop, y)
1111
preparestate!(mpc_im, [55, 30])
12+
mpc_im.estim()
1213
u = mpc_im([55, 30])
1314
sim!(mpc_im, 3)
1415

1516
mpc_kf = setconstraint!(LinMPC(KalmanFilter(model)), ymin=[45, -Inf])
1617
initstate!(mpc_kf, model.uop, model())
18+
preparestate!(mpc_kf, [55, 30])
1719
mpc_kf.estim()
1820
u = mpc_kf([55, 30])
1921
sim!(mpc_kf, 3, [55, 30])
2022

2123
mpc_lo = setconstraint!(LinMPC(Luenberger(model)), ymin=[45, -Inf])
2224
initstate!(mpc_lo, model.uop, model())
25+
preparestate!(mpc_lo, [55, 30])
2326
mpc_lo.estim()
2427
u = mpc_lo([55, 30])
2528
sim!(mpc_lo, 3, [55, 30])
2629

2730
mpc_ukf = setconstraint!(LinMPC(UnscentedKalmanFilter(model)), ymin=[45, -Inf])
2831
initstate!(mpc_ukf, model.uop, model())
32+
preparestate!(mpc_ukf, [55, 30])
2933
mpc_ukf.estim()
3034
u = mpc_ukf([55, 3])
3135
sim!(mpc_ukf, 3, [55, 30])
3236

3337
mpc_ekf = setconstraint!(LinMPC(ExtendedKalmanFilter(model)), ymin=[45, -Inf])
3438
initstate!(mpc_ekf, model.uop, model())
39+
preparestate!(mpc_ekf, [55, 30])
3540
mpc_ekf.estim()
3641
u = mpc_ekf([55, 30])
3742
sim!(mpc_ekf, 3, [55, 30])
3843

3944
mpc_skf = setconstraint!(LinMPC(SteadyKalmanFilter(model)), ymin=[45, -Inf])
4045
initstate!(mpc_skf, model.uop, model())
46+
preparestate!(mpc_skf, [55, 30])
4147
mpc_skf.estim()
4248
u = mpc_skf([55, 30])
4349
sim!(mpc_skf, 3, [55, 30])
4450

4551
mpc_mhe = setconstraint!(LinMPC(MovingHorizonEstimator(model, He=2)), ymin=[45, -Inf])
4652
setconstraint!(mpc_mhe.estim, x̂min=[-50,-50,-50,-50], x̂max=[50,50,50,50])
4753
initstate!(mpc_mhe, model.uop, model())
54+
preparestate!(mpc_mhe, [55, 30])
4855
mpc_mhe.estim()
4956
u = mpc_mhe([55, 30])
5057
sim!(mpc_mhe, 3, [55, 30])
5158

5259
nmpc_skf = setconstraint!(NonLinMPC(SteadyKalmanFilter(model), Cwt=Inf), ymin=[45, -Inf])
5360
initstate!(nmpc_skf, model.uop, model())
61+
preparestate!(nmpc_skf, [55, 30])
5462
nmpc_skf.estim()
5563
u = nmpc_skf([55, 30])
5664
sim!(nmpc_skf, 3, [55, 30])
@@ -61,6 +69,7 @@ res_man = SimResult(model, res.U_data, res.Y_data; X_data=res.X_data)
6169

6270
exmpc = ExplicitMPC(model)
6371
initstate!(exmpc, model.uop, model())
72+
preparestate!(exmpc, [55, 30])
6473
exmpc.estim()
6574
u = exmpc([55, 30])
6675
sim!(exmpc, 3, [55, 30])
@@ -73,22 +82,26 @@ y = nlmodel()
7382
nmpc_im = setconstraint!(NonLinMPC(InternalModel(nlmodel), Hp=10, Cwt=Inf), ymin=[45, -Inf])
7483
initstate!(nmpc_im, nlmodel.uop, y)
7584
preparestate!(nmpc_im, [55, 30])
85+
nmpc_im.estim()
7686
u = nmpc_im([55, 30])
7787
sim!(nmpc_im, 3, [55, 30])
7888

7989
nmpc_ukf = setconstraint!(NonLinMPC(UnscentedKalmanFilter(nlmodel), Hp=10, Cwt=1e3), ymin=[45, -Inf])
8090
initstate!(nmpc_ukf, nlmodel.uop, y)
91+
preparestate!(nmpc_ukf, [55, 30])
8192
u = nmpc_ukf([55, 30])
8293
sim!(nmpc_ukf, 3, [55, 30])
8394

8495
nmpc_ekf = setconstraint!(NonLinMPC(ExtendedKalmanFilter(model), Cwt=Inf), ymin=[45, -Inf])
8596
initstate!(nmpc_ekf, model.uop, model())
97+
preparestate!(nmpc_ekf, [55, 30])
8698
u = nmpc_ekf([55, 30])
8799
sim!(nmpc_ekf, 3, [55, 30])
88100

89101
nmpc_mhe = setconstraint!(NonLinMPC(MovingHorizonEstimator(nlmodel, He=2), Hp=10, Cwt=Inf), ymin=[45, -Inf])
90102
setconstraint!(nmpc_mhe.estim, x̂min=[-50,-50,-50,-50], x̂max=[50,50,50,50])
91103
initstate!(nmpc_mhe, nlmodel.uop, y)
104+
preparestate!(nmpc_mhe, [55, 30])
92105
u = nmpc_mhe([55, 30])
93106
sim!(nmpc_mhe, 3, [55, 30])
94107

@@ -98,5 +111,6 @@ function JE( _ , ŶE, _ )
98111
return dot(Eŷ, I, Eŷ)
99112
end
100113
empc = setconstraint!(NonLinMPC(nlmodel, Mwt=[0, 0], Hp=10, Cwt=Inf, Ewt=1, JE=JE), ymin=[45, -Inf])
114+
preparestate!(empc, [55, 30])
101115
u = empc()
102116
sim!(empc, 3)

0 commit comments

Comments
 (0)