% TITLE: INIT_Z.M
% DATE: JANUARY 1995
% DONE BY : RENO CIPOLLA
% VERSION: 2.0
% COPYRIGHT: 1995
%This program initializes variables for MACTUNE.
% ****************************************************

% set the size of some variables 

Kp = zeros(1,3); Kpp=Kp; tau1=Kp; tau2=tau1; tau3=tau2; theta=tau3; thetad=theta;
     taud1=tau1; taud2=tau2; taud3=tau3; taulead=taud3; tauleadd=taulead;

%Process and Disturbance variables.
Kp(1)= 1; Kpd=1;tau1(1)=8;taulead(1)=0;xi=0;xid=xi;theta(1)=2; 

thetad(1)=theta(1); tauleadd(1)=taulead(1);tau2(1)=0; 
taud1(1)=tau1(1); taud2(1)=tau2(1);tau3(1)=0; taud3(1)=tau3(1); 

% PID Controller Tuning Constants.
kc=1; ti=4; td=0; al_pha=0;       

% Miscellaneous variables - noise, dummy and flag variables.
mvtest=1; tdist=6; tset=6; betaa=20;
usegrh=2; cn_t = 1; scn_t = 1; Kn = 0.57; A=0; Dyn='y'; pp=0;
junk2=2; junk22=junk2; obj=1; Y0i= [kc ti]; op_ts=0; 
chg = 'd'; c_t=0; o_func=0; numlev=5; le_vel=zeros(1,numlev);
le_vel=[1 1.05 1.1 1.2 1.3]; save_graph=0; ct_count=0; 

%  Response Surface Variables
c_i=.1*kc; c_1=kc - 0.2*kc; c_2=kc + 0.2*kc; int_kc= round ((c_2-c_1)/c_i);  
b_i=.1*ti; b_1=ti - 0.2*ti; b_2=ti + 0.2*ti; int_ti= round ((b_2-b_1)/b_i);

% MV Bound Variables.
maxdev = 2.7;        % Initial Variation 
mindev = 2.5;       % Final MV variability
rise = 1.5;          % MV time constant

% Default variables.
time=120; deltat=1; maxit=round(time/deltat);
D=10;SP=10;        % Disturbance & Set Point Magnitudes.
rho = 0;           % Penalty Magnitude for MV Violations.
rho1 = 0;          % Penalty for Controlled Variable overshoot.
epsl = 25;         % Model Error. 
toll = 1E-02;      % Tolerance on Tuning Constants. 
toll2 = 1E-02;     % Tolerance on Objective function.
% Both Tolerances are defined as the difference between the lowest and highest   
% values in a (1,3) to (1,4) matrix of values. These Matrices are displayed 
% during optimization.
% Optimization terminates when both tolerances are satisfied.

%  set maximum array sizes based on the version of MATLAB 
%  being used (see M-file ml_ver.m)

if ver_sion == 0
   lim_it = 3000;
else
   lim_it = 10000;
end
