ADDED mttroot/mtt/lib/control/PPP/ppp_error.m Index: mttroot/mtt/lib/control/PPP/ppp_error.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/control/PPP/ppp_error.m @@ -0,0 +1,18 @@ +function err = ppp_error(par) + + ## usage: err = error (par) + ## + ## + + global ppp_y_0 ppp_sim_command ppp_par ppp_i_par ppp_x0 ppp_sim ppp_u + + pars = ppp_par; + pars(ppp_i_par) = par; + + y = sidSimpleExtruder_ssim(ppp_x0,pars,ppp_sim,ppp_u); + + [N,n_y] = size(y); + + Err = y - ppp_y_0; + err = sum(diag(Err'*Err))/N +endfunction Index: mttroot/mtt/lib/control/PPP/ppp_identify.m ================================================================== --- mttroot/mtt/lib/control/PPP/ppp_identify.m +++ mttroot/mtt/lib/control/PPP/ppp_identify.m @@ -26,31 +26,32 @@ ## Set up parameters sim = eval([s_system_name, "_simpar;"]); # Simulation parameter sym = eval([s_system_name, "_sympar;"]); # Parameter names x0 = eval([s_system_name, "_state(par_0);"]); # Initial state - ## Set up the free parameter list - free = []; - [n,m] = size(par_names); - for i = 1:n - p_name = deblank(par_names(i,:)); - s_name = sprintf("%ss", p_name); - if struct_contains(sym, p_name) - i_p = eval(sprintf("sym.%s;", p_name)); - if struct_contains(sym, s_name) - i_s = eval(sprintf("sym.%s;", s_name)); - free_i = eval(sprintf("[%i,%i];", i_p, i_s)); - free = [free; free_i]; - else - printf("Sensitivity parameter %s does not exist: ignoring \ - parameter %s\n", s_name, p_name); - endif - else - printf("Parameter %s does not exist: ignoring\n", p_name) - endif - endfor - +# ## Set up the free parameter list +# free = []; +# [n,m] = size(par_names); +# for i = 1:n +# p_name = deblank(par_names(i,:)); +# s_name = sprintf("%ss", p_name); +# if struct_contains(sym, p_name) +# i_p = eval(sprintf("sym.%s;", p_name)); +# if struct_contains(sym, s_name) +# i_s = eval(sprintf("sym.%s;", s_name)); +# free_i = eval(sprintf("[%i,%i];", i_p, i_s)); +# free = [free; free_i]; +# else +# printf("Sensitivity parameter %s does not exist: ignoring \ +# parameter %s\n", s_name, p_name); +# endif +# else +# printf("Parameter %s does not exist: ignoring\n", p_name) +# endif +# endfor +# free + free = ppp_indices(par_names,sym); [par,Par,Error,Y] = ppp_optimise(s_system_name,x0,par_0,sim,u,y_0,free,extras); endfunction ADDED mttroot/mtt/lib/control/PPP/ppp_indices.m Index: mttroot/mtt/lib/control/PPP/ppp_indices.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/control/PPP/ppp_indices.m @@ -0,0 +1,31 @@ +function indices = ppp_indices (names,sympar) + + ## usage: indices = ppp_indices (names,sympar) + ## + ## names: column vector of component names + ## sympar: mtt-generated data structure od symbolic parameters + + + ## Set up the + indices = []; + [n,m] = size(names); + for i = 1:n + p_name = deblank(names(i,:)); + s_name = sprintf("%ss", p_name); + if struct_contains(sympar, p_name) + i_p = eval(sprintf("sympar.%s;", p_name)); + if struct_contains(sympar, s_name) + i_s = eval(sprintf("sympar.%s;", s_name)); + indices_i = eval(sprintf("[%i,%i];", i_p, i_s)); + indices = [indices; indices_i]; + else + printf("Sensitivity parameter %s does not exist: ignoring \ + parameter %s\n", s_name, p_name); + endif + else + printf("Parameter %s does not exist: ignoring\n", p_name) + endif + endfor + + +endfunction Index: mttroot/mtt/lib/control/PPP/ppp_optimise.m ================================================================== --- mttroot/mtt/lib/control/PPP/ppp_optimise.m +++ mttroot/mtt/lib/control/PPP/ppp_optimise.m @@ -26,10 +26,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ + ## Revision 1.6 2001/07/03 22:59:10 gawthrop + ## Fixed problems with argument passing for CRs + ## ## Revision 1.5 2001/06/06 07:54:38 gawthrop ## Further fixes to make nonlinear PPP work ... ## ## Revision 1.4 2001/05/26 15:46:38 gawthrop ## Updated to account for new nonlinear ppp @@ -114,12 +117,12 @@ ## Use the last part of the simulation to compare with data y = y(1+N_data-n_data:N_data,:); y_par = y_par(1+N_data-n_data:N_data,:); if extras.verbose # Diagnostics - printf("y and y_0\n"); - [y,y_0] +## printf("y and y_0\n"); +## [y,y_0] endif ##Evaluate error, cost derivative J and cost second derivative JJ error = 0; J = zeros(n_th,1);