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+ ]
35Ts = 4.0
46model = setop! (LinModel (sys, Ts), uop= [10 , 10 ], yop= [50 , 30 ])
57y = model ()
@@ -65,7 +67,7 @@ initstate!(nmpc_im, nlmodel.uop, y)
6567u = nmpc_im ([55 , 30 ], ym= y)
6668sim! (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 ])
6971initstate! (nmpc_ukf, nlmodel. uop, y)
7072u = nmpc_ukf ([55 , 30 ])
7173sim! (nmpc_ukf, 3 , [55 , 30 ])
@@ -74,3 +76,12 @@ nmpc_ekf = setconstraint!(NonLinMPC(ExtendedKalmanFilter(model), Cwt=Inf), ymin=
7476initstate! (nmpc_ekf, model. uop, model ())
7577u = nmpc_ekf ([55 , 30 ])
7678sim! (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