Overview
Comment:Various changes to support PPP
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 78e107c25bbcc17f62ab9ffaf2586347b085509fb95625b1220713ec9cccb0b2
User & Date: gawthrop@users.sourceforge.net on 2001-06-04 08:13:38
Other Links: branch diff | manifest | tags
Context
2001-06-04
08:18:52
Putting documentation under CVS check-in: 6d5e3f99ef user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:13:38
Various changes to support PPP check-in: 78e107c25b user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2001-05-30
19:57:08
Fixes to sensitivity components for non-linear PPP check-in: ad7c2478fe user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/abg2lbl_fig2txt from [5718595199] to [5d3130fe45].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25







+
+
+







# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.11  2000/09/19 11:14:30  peterg
## Now writes the first component type header correctely
##
## Revision 1.10  2000/01/26 10:11:10  peterg
## Added I component
##
## Revision 1.9  1999/11/10 00:47:08  peterg
119
120
121
122
123
124
125

126




127
128
129
130
131
132
133
134
135
136
137
138
139
140



141
142
143



144
145
146
147
148
149
150
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145



146
147
148
149


150
151
152
153
154
155
156
157
158
159







+

+
+
+
+











-
-
-
+
+
+

-
-
+
+
+







  else {
    alias[++i] = $2;
    if (length(sensitivity)>0) {
      s_arg = sprintf("%ss",$2);
      alias[++i] = s_arg;
      s_arg = sprintf(";%s",s_arg);
      Component = substr(Component,2);
      lin = "slin"
    }
   else {
      lin = "lin"
    }
  
 }

    ## Table of components
    cr["SS"] = "SS";  arg["SS"] = "external,external";

    cr["Se"] = "SS";  arg["Se"] = sprintf("external%s", s_arg);
    cr["Sf"] = "SS";  arg["Sf"] = sprintf("external%s", s_arg);

    cr["De"] = "SS";  arg["De"] = "external";
    cr["Df"] = "SS";  arg["Df"] = "external";

    cr["R"] = "lin";  arg["R"]  = sprintf("flow,%s%s", $2, s_arg);
    cr["C"] = "lin";  arg["C"]  = sprintf("effort,%s%s", $2, s_arg);
    cr["I"] = "lin";  arg["I"]  = sprintf("flow,%s%s", $2, s_arg);
    cr["R"] = lin;  arg["R"]  = sprintf("flow,%s%s", $2, s_arg);
    cr["C"] = lin;  arg["C"]  = sprintf("effort,%s%s", $2, s_arg);
    cr["I"] = lin;  arg["I"]  = sprintf("flow,%s%s", $2, s_arg);

    cr["CS"] = "lin";  arg["CS"]  = sprintf("effort,%s;x_0%s", $2, s_arg);
    cr["IS"] = "lin";  arg["IS"]  = sprintf("flow,%s;x_0%s", $2, s_arg);
    cr["CS"] = "lin";  arg["CS"]  = sprintf("effort,%s;%s_x0%s", $2, $2, s_arg);
    cr["IS"] = "lin";  arg["IS"]  = sprintf("flow,%s;%s_x0%s", $2, $2, s_arg);
    cr["INTFS"] = "lin";  arg["INTFS"]  = sprintf("%s_x0%s", $2, s_arg);

    cr["TF"] = "lin";  arg["TF"]  = sprintf("flow,%s%s", $2, s_arg);
    cr["GY"] = "lin";  arg["GY"]  = sprintf("flow,%s%s", $2, s_arg);

    cr["AE"] = "lin";  arg["AE"]  = sprintf("%s%s", $2, s_arg);
    cr["AF"] = "lin";  arg["AF"]  = sprintf("%s%s", $2, s_arg);

Modified mttroot/mtt/lib/control/PPP/ppp_nlin_sim.m from [8be58fd40d] to [26d1c64307].

1

2
3

4
5
6
7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

1
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
-
+

-
+














+















-







function [y,x,u,t,UU,UU_c,UU_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N_ol,extras)
function [y,x,u,t,p,UU,UU_c,UU_l,t_ppp,t_est] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N_ol,extras)

  ## usage:  [y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w)
  ## usage: [y,x,u,t,p,UU,UU_c,UU_l,t_ppp,t_est] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N_ol,extras) 
  ##
  ## 
  
  ## Simulate nonlinear PPP
  ## Copyright (C) 2000 by Peter J. Gawthrop

  ## Defaults
  if nargin<7
    extras.U_initial = "zero";
    extras.U_next = "continuation";
    extras.criterion = 1e-5;
    extras.max_iterations = 10;
    extras.v = 0.1;
    extras.verbose = 0;
    extras.estimate = 1;
  endif
  
  

  ## 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));
  [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));
  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;
  Tau = [0:n_Tau-1]'*dtau;
97
98
99
100
101
102
103



104
105
106
107
108



109
110
111
112
113
114
115
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121







+
+
+





+
+
+







  [k_x,k_w,K_x,K_w] = ppp_lin(A,B,C,D,A_u,0,tau');

  ## Main simulation loop
  y = [];
  x = [];
  u = [];
  t = [];

  p = [];

  t_last = 0;
  UU = [];
  UU_l =[];
  UU_c =[];
  
  t_ppp = [];
  t_est = [];

  x_0s = zeros(2*n_x,1);

  if  strcmp(extras.U_initial,"linear")
    U = K_w*w - K_x*x_0;
  elseif strcmp(extras.U_initial,"zero")
    U = zeros(n_U,1);
  else
145
146
147
148
149
150
151
152

153
154

155
156
157
158
159

160












161
162
163
164
165
166


167
168
169
170
171
172
173
174
175
176


177
178
179
180
151
152
153
154
155
156
157

158


159
160
161
162
163
164
165

166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198








-
+
-
-
+





+
-
+
+
+
+
+
+
+
+
+
+
+
+




-
-
+
+










+
+



-
    tick = time;
    if extras.max_iterations>0
      [U, U_all, Error, Y] = ppp_nlin(system_name,x_0s,pars,simpars,u_star_tau,w_s,i_ppp,extras);
      pars(i_ppp(:,1)) = U;	# Put final value of U into the parameter vector
    else
      Error = [];
    endif
    opt_time = time-tick;  
    ppp_time = time-tick;  
    printf("Optimisation %i took %i iterations and %2.2f sec\n", i, \
	   length(Error), opt_time);
    t_ppp = [t_ppp;ppp_time];
    
    ## Generate control
    u_ol = u_star_t*U;		# Not used - just for show

    ## Simulate system over one ol interval
    par(i_ppp(:,3)) = pars(i_ppp(:,1)); # Update the simulation ppp weights
    [y_ol,ys_ol,x_ol] = eval(sprintf("%s_ssim(x_0s, pars, simpar, u_star_t);", s_system_name));
    [y_ol,x_ol] = eval(sprintf("%s_sim(x_0, par, simpar, u_star_t);", system_name));


    ## Tune parameters/states
    if (extras.estimate==1)
      tick = time;
      par_est = pars(i_par(:,1));
      p = [p; par_est'];
      pars = ppp_optimise(s_system_name,x_0s,pars,simpar,u_star_t,y_ol,i_par,extras);
      est_time = time-tick;  
      t_est = [t_est;est_time];
    endif

    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 


    
    
    y = [y; y_ol];
    x = [x; x_ol];
    u = [u; u_ol];

    UU = [UU; U'];
    UU_l = [UU_l; U_l'];
    UU_c = [UU_c; U_c'];

    t = [t; t_ol+t_last*ones(n_t,1) ];
    t_last = t_last + T_ol; 


  endfor

endfunction

Modified mttroot/mtt/lib/rep/nppp_rep.make from [1a8a9b1146] to [d69a3656d1].

1
2
3
4
5

6
7
8
9
10
11
12
1
2
3
4

5
6
7
8
9
10
11
12




-
+







# -*-makefile-*-
# Makefile for representation nppp
# File nppp_rep.make

#Copyright (C) 2000 by Peter J. Gawthrop
#Copyright (C) 2000,2001 by Peter J. Gawthrop

all: $(SYS)_nppp.$(LANG)

$(SYS)_nppp.view: $(SYS)_nppp.ps
	echo Viewing $(SYS)_nppp.ps; ghostview $(SYS)_nppp.ps&

$(SYS)_nppp.ps: $(SYS)_ode2odes.out s$(SYS)_ode2odes.out \


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