794794 setconstraint! (nmpc_lin, ymin= [5 ,10 ],ymax= [55 , 35 ])
795795 @test all ((nmpc_lin. con. Y0min, nmpc_lin. con. Y0max) .≈ ([5 ,10 ], [55 ,35 ]))
796796 setconstraint! (nmpc_lin, c_ymin= [1.0 ,1.1 ], c_ymax= [1.2 ,1.3 ])
797- @test all ((- nmpc_lin. con. A_Ymin[:, end ], - nmpc_lin. con. A_Ymax[:, end ]) .≈ ([1.0 ,1.1 ], [1.2 ,1.3 ]))
797+ @test all ((- nmpc_lin. con. A_Ymin[:, end ], - nmpc_lin. con. A_Ymax[:, end ]) .≈
798+ ([1.0 ,1.1 ], [1.2 ,1.3 ]))
799+ setconstraint! (nmpc_lin, x̂min= [- 21 ,- 22 ,- 23 ,- 24 ,- 25 ,- 26 ], x̂max= [21 ,22 ,23 ,24 ,25 ,26 ])
800+ @test all ((nmpc_lin. con. x̂0min, nmpc_lin. con. x̂0max) .≈
801+ ([- 21 ,- 22 ,- 23 ,- 24 ,- 25 ,- 26 ], [21 ,22 ,23 ,24 ,25 ,26 ]))
802+ setconstraint! (nmpc_lin,
803+ c_x̂min= [0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ],
804+ c_x̂max= [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ]
805+ )
806+ @test all ((- nmpc_lin. con. A_x̂min[:, end ], - nmpc_lin. con. A_x̂max[:, end ]) .≈
807+ ([0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ], [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ]))
798808
799809 f = (x,u,d,_) -> linmodel1. A* x + linmodel1. Bu* u + linmodel1. Bd* d
800810 h = (x,d,_) -> linmodel1. C* x + linmodel1. Dd* d
@@ -808,17 +818,44 @@ end
808818 setconstraint! (nmpc, ymin= [- 6 , - 11 ],ymax= [55 , 35 ])
809819 @test all ((nmpc. con. Y0min, nmpc. con. Y0max) .≈ ([- 6 ,- 11 ], [55 ,35 ]))
810820 setconstraint! (nmpc, x̂min= [- 21 ,- 22 ,- 23 ,- 24 ,- 25 ,- 26 ], x̂max= [21 ,22 ,23 ,24 ,25 ,26 ])
811- @test all ((nmpc. con. x̂0min, nmpc. con. x̂0max) .≈ ([- 21 ,- 22 ,- 23 ,- 24 ,- 25 ,- 26 ], [21 ,22 ,23 ,24 ,25 ,26 ]))
821+ @test all ((nmpc. con. x̂0min, nmpc. con. x̂0max) .≈
822+ ([- 21 ,- 22 ,- 23 ,- 24 ,- 25 ,- 26 ], [21 ,22 ,23 ,24 ,25 ,26 ]))
812823
813824 setconstraint! (nmpc, c_umin= [0.01 ,0.02 ], c_umax= [0.03 ,0.04 ])
814- @test all ((- nmpc. con. A_Umin[:, end ], - nmpc. con. A_Umax[:, end ]) .≈ ([0.01 ,0.02 ], [0.03 ,0.04 ]))
825+ @test all ((- nmpc. con. A_Umin[:, end ], - nmpc. con. A_Umax[:, end ]) .≈
826+ ([0.01 ,0.02 ], [0.03 ,0.04 ]))
815827 setconstraint! (nmpc, c_Δumin= [0.05 ,0.06 ], c_Δumax= [0.07 ,0.08 ])
816- @test all ((- nmpc. con. A_ΔŨmin[1 : end - 1 , end ], - nmpc. con. A_ΔŨmax[1 : end - 1 , end ]) .≈ ([0.05 ,0.06 ], [0.07 ,0.08 ]))
828+ @test all ((- nmpc. con. A_ΔŨmin[1 : end - 1 , end ], - nmpc. con. A_ΔŨmax[1 : end - 1 , end ]) .≈
829+ ([0.05 ,0.06 ], [0.07 ,0.08 ]))
817830 setconstraint! (nmpc, c_ymin= [1.00 ,1.01 ], c_ymax= [1.02 ,1.03 ])
818831 @test all ((- nmpc. con. A_Ymin, - nmpc. con. A_Ymax) .≈ (zeros (0 ,3 ), zeros (0 ,3 )))
819832 @test all ((nmpc. con. C_ymin, nmpc. con. C_ymax) .≈ ([1.00 ,1.01 ], [1.02 ,1.03 ]))
820- setconstraint! (nmpc, c_x̂min= [0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ], c_x̂max= [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ])
821- @test all ((nmpc. con. c_x̂min, nmpc. con. c_x̂max) .≈ ([0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ], [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ]))
833+ setconstraint! (nmpc,
834+ c_x̂min= [0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ],
835+ c_x̂max= [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ]
836+ )
837+ @test all ((nmpc. con. c_x̂min, nmpc. con. c_x̂max) .≈
838+ ([0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ], [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ]))
839+
840+ nmpc_ms = NonLinMPC (nonlinmodel, Hp= 1 , Hc= 1 , transcription= MultipleShooting ())
841+
842+ setconstraint! (nmpc_ms, ymin= [- 6 , - 11 ],ymax= [55 , 35 ])
843+ @test all ((nmpc_ms. con. Y0min, nmpc_ms. con. Y0max) .≈ ([- 6 ,- 11 ], [55 ,35 ]))
844+ setconstraint! (nmpc_ms, x̂min= [- 21 ,- 22 ,- 23 ,- 24 ,- 25 ,- 26 ], x̂max= [21 ,22 ,23 ,24 ,25 ,26 ])
845+ @test all ((nmpc_ms. con. x̂0min, nmpc_ms. con. x̂0max) .≈
846+ ([- 21 ,- 22 ,- 23 ,- 24 ,- 25 ,- 26 ], [21 ,22 ,23 ,24 ,25 ,26 ]))
847+
848+ setconstraint! (nmpc_ms, c_ymin= [1.00 ,1.01 ], c_ymax= [1.02 ,1.03 ])
849+ @test all ((- nmpc_ms. con. A_Ymin, - nmpc_ms. con. A_Ymax) .≈ (zeros (0 ,9 ), zeros (0 ,9 )))
850+ @test all ((nmpc_ms. con. C_ymin, nmpc_ms. con. C_ymax) .≈ ([1.00 ,1.01 ], [1.02 ,1.03 ]))
851+ setconstraint! (nmpc_ms,
852+ c_x̂min= [0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ],
853+ c_x̂max= [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ]
854+ )
855+ @test all ((- nmpc_lin. con. A_x̂min[:, end ], - nmpc_lin. con. A_x̂max[:, end ]) .≈
856+ ([0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ], [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ]))
857+ @test all ((nmpc_ms. con. c_x̂min, nmpc_ms. con. c_x̂max) .≈
858+ ([0.21 ,0.22 ,0.23 ,0.24 ,0.25 ,0.26 ], [0.31 ,0.32 ,0.33 ,0.34 ,0.35 ,0.36 ]))
822859
823860end
824861
0 commit comments