661661 u = moveinput! (nmpc)
662662 @test u ≈ [4 ] atol= 5e-2
663663 linmodel2 = LinModel ([tf (5 , [2000 , 1 ]) tf (7 , [8000 ,1 ])], 3000.0 , i_d= [2 ])
664- f = (x,u,d,_ ) -> linmodel2 . A* x + linmodel2 . Bu* u + linmodel2 . Bd* d
665- h = (x,d,_ ) -> linmodel2 . C* x + linmodel2 . Dd* d
666- nonlinmodel = NonLinModel (f, h, 3000.0 , 1 , 2 , 1 , 1 , solver= nothing )
664+ f = (x,u,d,model ) -> model . A* x + model . Bu* u + model . Bd* d
665+ h = (x,d,model ) -> model . C* x + model . Dd* d
666+ nonlinmodel = NonLinModel (f, h, 3000.0 , 1 , 2 , 1 , 1 , solver= nothing , p = linmodel2 )
667667 nmpc2 = NonLinMPC (nonlinmodel, Nwt= [0 ], Hp= 100 , Hc= 1 )
668668 preparestate! (nmpc2, [0 ], [0 ])
669669 # if d=[0.1], the output will eventually reach 7*0.1=0.7, no action needed (u=0):
@@ -684,13 +684,22 @@ end
684684 u = moveinput! (nmpc4, [0 ], d, R̂u= fill (12 , nmpc4. Hp))
685685 @test u ≈ [12 ] atol= 5e-2
686686 linmodel3 = LinModel {Float32} (0.5 * ones (1 ,1 ), ones (1 ,1 ), ones (1 ,1 ), 0 , 0 , 3000.0 )
687+ nmpc5 = NonLinMPC (nonlinmodel, Hp= 1 , Hc= 1 , Cwt= Inf , transcription= MultipleShooting ())
688+ nmpc5 = setconstraint! (nmpc5, ymin= [1 ])
689+ # execute update_predictions! branch in `gfunc_i` for coverage:
690+ g_Y0min_end = nmpc5. optim[:g_Y0min_1 ]. func
691+ println (nmpc5. Z̃)
692+ @test_nowarn g_Y0min_end (10.0 , 9.0 , 8.0 , 7.0 )
693+ # execute update_predictions! branch in `geqfunc_i` for coverage:
694+ geq_end = nmpc5. optim[:geq_2 ]. func
695+ @test_nowarn geq_end (5.0 , 4.0 , 3.0 , 2.0 )
687696 nmpc6 = NonLinMPC (linmodel3, Hp= 10 )
688697 preparestate! (nmpc6, [0 ])
689698 @test moveinput! (nmpc6, [0 ]) ≈ [0.0 ]
690699 nonlinmodel2 = NonLinModel {Float32} (f, h, 3000.0 , 1 , 2 , 1 , 1 , solver= nothing )
691700 nmpc7 = NonLinMPC (nonlinmodel2, Hp= 10 )
692701 y = similar (nonlinmodel2. yop)
693- nonlinmodel2. h! (y, Float32[0 ,0 ], Float32[0 ], Float32[] )
702+ nonlinmodel2. h! (y, Float32[0 ,0 ], Float32[0 ], nonlinmodel2 . p )
694703 preparestate! (nmpc7, [0 ], [0 ])
695704 @test moveinput! (nmpc7, [0 ], [0 ]) ≈ [0.0 ]
696705 nmpc8 = NonLinMPC (nonlinmodel, Nwt= [0 ], Hp= 100 , Hc= 1 , transcription= MultipleShooting ())
0 commit comments