110110 @test all (p5[end - 4 ][2 ][:y ] .≈ + 101 )
111111 @test all (p5[end - 3 ][2 ][:y ] .≈ + 102 )
112112 @test all (p5[end - 2 ][2 ][:y ] .≈ + 103 )
113+ p6 = plot (res, plotxwithx̂= true , plotx̂min= true , plotx̂max= false )
114+ @test p6[1 ][1 ][:x ] ≈ res. T_data
115+ @test all (p6[end - 5 ][3 ][:y ] .≈ - 100 )
116+ @test all (p6[end - 4 ][3 ][:y ] .≈ - 101 )
117+ @test all (p6[end - 3 ][3 ][:y ] .≈ - 102 )
118+ @test all (p6[end - 2 ][3 ][:y ] .≈ - 103 )
119+ p7 = plot (res, plotxwithx̂= true , plotx̂min= false , plotx̂max= true )
120+ @test p7[1 ][1 ][:x ] ≈ res. T_data
121+ @test all (p7[end - 5 ][3 ][:y ] .≈ + 100 )
122+ @test all (p7[end - 4 ][3 ][:y ] .≈ + 101 )
123+ @test all (p7[end - 3 ][3 ][:y ] .≈ + 102 )
124+ @test all (p7[end - 2 ][3 ][:y ] .≈ + 103 )
113125end
114126
115127@testset " PredictiveController quick simulation" begin
147159end
148160
149161@testset " PredictiveController Plots" begin
150- mpc = LinMPC (LinModel (sys, Ts, i_d= [3 ]), Lwt= [0.01 , 0.01 ])
162+ estim = MovingHorizonEstimator (LinModel (sys, Ts, i_d= [3 ]), He= 5 )
163+ estim = setconstraint! (estim, x̂min= [- 100 ,- 101 ,- 102 ,- 103 ,- 104 ,- 105 ])
164+ estim = setconstraint! (estim, x̂max= [+ 100 ,+ 101 ,+ 102 ,+ 103 ,+ 104 ,+ 105 ])
165+ mpc = LinMPC (estim, Lwt= [0.01 , 0.01 ])
151166 mpc = setconstraint! (mpc, umin= [- 50 , - 51 ], umax= [52 , 53 ], ymin= [- 54 ,- 55 ], ymax= [56 ,57 ])
152167 res = sim! (mpc, 15 )
153168 p1 = plot (res, plotŷ= true )
198213 @test p8[1 ][1 ][:x ] ≈ res. T_data
199214 @test all (p8[end - 4 ][3 ][:y ] .≈ 56.0 )
200215 @test all (p8[end - 3 ][3 ][:y ] .≈ 57.0 )
216+ p9 = plot (res, plotx̂= true , plotx̂min= true , plotx̂max= false )
217+ @test p9[1 ][1 ][:x ] ≈ res. T_data
218+ @test all (p9[end - 5 ][2 ][:y ] .≈ - 100.0 )
219+ @test all (p9[end - 4 ][2 ][:y ] .≈ - 101.0 )
220+ @test all (p9[end - 3 ][2 ][:y ] .≈ - 102.0 )
221+ @test all (p9[end - 2 ][2 ][:y ] .≈ - 103.0 )
222+ @test all (p9[end - 1 ][2 ][:y ] .≈ - 104.0 )
223+ @test all (p9[end - 0 ][2 ][:y ] .≈ - 105.0 )
224+ p10 = plot (res, plotx̂= true , plotx̂min= false , plotx̂max= true )
225+ @test p10[1 ][1 ][:x ] ≈ res. T_data
226+ @test all (p10[end - 5 ][2 ][:y ] .≈ + 100.0 )
227+ @test all (p10[end - 4 ][2 ][:y ] .≈ + 101.0 )
228+ @test all (p10[end - 3 ][2 ][:y ] .≈ + 102.0 )
229+ @test all (p10[end - 2 ][2 ][:y ] .≈ + 103.0 )
230+ @test all (p10[end - 1 ][2 ][:y ] .≈ + 104.0 )
231+ @test all (p10[end - 0 ][2 ][:y ] .≈ + 105.0 )
232+ p11 = plot (res, plotxwithx̂= true , plotx̂min= true , plotx̂max= false )
233+ @test p11[1 ][1 ][:x ] ≈ res. T_data
234+ @test all (p11[end - 5 ][3 ][:y ] .≈ - 100.0 )
235+ @test all (p11[end - 4 ][3 ][:y ] .≈ - 101.0 )
236+ @test all (p11[end - 3 ][3 ][:y ] .≈ - 102.0 )
237+ @test all (p11[end - 2 ][3 ][:y ] .≈ - 103.0 )
238+ @test all (p11[end - 1 ][2 ][:y ] .≈ - 104.0 )
239+ @test all (p11[end - 0 ][2 ][:y ] .≈ - 105.0 )
240+ p12 = plot (res, plotxwithx̂= true , plotx̂min= false , plotx̂max= true )
241+ @test p12[1 ][1 ][:x ] ≈ res. T_data
242+ @test all (p12[end - 5 ][3 ][:y ] .≈ + 100.0 )
243+ @test all (p12[end - 4 ][3 ][:y ] .≈ + 101.0 )
244+ @test all (p12[end - 3 ][3 ][:y ] .≈ + 102.0 )
245+ @test all (p12[end - 2 ][3 ][:y ] .≈ + 103.0 )
246+ @test all (p12[end - 1 ][2 ][:y ] .≈ + 104.0 )
247+ @test all (p12[end - 0 ][2 ][:y ] .≈ + 105.0 )
201248end
0 commit comments