亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? nmpc.m

?? 使用matlab實現智能預測控制算法中的GPC算法
?? M
字號:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This program implements a controller that uses a planning
% strategy for the surge tank example.
%
% Kevin Passino
% Version: 4/19/01
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Initialize variables

clear

% Set the length of the simulation

Nnc=300;

T=0.1;      % Sampling rate

% As a reference input, we use a square wave (define one extra 
% point since at the last time we need the reference value at
% the last time plus one)

timeref=1:Nnc;
r(timeref)=3.25-3*square((2*pi/150)*timeref); % A square wave input
%r(timeref)=3.25*ones(1,Nnc+1)-3*(2*rand(1,Nnc+1)-ones(1,Nnc+1)); % A noise input
ref=r(1:Nnc);  % Then, use this one for plotting

time=1:Nnc;
time=T*time; % Next, make the vector real time


% We assume that the parameters of the surge tank (truth model) are:

abar=0.01;  % Parameter characterizing tank shape (nominal value is 0.01)
%abar=0.05;  % Parameter characterizing tank shape 
bbar=0.2;   % Parameter characterizing tank shape (nominal value is 0.2)
cbar=1;     % Clogging factor representing dirty filter in pump (nominally, 1)
%cbar=0.8;     % Clogging factor representing dirty filter in pump (dirty case)
dbar=1;     % Related to diameter of output pipe 
g=9.8;      % Gravity

% Controller parameters

% Model used in planning strategy:

abarm=0.002;  % Parameter characterizing tank shape 
bbarm=0.2;   % Parameter characterizing tank shape 
cbarm=0.9;  % Clogging factor representing dirty filter in pump 
dbarm=0.8;   % Related to diameter of output pipe 

% Next, use a set of preset controllers (think of each as a plan template)
% In this case we use PI controllers, with a grid of Kp, Ki gains around the 
% ones that we had designed for the PI controller for the **model**

% Guess at values 
Kp=0.01;
Ki=0.3;

%Kpvec=Kp; % Vector of gains in the region of Kp, Ki
%Kivec=Ki;

Kpvec=0:0.05:0.2; % Vector of gains in the region of Kp, Ki
%Kivec=Ki;
Kivec=0.15:0.05:0.4;

%Kpvec=0.2:0.2:1.8; % Vector of gains in the region of Kp, Ki
%Kivec=0.05:0.01:0.11;

% Set weights of cost function used to select plans
w1=1;
w2=1;

% Set the length of time that will project into the future, N
%NN=[20]; % To test just one value for N
NN=[1,5,10,15,17,20,25,30,33,35,36,37,38,39,40,45,50,51,52,53,55,56,59,60,61,65,69,70];  % To test multiple values of the projection length
N=max(NN); % For initialization, and allocation of variables below


% First, compare the truth model characteristics to the model

height=0:.1:10;

for i=1:length(height)
crosssect_truth(i,1)=abs(abar*height(i)+bbar);
crosssect_model(i,1)=abarm*height(i)^2 +bbarm;
end

figure(1)
clf
plot(height,crosssect_truth,'k-',height,crosssect_model,'k--')
grid
ylabel('Cross-sectional area')
xlabel('Height')
title('Cross-sectional area for plant (solid) and model (dashed)')


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Next, start the main loop:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for kk=1:length(NN)
	N=NN(kk); % Next projection length

	h=0*ones(1,Nnc+1);  % Allocate memory
	hp=0*ones(1,Nnc+1);
	hmm=0*ones(1,Nnc+1);
	h(1)=1;     % Initial liquid level 
	hp(1)=1;     % Initial liquid level  (for plant with a PI controller)
	hmm(1)=1;     % Initial liquid level  (for model with a PI controller)

	% Allocate memory for projection variables

	hm=0*ones(N+1,length(Kpvec),length(Kivec));
	em=0*ones(N,length(Kpvec),length(Kivec));
	um=0*ones(N,length(Kpvec),length(Kivec));

	J=0*ones(length(Kpvec),length(Kivec));
	rowindex=0*ones(1,Nnc);
	colindex=0*ones(1,Nnc);

	% Also, allocate memory for the control inputs and error

	up=0*ones(1,Nnc);
	umm=0*ones(1,Nnc);
	u=0*ones(1,Nnc);

	ep=0*ones(1,Nnc);
	emm=0*ones(1,Nnc);
	e=0*ones(1,Nnc);
	
	% Initialize controller integrator:

	sume=0;
	sumep=0;
	sumemm=0;

for k=1:Nnc

	%---------------------------------------------------------------
	% Define the controller (for plant), where test single Kp, Ki gains
	
	ep(k)=r(k)-hp(k);
	sumep=sumep+ep(k); % Compute integral approx.
	
	up(k)=Kp*ep(k)+Ki*sumep;
			
	% In implementation, the input flow is restricted 
	% by some physical contraints. So we have to put a
	% limit for the input flow that is chosen as 50.

    if up(k)>50
      up(k)=50;
    end
    if up(k)<-50
     up(k)=-50;
    end

	% Plant equations
	
	Ap=abs(abar*hp(k)+bbar); % Cross-sectional area

	alphap=hp(k)-T*dbar*sqrt(2*g*hp(k))/Ap; % Nonlinear dynamics
	betap=T*cbar/Ap;

	hp(k+1)=alphap+betap*up(k); % Compute plant output
	hp(k+1)=max([0.001,hp(k+1)]); % Constraint liquid not to go
							    % negative

	%---------------------------------------------------------------
	% Define the controller (for model), also where test single Kp, Ki
	% gains - here for the purpose of seeing how good the model is
	% (test model validity by seeing if it reacts similarly to the plant
	% for the same control system).
	
	emm(k)=r(k)-hmm(k);
	sumemm=sumemm+emm(k); % Compute integral approx.
	
	umm(k)=Kp*emm(k)+Ki*sumemm;
			
	% In implementation, the input flow is restricted 
	% by some physical contraints. So we have to put a
	% limit for the input flow that is chosen as 50.

    if umm(k)>50
      umm(k)=50;
    end
    if umm(k)<-50
     umm(k)=-50;
    end

	% Model equations
	
	Amm=abarm*hmm(k)^2 +bbarm; % Cross-sectional area (model)

	alphamm=hmm(k)-T*dbarm*sqrt(2*g*hmm(k))/Amm; % Nonlinear dynamics (model)
	betamm=T*cbarm/Amm;

	hmm(k+1)=alphamm+betamm*umm(k); % Compute plant output
	hmm(k+1)=max([0.001,hmm(k+1)]); % Constraint liquid not to go
							        % negative

	%---------------------------------------------------------------
	% Define the planner that uses the model to control the plant
	% (of course this is the primary thing that we want to study)
	
	e(k)=r(k)-h(k); % Compute error
	sume=sume+e(k); % Compute integral approx.
	

	% Projection into the future for each controller:
	
	hm(1,:,:)=h(k)*ones(length(Kpvec),length(Kivec)); % Initialize prediction with current
														% liquid level

	for ii=1:length(Kpvec)
		for jj=1:length(Kivec)  % The first two loops pick a controller
			% Initialize integral with current error integral sume, or 0 
			% (analgous to how we start the loop for the main controller)
			sumem=sume; 
			for j=1:N           % This loop simulates it at N time points

	em(j,ii,jj)=r(k)-hm(j,ii,jj); % Error for each model (assumes that r(k) will stay
									% constant over the projection window)
	sumem=sumem+em(j,ii,jj); % Compute integator for each controller
	um(j,ii,jj)=Kpvec(ii)*em(j,ii,jj)+Kivec(jj)*sumem; % Compute controller output
	
    if um(j,ii,jj)>50 % Compute saturation
      um(j,ii,jj)=50;
    end
    if um(j,ii,jj)<-50
     um(j,ii,jj)=-50;
    end

	Am=abarm*hm(j,ii,jj)^2 +bbarm; % Cross-sectional area (model)

	alpham=hm(j,ii,jj)-T*dbarm*sqrt(2*g*hm(j,ii,jj))/Am; % Nonlinear dynamics (model)
	betam=T*cbarm/Am;

	hm(j+1,ii,jj)=alpham+betam*um(j,ii,jj); % Compute plant output
	hm(j+1,ii,jj)=max([0.001,hm(j+1,ii,jj)]); % Constraint liquid not to go
							    				% negative
												
			end
		
	% Compute the cost function for the controller that was just simulated
	
	J(ii,jj)=w1*(r(k)*ones(N+1,1)-hm(1:N+1,ii,jj))'*(r(k)*ones(N+1,1)-hm(1:N+1,ii,jj))+...
	w2*um(1:N,ii,jj)'*um(1:N,ii,jj);
			
		end
	end
							
	% Find the indices of the best controller (plan)
	
	[val,rowindex(k)]=min(min(J')); % Gives the min value (val) and its row index
	[val,colindex(k)]=min(min(J)); % Gives the min value and its column index

	% Pick the input to be the one that came from the plan that did best in 
	% the projection
	
	u(k)=um(1,rowindex(k),colindex(k));
	
	% Next, put the chosen input to the plant
	
	% Input saturation

    if u(k)>50
      u(k)=50;
    end
    if u(k)<-50
     u(k)=-50;
    end

	% Plant equations
	
	A=abs(abar*h(k)+bbar); % Cross-sectional area

	alpha=h(k)-T*dbar*sqrt(2*g*h(k))/A; % Nonlinear dynamics
	beta=T*cbar/A;

	h(k+1)=alpha+beta*u(k); % Compute plant output
	h(k+1)=max([0.001,h(k+1)]); % Constraint liquid not to go
							    % negative

end

hh=h(timeref);

trackerrorenergy(kk)=0.5*(ref'-hh')'*(ref'-hh');
inputenergy(kk)=0.5*u*u';

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plot the results

% Plant: Controlled by PI controller 
% Strip off last computed value of h
hhp=hp(timeref);

figure(2)
clf
subplot(211)
plot(time,hhp,'k-',time,ref,'k--')
grid
ylabel('Liquid height, h')
title('Liquid level h and reference input r (plant)')

subplot(212)
plot(time,up,'k-')
grid
title('Tank input, u')
xlabel('Time, k')
axis([min(time) max(time) -50 50])

% Model: Controlled by PI controller
% Strip off last computed value of hmm
hhm=hmm(timeref);

figure(3)
clf
subplot(211)
plot(time,hhm,'k-',time,ref,'k--')
grid
ylabel('Liquid height, h_m')
title('Liquid level h_m and reference input r (model)')

subplot(212)
plot(time,umm,'k-')
grid
title('Tank input, u_m')
xlabel('Time, k')
axis([min(time) max(time) -50 50])

% Difference between plant and model: Controlled by PI controller
% Strip off last computed value of hmm

figure(4)
clf
subplot(211)
plot(time,hhp-hhm,'k-')
grid
title('Liquid height error')

subplot(212)
plot(time,up-umm,'k-')
grid
title('Tank input error')
xlabel('Time, k')


%-----------------------------------------------------------
% Planning system results
% Strip off last computed value of h
hh=h(timeref);

figure(5)
clf
subplot(211)
plot(time,hh,'k-',time,ref,'k--')
grid
ylabel('Liquid height, h')
title('Liquid level h and reference input r')

subplot(212)
plot(time,u,'k-')
grid
title('Tank input, u')
xlabel('Time, k')
axis([min(time) max(time) -50 50])

figure(6)
clf
plot(time,rowindex,'k-',time,colindex,'k--')
axis([min(time) max(time) 0 max(length(Kpvec),length(Kivec))])
grid
title('Indices of plan (row=solid, column=dashed)')
ylabel('Row and column indices')
xlabel('Time, k')

% Next, study the effect of the projection length N
figure(7)
clf
plot(NN,trackerrorenergy,'b-',NN,trackerrorenergy,'ro')
title('Tracking energy vs. projection length N')
xlabel('Projection length N')

figure(8)
clf
plot(NN,inputenergy,'b-',NN,inputenergy,'ro')
title('Control energy vs. projection length N')
xlabel('Projection length N')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of program
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区私人影院日本| 日韩精品亚洲一区二区三区免费| 欧美三级日韩三级国产三级| hitomi一区二区三区精品| 国产精品亚洲一区二区三区在线| 另类成人小视频在线| 日韩成人av影视| 久久精工是国产品牌吗| 精品综合久久久久久8888| 精品在线一区二区三区| 国产在线观看免费一区| 国产91精品久久久久久久网曝门 | 欧美午夜精品久久久久久超碰| 99精品视频在线观看免费| 99国产精品视频免费观看| 色婷婷综合久久久中文字幕| 精品视频在线看| 欧美一区二视频| 精品成人私密视频| 国产亚洲欧美日韩在线一区| 国产精品久久综合| 亚洲国产日韩一级| 韩国在线一区二区| 成人av网站免费观看| 日本丶国产丶欧美色综合| 欧美三级电影一区| www国产亚洲精品久久麻豆| 国产精品国产自产拍在线| 亚洲一区二区三区四区在线免费观看 | 欧美日韩免费高清一区色橹橹| 7878成人国产在线观看| 久久久久9999亚洲精品| 一级中文字幕一区二区| 免费在线一区观看| 波多野结衣亚洲一区| 51午夜精品国产| 国产精品久久久久久亚洲伦 | 日韩电影在线一区二区| 国产盗摄视频一区二区三区| 一本大道久久a久久综合| 91精品国产色综合久久| 亚洲欧美综合另类在线卡通| 亚洲高清在线视频| www.亚洲精品| 欧美一区二区三区不卡| 亚洲视频免费观看| 国产精品主播直播| 91精品国产综合久久久久久漫画| 中文字幕中文乱码欧美一区二区| 亚洲国产成人tv| a级高清视频欧美日韩| 精品久久久久99| 偷偷要91色婷婷| 91热门视频在线观看| 26uuuu精品一区二区| 性做久久久久久久免费看| 成人av在线资源网站| 精品成人一区二区| 麻豆国产精品777777在线| 欧美性猛交xxxxxx富婆| 亚洲人成伊人成综合网小说| 国产福利一区二区| 日韩欧美一区二区视频| 午夜电影网一区| 91精品国产色综合久久不卡电影 | 亚洲成人动漫一区| 97久久精品人人做人人爽 | 国产精品夫妻自拍| 国产精品系列在线观看| 欧美成人bangbros| 免费xxxx性欧美18vr| 3d动漫精品啪啪1区2区免费 | 婷婷六月综合亚洲| 欧美日韩午夜精品| 亚洲午夜视频在线| 欧美老人xxxx18| 日韩极品在线观看| 日韩三级伦理片妻子的秘密按摩| 亚洲二区在线观看| 欧美二区三区91| 奇米精品一区二区三区四区| 欧美肥妇毛茸茸| 美腿丝袜一区二区三区| 精品美女一区二区| 国产精品一卡二卡在线观看| 国产亚洲精品免费| 91在线国产福利| 亚洲精品v日韩精品| 欧美性感一区二区三区| 午夜视频一区二区| 日韩三级视频在线看| 国产精品亚洲成人| 亚洲欧洲国产日本综合| 欧美一级夜夜爽| 激情久久久久久久久久久久久久久久| 日韩精品一区二区三区视频 | 五月天激情综合| 91精品在线麻豆| 国产精华液一区二区三区| 国产精品欧美久久久久无广告| 91丨porny丨首页| 天天av天天翘天天综合网色鬼国产| 欧美一区二区美女| 粉嫩av一区二区三区在线播放| 亚洲欧美另类图片小说| 欧美挠脚心视频网站| 国产一区二区在线观看视频| 国产精品久久久久久久第一福利| 欧美伊人久久久久久午夜久久久久| 日韩av中文在线观看| 欧美国产欧美综合| 欧美日韩一区二区三区在线 | 99久久久久久99| 午夜欧美2019年伦理| 国产日韩欧美综合在线| 欧美优质美女网站| 国产美女精品人人做人人爽| 亚洲综合成人在线| 日本一区二区久久| 国产精品久久久久影院亚瑟 | 日韩欧美中文字幕精品| 91影院在线观看| 国产麻豆成人精品| 亚洲高清在线视频| 国产精品久久久久久久久免费桃花| 91精品国产欧美一区二区18| 91污片在线观看| 国产精品影视天天线| 免费精品视频在线| 日韩一区二区高清| 国产精品123区| 天天综合色天天综合色h| 国产视频一区二区在线观看| 欧美一区三区四区| 欧美做爰猛烈大尺度电影无法无天| 国产专区综合网| 青青草91视频| 亚洲成a人片在线观看中文| 综合激情网...| 国产精品婷婷午夜在线观看| 欧美成人性战久久| 日韩欧美一区二区久久婷婷| 色综合久久综合中文综合网| 成人性视频免费网站| 国产精品资源网站| 国产一区二区三区最好精华液| 奇米综合一区二区三区精品视频| 一区二区三区在线视频观看58| 国产精品久久久久久久久晋中 | 日本最新不卡在线| 亚洲高清免费观看 | 日韩欧美国产一区二区在线播放| 精品污污网站免费看| 色婷婷av一区| 欧美自拍偷拍午夜视频| 91美女精品福利| 在线亚洲+欧美+日本专区| 色婷婷激情综合| 欧美三级乱人伦电影| 欧美日韩你懂得| 日韩一区二区三区四区五区六区| 欧美精品一二三四| 日韩欧美在线综合网| 欧美精品一区二区三区在线| 欧美成人r级一区二区三区| 2019国产精品| 国产精品亲子伦对白| 亚洲色图在线看| 亚洲国产成人精品视频| 蜜桃一区二区三区四区| 国产麻豆成人精品| zzijzzij亚洲日本少妇熟睡| 色噜噜久久综合| 91麻豆精品国产91| 国产日本欧洲亚洲| 午夜精品免费在线观看| 亚洲精品国产一区二区精华液| 一级特黄大欧美久久久| 日韩av中文字幕一区二区三区| 久久精品国产99国产| 国产不卡一区视频| 欧美性猛交xxxx乱大交退制版 | 国产精品亲子乱子伦xxxx裸| 亚洲精品久久嫩草网站秘色| 午夜欧美在线一二页| 韩国女主播成人在线| 91网站黄www| 日韩欧美一二三| 中文字幕中文字幕在线一区 | 国产91精品一区二区麻豆网站 | 午夜精品福利一区二区蜜股av| 美国十次综合导航| aaa欧美大片| 日韩欧美一二三区| 一区二区在线观看不卡| 激情小说欧美图片| 欧美日韩不卡在线| 亚洲欧美国产高清| 国产精品一区二区三区网站| 欧美日韩日日摸|