第七章模型预测控制算法之五~5---Matlab71杨根科上海交通大学自动化系2009年3月内容提要Matlab6.5例子Matlab7.1例子TheModelPredictiveControlTheModelPredictiveControl(MPC)ToolboxisacollectionofMATLABfunctionsforSISOorMIMOoptimalcontrolwhenthereareconstraintsoninputsand/orstates.MPC(akaDMC,IDCOM,MAC,etc.)isthemostwidelyusedmultivariablecontrolmethodinchemicalprocesscontrolandrelatedindustries,andisseeingincreaseduseinotherareas.MPCToolsallowslinearstep-response,state-spaceandtransferfunctionmodelstobeusedasthebasisofcontrollerdesign.Eitherlinearornonlinearplantmodelscanbeusedinsimulations.PuredelaycanbeincludedintheanalysisProductpageatmathworks.comTutorialCaseStudiesOn-lineImplementationofMPCTutorialMPCControlofaDoubleIntegratorMPCControlofaMulti-InputSingle-OutputSystemMPCControlofaMulti-InputMulti-OutputNonlinearSystemMPCforaNonlinearPlantUnderNonzeroNominalConditionsMPCControlwithAnticipativeActionMPCControlwithInputTargetsMPCControlofaMIMOSystemUnderPlantModelMismatchMPCControlDesignUsingaLinearizedPlantModelTutorial-DoubleIntegrator%%MPCcontrolofadoubleintegrator%ThisverysimpledemonstrationshowshowtouseMPCtocontroladouble%integratorunderinputsaturation.%Author:A.Bemporad%Copyright1990-2005TheMathWorks,Inc.%$Revision:1.1.4.3$$Date:2005/06/2723:08:23$%%%MPCobjectsetupTs=.1;%Samplingtimep=20;%Predictionhorizonm=3;%Controlhorizonmpc_controller=mpc(tf(1,[100]),Ts,p,m);%%%Specifyinputsaturationconstraintsmpc_controller.MV=struct('Min',-1,'Max',1);%%%SetupdataforthesimulationusingSimulink%%%Trueinitialstatex01=0;%Firstintegratorx02=0;%SecondintegratorTstop=5;%Simulationtimer=1;%Setpointmpc_doubleintsim('mpc_doubleint',Tstop)displayEndOfDemoMessage(mfilename)Tutorial-DoubleIntegrator备注:运行方式选择!mpc_doubleintsim('mpc_doubleint',Tstop)等价于运行sim(mpc_controller,Tstop/0.1,r)Tutorial-DoubleIntegratoru(t)y(t)r(t)uToWorkspace1yToWorkspaceOutputs/ReferencesMPCmvmorefmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdMPCController1sIntegrator21sIntegrator1InputrConstantTutorial-DoubleIntegrator010203040506000.20.40.60.811.21.40102030405060-1-0.8-0.6-0.4-0.200.20.40.60.81Tutorial-DoubleIntegratormpc_controllerSamplingtime:0.1PredictionHorizon:20ControlHorizon:3Model:Plant:[1x1tf]Disturbance:[]Noise:[]Nominal:[1x1struct]Outputdisturbancemodel:defaultmethod(typegetoutdist(mpc_controller)fordetails)DetailsonPlantmodel:--------------1manipulatedvariables--|tf|||--1measuredoutputs0measureddisturbances--|1inputs|||--0unmeasuredoutputs0unmeasureddisturbances--|1outputs|--------------Weights:(default)ManipulatedVariables:0ManipulatedVariablesRate:0.1000OutputVariables:1ECR:100000-1=MV1=1,MV1/rateisunconstrained,MO1isunconstrainedTutorial-DoubleIntegratormpc_controllermpc_controller.Tf:mpc_controller.Samplingtime?:0.1mpc_controller.p:ormpc_controller.PredictionHorizon!:20mpc_controller.mormpc_controller.ControlHorizon!:3ormpc_controller.Model.Plant=1/s^2mpc_controller.Weights:ManipulatedVariables:0ManipulatedVariablesRate:0.1000OutputVariables:1ECR:100000mpc_controller.Weights.ManipulatedVariablesRate:0.1000mpc_controller.W.ManipulatedVariablesRate:0.1000mpc_controller.-Constraints?mpc_controller.MV=!mpc_controller.MV.Min=!-1=MV1=1,MV1/rateisunconstrained,MO1isunconstrainedTutorial-MPCControlofaMulti-InputSingle-OutputSystemThisdemonstrationshowsseveralfeaturesoftheMPCtoolboxonatestsystemwithonemeasuredoutput,onemanipulatedvariable,onemeasureddisturbance,andoneunmeasureddisturbance.Tutorial-MPCControlofaMulti-InputSingle-OutputSystemMPCControlofaMulti-InputSingle-OutputsystemContentsMPCcontrollersetupClosed-loopMPCsimulationusingthecommandSIMClosed-loopMPCsimulationundermodelmismatchSofteningtheconstraintsUser-specifiedstateestimatorOpen-loopsimulationCheckingasymptoticpropertiesMPCcontrolaction(step-by-stepsimulation)LinearizationofMPCcontrollerTurningconstraintsoffMPCsimulationusingSimulinkTutorial-MPCControlofaMulti-InputSingle-OutputSystem-MPCcontrollersetup%Westartdefiningtheplanttobecontrolledsys=ss(tf({1,1,1},{[1.51],[11],[.7.51]}),'min');%%%Now,setupanMPCcontrollerobjectTs=.2;%samplingtimemodel=c2d(sys,Ts);%predictionmodel%%%Definetypeofinputsignals:thefirstsignalisamanipulatedvariable,%thesecondsignalisameasureddisturbance,thethirdoneisan%unmeasureddisturbancemodel=setmpcsignals(model,'MV',1,'MD',2,'UD',3);Tutorial-MPCControlofaMulti-InputSingle-OutputSystemSystem-MPCcontrollersetup%DefinethestructureofmodelsusedbytheMPCcontrollerModel=[];%resetstructureModelModel.Plant=model;%Disturbancemodel:Integratordrivenbywhitenoisewithvariance=1000Model.Disturbance=tf(sqrt(1000),[10]);%%%Definepredictionandcontrolhorizonsp=[];%predictionhorizon(takedefaultone)m=3;%controlhorizon%%%LetusassumedefaultvalueforweightsandbuildtheMPCobjectMPCobj=mpc(Model,Ts,p,m);%%%DefineconstraintsonthemanipulatedvariableMPCobj.MV=struct('Min',0,'Max',1,'RateMin',-10,'RateMax',10);Tutorial-MPCControlofaMulti-InputSingle-OutputSystem-MPCsimulationusingthecomm