Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -14,10 +14,14 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.310 2001/05/08 08:30:12 gawthrop +## Added line to reverse the x^y --> pow(x,y) in default _simp file to +## prettyfy LaTeX +## ## Revision 1.309 2001/04/28 03:15:03 geraint ## Fixed comment (interfered with "mtt help representations"). ## ## Revision 1.308 2001/04/25 22:17:45 geraint ## Fixed icd.txt2 dependency. @@ -2622,25 +2626,29 @@ endif $1_ode2odes.c: $1_ode2odes.p mtt_p2c $info_switch $1 ode2odes -#SUMMARY sim Octave simulation function (m) - -ifeq ($computation,octave) -$1_sim.m: $1_def.r $1_sympar.txt $1_cse.m $1_cseo.m $1_smxa.m $1_smxax.m $1_numpar.m $1_state.m - mtt_make_sim $1 $integration_method $computation -endif - -ifeq ($computation,c) -$1_sim.m: $1_def.r $1_sympar.txt $1_ode2odes.out $1_numpar.m $1_state.m - mtt_make_sim $1 $integration_method $computation -endif +##SUMMARY sim Octave simulation function (m) + +#ifeq ($computation,octave) +#$1_sim.m: $1_def.r $1_sympar.txt $1_cse.m $1_cseo.m $1_smxa.m $1_smxax.m $1_numpar.m $1_state.m + mtt_make_sim $1 $integration_method $computation +#endif + +#ifeq ($computation,c) +#$1_sim.m: $1_def.r $1_sympar.txt $1_ode2odes.out $1_numpar.m $1_state.m +# mtt_make_sim $1 $integration_method $computation +#endif #SUMMARY ssim Octave sensitivity simulation function (m) $1_ssim.m: $1_def.r make_ssim $1 m + +#SUMMARY sim Octave simulation function (m) +$1_sim.m: $1_def.r + make_sim $1 m #SUMMARY obs observer equations for CGPC (r) #SUMMARY obs* observer equations for CGPC (m) #SUMMARY obs observer equations for CGPC (tex) #SUMMARY obs* observer equations for CGPC (view) Index: mttroot/mtt/bin/trans/mtt_header ================================================================== --- mttroot/mtt/bin/trans/mtt_header +++ mttroot/mtt/bin/trans/mtt_header @@ -10,10 +10,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.33 2001/05/26 15:46:38 gawthrop +## Updated to account for new nonlinear ppp +## ## Revision 1.32 2001/05/24 07:42:12 gawthrop ## Included and updated the missing tf_r2m ## ## Revision 1.31 2001/04/03 14:49:42 gawthrop ## Revised to incorporate new ssim (sensitivity simulation) @@ -285,10 +288,17 @@ parameters=yes; output=mttx args=mttpar declarestates=yes ;; + sim) + states=no; + inputs=no; + parameters=no; + output='y,x' + args='x0,par,simpar,u' + ;; ssim) states=no; inputs=no; parameters=no; output='y,y_par,x' Index: mttroot/mtt/lib/control/PPP/ppp_nlin_sim.m ================================================================== --- mttroot/mtt/lib/control/PPP/ppp_nlin_sim.m +++ mttroot/mtt/lib/control/PPP/ppp_nlin_sim.m @@ -22,38 +22,34 @@ ## Names s_system_name = sprintf("s%s", system_name); ## System details -- defines simulation within ol interval par = eval(sprintf("%s_numpar;", system_name)); - simpar = eval(sprintf("%s_simpar;", system_name)) - x_0 = eval(sprintf("%s_state(par);", system_name)) + simpar = eval(sprintf("%s_simpar;", system_name)); + x_0 = eval(sprintf("%s_state(par);", system_name)); [n_x,n_y,n_u] = eval(sprintf("%s_def;", system_name)); ## Sensitivity system details -- defines moving horizon simulation - simpars = eval(sprintf("%s_simpar;", s_system_name)) + simpars = eval(sprintf("%s_simpar;", s_system_name)); sympars = eval(sprintf("%s_sympar;", s_system_name)); pars = eval(sprintf("%s_numpar;", s_system_name)); ## Times ## -- within opt horizon - n_Tau = round(simpars.last/simpars.dt) - dtau = simpars.dt + n_Tau = round(simpars.last/simpars.dt); + dtau = simpars.dt; Tau = [0:n_Tau-1]'*dtau; [n_tau,n_w] = size(w_s); tau = Tau(n_Tau-n_tau+1:n_Tau); w = w_s(length(w_s)); # Final value of setpoint ## -- within ol interval - n_t = round(simpar.last/simpar.dt) + n_t = round(simpar.last/simpar.dt); dt = simpar.dt; t_ol = [0:n_t-1]'*dt; T_ol = n_t*dt; - ## Weight and moving-horizon setpoint -# weight = [zeros(n_y,n_Tau-n_tau), ones(n_y,n_tau)]; -# w_s = w*ones(n_tau,1); - ## Create input basis functions [n_U,junk] = size(A_u); ## For moving horizon eA = expm(A_u*dtau); @@ -154,22 +150,17 @@ Error = []; endif opt_time = time-tick; printf("Optimisation %i took %i iterations and %2.2f sec\n", i, \ length(Error), opt_time); - ##title(sprintf("Moving horizon trajectories: Interval %i",i)); - ##grid; - ##plot(tau,Y) ## Generate control u_ol = u_star_t*U; # Not used - just for show ## Simulate system over one ol interval - ## (Assumes that first gain parameter is one) - ##U = [u_ol zeros(n_t,n_u-1)]; # Generate the vector input - [y_ol,y_s,x_ol] = eval(sprintf("%s_ssim(x_0s, pars, simpar, u_star_t);", s_system_name)); - + [y_ol,ys_ol,x_ol] = eval(sprintf("%s_ssim(x_0s, pars, simpar, u_star_t);", s_system_name)); + x_0 = x_ol(n_t+1,:)'; # Extract state for next time y_ol = y_ol(1:n_t,:); # Avoid extra points due to rounding error x_ol = x_ol(1:n_t,:); # Avoid extra points due to rounding error Index: mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Figures.m ================================================================== --- mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Figures.m +++ mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Figures.m @@ -1,8 +1,11 @@ ## Figures.m ## Makes figures for the rc_PPP exasmple. ## $Log$ +## Revision 1.2 2000/05/17 17:02:58 peterg +## Fixed documentation +## ## Revision 1.1 2000/05/17 09:14:37 peterg ## Initial revision ## system_name = "rcPPP"; @@ -10,117 +13,132 @@ ## (Or do ./Make rcPPP in this directory) ## MTT stuff for the system simulation ##system("Make rcPPP"); - - -t_s=[0:0.1:10]; -u = [ones(1,length(t_s));ones(1,length(t_s))]; -x_0 = rcPPP_state; +# ## System info par = rcPPP_numpar; - -## Simulate the system -tick=time; -[y,x] = rcPPP_sim(x_0,u,t_s,par); -Elapsed = time-tick -plot(t_s,y,t_s,x); - -## Simulate the system to give just the final few point -t_s1 = [9:0.1:10]; -tick=time; -[y,x] = rcPPP_sim(x_0,u,t_s1,par); -Elapsed = time-tick -plot(t_s1,y,t_s1,x); +simpar = rcPPP_simpar; +x_0 = rcPPP_state(par); + +# ## Set up the input +# t = [0:simpar.dt:simpar.last]; +# A_w = 0; +# A_u = ppp_aug(A_w,laguerre_matrix(1,2.0)) # Specify basis functions: constant & exp(-t/T) +# u = ppp_ustar(A_u,1,t,0,0); + +# ## Simulate the system +# tick=time; +# [y,x] = rcPPP_sim(x_0,par,simpar,u); +# Elapsed = time-tick +# plot(t,y) ## Sensitivity system simulation parameters -x_0s = srcPPP_state; +simpars = srcPPP_simpar; +sympars = srcPPP_sympar; pars = srcPPP_numpar; -sympars = srcPPP_sympar; +x_0s = srcPPP_state(pars); + +t = [0:simpars.dt:simpars.last]; +A_w = 0; +A_u = ppp_aug(A_w,laguerre_matrix(1,2.0)) # Specify basis functions: constant & exp(-t/T) +u = ppp_ustar(A_u,1,t,0,0); + + +## Setup the indices of the adjustable stuff +i_ppp = [sympars.ppp_1, sympars.ppp_1s + sympars.ppp_2, sympars.ppp_2s]; # PPP params +i_par = [sympars.x_0, sympars.x_0s + sympars.r, sympars.rs]; # State and r component ## Simulate the sensitivity system -sensitivities = [sympars.ppp_1s,sympars.ppp_2s,sympars.rs] +sensitivities = [i_ppp(:,2); i_par(:,2)] +u = ppp_ustar(A_u,1,t,0,0); tick=time; -[y,ys] = srcPPP_sim(x_0s,u,t_s,[sympars.r,2.0],sensitivities); +[y,ys,x] = srcPPP_ssim(x_0s,pars,simpars,u,sensitivities); Elapsed = time-tick -plot(t_s,y,t_s,ys); +plot(t,y,t,ys); ### PPP parameters -A_w = 0; -A_u = ppp_aug(A_w,laguerre_matrix(1,10)); # Specify basis functions: constant & exp(-5t) tau = [0.9:0.01:1]; # Optimisation interval t_ol = [0:0.01:0.2]; # Open-loop interval -N = 5; # Number of open-loop intervals in simulation +N = 10; # Number of open-loop intervals in simulation w = 1; # Setpoint +w_s = w*ones(10,1); # The setpoint witnin the horizon ## Linear system -[A,B,C,D] = rcPPP_sm; +n_Tau = round(simpars.last/simpars.dt); +dtau = simpars.dt; +Tau = [0:n_Tau-1]'*dtau; +[n_tau,n_w] = size(w_s); +tau = Tau(n_Tau-n_tau+1:n_Tau) +[A,B,C,D] = rcPPP_sm(par); Q = 1; w = 1; -ppp_lin_plot (A,B(:,1),C(1,:),D(1,1),A_u,A_w,tau,Q,w,x_0); +ppp_lin_plot (A,B(:,1),C(1,:),D(1,1),A_u,A_w,tau',Q,w); psfig("rcPPP_lin"); ## Simulate non-linear PPP (on this linear system) extras.U_initial = "zero"; extras.U_next = "continuation"; extras.criterion = 1e-5; extras.max_iterations = 10; extras.alpha = 0.1; extras.verbose = 0; +extras.v = 1e-5; ## -- with no optimisation using linear PPP with continuation extras.U_initial = "linear"; extras.U_next = "continuation"; extras.criterion = 1e-5; extras.max_iterations = 0; -[y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras); +[y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras); ## -- with no optimisation using linear PPP at each step extras.U_initial = "linear"; extras.U_next = "linear"; extras.criterion = 1e-5; extras.max_iterations = 0; -[y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras); +[y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras); -## -- with no optimisation using nonlinear PPP with continuation +## -- with optimisation using nonlinear PPP with continuation extras.U_initial = "zero"; extras.U_next = "continuation"; extras.criterion = 1e-5; extras.max_iterations = 100; -[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras); +[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras); ## Plots title(""); ## U, U_c and U_l -I = 1:N; -IU1 = [I' U(1,:)']; -IU1_c = [I' U_c(1,:)']; -IU1_l = [I' U_l(1,:)']; +I = [1:N]'; +IU1 = [I U(:,1)]; +IU1_c = [I U_c(:,1)]; +IU1_l = [I U_l(:,1)]; gset grid; xlabel "Interval" gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1" psfig("rcPPP_U1"); -IU2 = [I' U(2,:)']; -IU2_c = [I' U_c(2,:)']; -IU2_l = [I' U_l(2,:)']; +IU2 = [I U(:,2)]; +IU2_c = [I U_c(:,2)]; +IU2_l = [I U_l(:,2)]; gset grid; xlabel "Interval " gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2" psfig("rcPPP_U2"); ## y & u gset grid; xlabel "Time (sec)" -ty = [t' y'] ; tu = [t' u']; +ty = [t y] ; tu = [t u]; gplot ty title "Output", tu title "Input" psfig("rcPPP_yu"); -title(""); gset grid; xlabel "Time (sec)" -ty_c = [t' y_c'] ; -ty_l = [t' y_l'] ; -ty = [t' y'] ; -tu = [t' u']; +ty_c = [t y_c] ; +ty_l = [t y_l] ; +ty = [t y] ; +tu = [t u]; gplot ty_c title "Continuation", ty_l title "Linear", ty title "Optimisation" psfig("rcPPP_ylco"); Index: mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Make ================================================================== --- mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Make +++ mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Make @@ -1,30 +1,46 @@ #!/bin/sh ## Makes the files needed for Figures.m ## Copyright (C) 2000 by Peter J. Gawthrop + +sys=$1 + +if [ -z "$2" ]; then + code=oct +else + code=$2 +fi if [ -z "$1" ]; then - echo Usage ./Make system_name + echo 'Usage ./Make system_name [m|oct]' exit else - echo "Making simulation for system $1 (for use in Figures.m)" + echo "Making sensitivity simulation for system ${sys} (code ${code})" +fi + +if [ "${code}" == "oct" ]; then + oct='-oct' fi +echo Switches ${oct} + ## System -mtt -q -c -stdin $1 ode2odes out -mtt -q -c -stdin $1 sim m -mtt -q $1 state m -mtt -q $1 sympar m -mtt -q $1 numpar m +mtt -q ${sys} sympar m +mtt -q ${sys} simpar m +mtt -q ${sys} numpar m +mtt -q ${sys} state m + ## Sensitivity system -mtt -q -c -stdin -s s$1 ode2odes out -mtt -q -c -stdin -s s$1 sim m -mtt -q -s s$1 state m -mtt -q -s s$1 sympar m -mtt -q -s s$1 numpar m +mtt -q -stdin -s s${sys} ssim m +mtt -q -stdin -s s${sys} sympar m +mtt -q -stdin -s s${sys} simpar m +mtt -q -stdin ${oct} -s s${sys} input ${code} +mtt -q -stdin ${oct} -s s${sys} ode2odes ${code} +mtt -q -stdin ${oct} -s s${sys} state ${code} +mtt -q -stdin ${oct} -s s${sys} numpar ${code} ## Additional system reps for PPP -mtt -q $1 sm m -mtt -q $1 def m -mtt -q -s s$1 def m +mtt -q -stdin ${sys} sm m +mtt -q -stdin ${sys} def m +mtt -q -stdin -s s${sys} def m Index: mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_numpar.txt ================================================================== --- mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_numpar.txt +++ mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_numpar.txt @@ -5,21 +5,23 @@ # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # %% Version control history # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # %% $Id$ # %% $Log$ +# %% Revision 1.1 2000/12/28 17:31:27 peterg +# %% To RCS +# %% # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Parameters c = 1.0; # CS,rcPPP -e_0 = 1.0; # CS -e_s = 1.0; # Se +## Removed by MTT on Sat May 26 07:46:29 BST 2001: e_0 = 1.0; # CS +## Removed by MTT on Sat May 26 07:46:29 BST 2001: e_s = 1.0; # Se + ppp_1 = 1.0; # rcPPP ppp_2 = 0.0; # rcPPP -q_0 = 1.0; # rcPPP -r = 1.0; # rcPPP ## Physical parameters c = 1.0; q_0 = 0.0; r = 1.0; Index: mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_lbl.txt ================================================================== --- mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_lbl.txt +++ mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_lbl.txt @@ -5,10 +5,13 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.1 2000/12/28 17:31:27 peterg +% %% To RCS +% %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Port aliases @@ -32,22 +35,23 @@ % a comment (ie starting with %) % component-name cr_name arg1,arg2,..argn % blank % ---- Component labels ---- - ppp_1 lin ppp_1;ppp_1s - ppp_2 lin ppp_2;ppp_2s +% Component type Ae + ppp_1 slin ppp_1;ppp_1s + ppp_2 slin ppp_2;ppp_2s % Component type CS - c lin effort,c;x_0;cs;x_0s + c slin effort,c;x_0;cs;x_0s % Component type De y SS external % Component type R - r lin flow,r;rs + r slin flow,r;rs % Component type Se u1 SS external;0 u2 SS external;0 Index: mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_numpar.txt ================================================================== --- mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_numpar.txt +++ mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_numpar.txt @@ -1,45 +1,25 @@ -# -*-octave-*- Put Emacs into octave-mode -# Numerical parameter file (srcPPP_numpar.txt) -# Generated by MTT at Tue Apr 18 09:13:31 BST 2000 - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -# %% Version control history -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -# %% $Id$ -# %% $Log$ -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -## Dummies -c = 0.0; -c_s = 0.0; -cs = 0.0; -e_0 = 0.0; -e_0s = 0.0; -e_s = 0.0; -g = 0.0; -k = 0.0; -k_s = 0.0; -ppp_1 = 0.0; -ppp_1s = 0.0; -ppp_2 = 0.0; -ppp_2s = 0.0; -r = 0.0; -rs = 0.0; -x_0 = 0.0; -x_0s = 0.0; - -# Parameters -c = 1.0; # CS,rcPPP -e_0 = 1.0; # CS -e_s = 1.0; # Se -ppp_1 = 1.0; # rcPPP -ppp_2 = 0.0; # rcPPP -#q_0 = 1.0; -r = 1.0; # rcPPP - -## Physical parameters -c = 1.0; -q_0 = 0.0; -r = 1.0; - +## -*-octave-*- Put Emacs into octave-mode ## + +## +## System srcPPP, representation numpar, language txt; +## File srcPPP_numpar.txt; +## Generated by MTT on Sat May 26 08:47:19 BST 2001; + + +## Parameters +c = 1.0; +r = 1.0; + +## PPP coefficients +ppp_1 = 0.0; # Default +ppp_2 = 1.0; # Default + +## State +x_0 = 0.0; # Default + +## Sensitivities +cs = 0.0; # Default +ppp_1s = 0.0; # Default +ppp_2s = 0.0; # Default +rs = 0.0; # Default +x_0s = 0.0; # Default Index: mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_simpar.txt ================================================================== --- mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_simpar.txt +++ mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_simpar.txt @@ -4,15 +4,19 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.1 2000/12/28 17:31:27 peterg +## To RCS +## ############################################################### -LAST = 10.0; # Last time in simulation -DT = 0.1; # Print interval +FIRST = 0.0; # Last time in simulation +LAST = 2.0; # Last time in simulation +DT = 0.01; # Print interval STEPFACTOR = 1; # Integration steps per print interval WMIN = -1; # Minimum frequency = 10^WMIN WMAX = 2; # Maximum frequency = 10^WMAX WSTEPS = 100; # Number of frequency steps INPUT = 1; # Index of the input