% TITLE : OPTIMAL.M
% DATE : JAN/94
% DONE BY : RENO CIPOLLA
% VERSION 2.0
% COPYRIGHT 1994-5 by T. Marlin and R. Cipolla
% This file displays the results of the optimization to the user
% and runs the optimal case for use in plots and initializing the
% runs at the optimum for response surface displays
% ************************************************************************

clc
disp('')
disp('')
disp('')
disp('')
disp('')
disp('')
disp('                    Optimization  Complete                         ')
disp('*******************************************************************')
disp('')
disp('                The Optimal Tuning Parameters are:                 ')
disp('')
if junk2 == 2
fprintf('                  Kc =  %4.2f\n',x_(1))                           
fprintf('                  Ti =  %4.2f\n',x_(2))          
kc=x_(1); ti=x_(2); Y0i=[kc ti]; junk2=2;

elseif junk2 == 1
fprintf('                  Kc =  %4.2f\n',x_(1))                           
fprintf('                  Ti =  %4.2f\n',x_(2))          
fprintf('                  Td =  %4.2f\n',x_(3))          
kc=x_(1); ti=x_(2); td=x_(3); Y0i=[kc ti td]; junk2=1;

elseif junk2 == 3 
fprintf('                  Kc =  %4.2f\n',x_(1))                           
fprintf('                  Td =  %4.2f\n',x_(2))          
kc = x_(1); td=x_(2); Y0i=[kc td]; junk2=3;
end
disp('') 
disp('********************************************************************')

mvtest = 2; cn_t=1; scn_t=1; usegrh=0; pp=0; p=1; Y0=Y0i;
op_ts=1;

fprintf('            Objective Function =  %4.2f\n',ob_j )        
disp('')
disp('')
disp(' Simulating Optimal Case...... Please wait a moment.') 
disp('')
disp('')
mvbound1
integ4a(Y0);     % Run the Simulation with the Optimal Tuning.
disp('')
disp('')
disp('       Press any key to continue ......... ')
pause
