Differences From Artifact [a7eaf434e3]:

To Artifact [37eb564d85]:


1

2
3
4
5
6
7
8

1
2
3
4
5
6
7
8
-
+







function [y,u,t,p,UU,t_open,t_ppp,t_est,its_ppp,its_est] = ppp_nlin_run (system_name,i_ppp,i_par,A_u,w_s,N_ol,extras)
function [y,u,t,p,UU,t_open,t_ppp,t_est,its_ppp,its_est] = ppp_nlin_run(system_name,i_ppp,i_par,A_u,w_s,N_ol,Q,extras)


  ## usage: [y,u,t,p,U,t_open,t_ppp,t_est,its_ppp,its_est] =
  ## ppp_nlin_run (system_name,i_ppp,i_par,A_u,w_s,N_ol[,extras])
  ##
  ##  y,u,t   System output, input and corresponding time p
  ##  Estimated parameters U       PPP weight vector t_open  The
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41







-
+







  ## Real-time implementatipn of  nonlinear PPP Copyright (C) 2001,2002
  ## by Peter J. Gawthrop

  ## Globals to pass details to simulation
  global system_name_sim i_ppp_sim x_0_sim y_sim u_sim A_u_sim simpar_sim

  ## Defaults
  if nargin<7
  if nargin<8
    extras.alpha = 0.1;
    extras.criterion = 1e-5;
    extras.emulate_timing = 0;
    extras.max_iterations = 10;
    extras.simulate = 1;
    extras.v = 1e-5;
    extras.verbose = 0;
57
58
59
60
61
62
63




64
65
66
67
68
69
70
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74







+
+
+
+







  simpar_pred = simpar;		# Initial prediction simulation params
  T_ol_0 = simpar.last;		# The initial specified interval
  n_t = round(simpar.last/simpar.dt); # Corresponding length
  x_0 = eval(sprintf("%s_state(par);", system_name));
  x_0_model = x_0;
  [n_x,n_y,n_u] = eval(sprintf("%s_def;", system_name));

  if nargin<8
    Q = ones(n_y,1);
  endif
 
  ## Sensitivity system details -- defines moving horizon simulation
  simpars = eval(sprintf("%s_simpar;", s_system_name));
  pars = eval(sprintf("%s_numpar;", s_system_name));
  x_0s = eval(sprintf("%s_state(pars);", s_system_name));
  x_0_models = x_0s;

  ## Times
161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
165
166
167
168
169
170
171

172
173
174
175
176
177
178
179







-
+







	
	## Optimise
	tick = time;
	[pars,Par,Error,Y,its] = \
	    ppp_optimise(s_system_name,x_0_models,pars,simpar_est,u_star_t,y_est,i_par,extras);
	
	if extras.visual
	  figure(2);
	  figure(11);
	  title("Parameter optimisation"); 
	  II = [1:length(y_est)]; plot(II,y_est,"*", II,Y);
	endif
	
	est_time = time-tick;  
	t_est = [t_est;est_time];
	its_est = [its_est; its-1];
201
202
203
204
205
206
207
208

209
210

211
212
213
214
215
216
217
205
206
207
208
209
210
211

212
213

214
215
216
217
218
219
220
221







-
+

-
+







      x_next = x_next(n_t+1,:)'; # Initial state for next time
      x_nexts(1:2:(2*n_x)-1) = x_next; # And for internal sensitivity model
      
      ## Optimize for next interval      
      U_old = U;		# Save previous value
      U = expm(A_u*T_ol)*U;	# Initialise from continuation trajectory
      pars(i_ppp(:,1)) = U;	# Put initial value of U into the parameter vector
      [U, U_all, Error, Y, its] = ppp_nlin(system_name,x_nexts,pars,simpars,u_star_tau,w_s,i_ppp,extras);
      [U, U_all, Error, Y, its] = ppp_nlin(system_name,x_nexts,pars,simpars,u_star_tau,w_s,i_ppp,Q,extras);
      if extras.visual
	figure(3);
	figure(12);
	title("PPP optimisation");
	II = [1:length(w_s)]; plot(II,w_s,"*", II,Y);
	figure(1);
	endif

      ppp_time = time-tick;  
      t_ppp = [t_ppp;ppp_time];

MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]