Overview
Comment:Implicit rules
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 9bdd1aa5cf665c37f1517cff463a1f3479d1636f32fbae9ab7c70725fb57d953
User & Date: gawthrop@users.sourceforge.net on 2002-05-21 08:47:41
Other Links: branch diff | manifest | tags
Context
2002-05-21
11:46:31
MTT input block "sys_sfun_input.mexglx" created to provide inputs from MTT input file to plant model within Simulink.
The command "mtt sys sfun zip" now also creates a simple sys.mdl file which connects the input block to the plant block correctly.
check-in: f281078eb6 user: geraint@users.sourceforge.net tags: origin/master, trunk
08:47:41
Implicit rules check-in: 9bdd1aa5cf user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:45:36
DIY reps: no longer skips rep if file exists already.
Avoids problems in rep.txt when options change
check-in: 1ca84ea61b user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/lib/rep/nppp_rep.make from [a45ca90fbc] to [93cfab61d5].

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

67
68
69

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106







107
108
109
110
# -*-makefile-*-
# Makefile for representation nppp
# File nppp_rep.make

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


model_reps = ${SYS}_sympar.m ${SYS}_simpar.m ${SYS}_state.m\
             ${SYS}_numpar.m ${SYS}_input.m ${SYS}_ode2odes.m\
             ${SYS}_sim.m ${SYS}_def.m


sensitivity_reps = s${SYS}_sympar.m s${SYS}_simpar.m s${SYS}_state.m\
                   s${SYS}_numpar.m s${SYS}_input.m s${SYS}_ode2odes.m\

                   s${SYS}_ssim.m s${SYS}_def.m







all: ${SYS}_nppp.${LANG}







${SYS}_nppp.view: ${SYS}_nppp.ps
	echo Viewing ${SYS}_nppp.ps; ghostview ${SYS}_nppp.ps&

${SYS}_nppp.ps: ${SYS}_nppp.fig
	nppp_rep.sh ${SYS} ps

${SYS}_nppp.fig: ${SYS}_nppp.gdat
	nppp_rep.sh ${SYS} fig

${SYS}_nppp.gdat: ${SYS}_nppp.dat2
	nppp_rep.sh ${SYS} gdat

${SYS}_nppp.dat2: ${SYS}_nppp.m ${SYS}_nppp_numpar.m \
                  ${model_reps} ${sensitivity_reps} ${SYS}_def.r
	nppp_rep.sh ${SYS} dat2

${SYS}_nppp.m: 
	nppp_rep.sh ${SYS} m

${SYS}_nppp_numpar.m:
	nppp_rep.sh ${SYS} numpar.m

## System model reps
${SYS}_sympar.m:
	mtt ${OPTS} -q -stdin ${SYS} sympar m

${SYS}_simpar.m: ${SYS}_simpar.txt
	mtt ${OPTS} -q -stdin ${SYS} simpar m

${SYS}_state.m: ${SYS}_state.txt
	mtt ${OPTS} -q -stdin ${SYS} state m

${SYS}_state.txt: 
	mtt ${OPTS} -q -stdin ${SYS} state txt

${SYS}_numpar.m: ${SYS}_numpar.txt
	mtt ${OPTS} -q -stdin ${SYS} numpar m

${SYS}_input.m: ${SYS}_input.txt
	mtt ${OPTS} -q -stdin ${SYS} input m

${SYS}_input.txt: 
	mtt ${OPTS} -q -stdin ${SYS} input txt

${SYS}_ode2odes.m: ${SYS}_rdae.r
	mtt ${OPTS} -q -stdin ${SYS} ode2odes m

${SYS}_sim.m: ${SYS}_ode2odes.m
	mtt ${OPTS} -q -stdin ${SYS} sim m


${SYS}_def.m: ${SYS}_def.r
	mtt ${OPTS} -q -stdin ${SYS} def m


${SYS}_def.r: ${SYS}_abg.fig
	mtt ${OPTS} -q -stdin ${SYS} def r

${SYS}_rdae.r: 
	mtt ${OPTS} -q -stdin ${SYS} rdae r

## Sensitivity model reps
s${SYS}_sympar.m:
	mtt -q -stdin ${OPTS} -s s${SYS} sympar m

s${SYS}_simpar.m:
	mtt -q -stdin ${OPTS} -s s${SYS} simpar m

s${SYS}_state.m: s${SYS}_state.txt
	mtt -q -stdin ${OPTS} -s s${SYS} state m

s${SYS}_state.txt: 
	mtt -q -stdin ${OPTS} -s s${SYS} state txt

s${SYS}_numpar.m: s${SYS}_numpar.txt
	mtt -q -stdin ${OPTS} -s s${SYS} numpar m

s${SYS}_input.m: s${SYS}_input.txt
	mtt -q -stdin ${OPTS} -s s${SYS} input m

s${SYS}_input.txt:
	mtt -q -stdin ${OPTS} -s s${SYS} input txt

s${SYS}_ode2odes.m: s${SYS}_rdae.r
	mtt -q -stdin ${OPTS} -s s${SYS} ode2odes m

s${SYS}_ssim.m:
	mtt -q -stdin ${OPTS} -s s${SYS} ssim m

s${SYS}_def.m:
	mtt -q -stdin ${OPTS} -s s${SYS} def m








s${SYS}_rdae.r: 
	mtt ${OPTS} -q -stdin -s s${SYS} rdae r








>
|
|
|

>
|
|
>
|
>
>
>
>
>
>



>
>
>
>
>
>

|










|
<









<
<
|
<
<
<
<
<
<
|
|

<
<
|
<
<
<
<
<
<

|




>
|
|

>







<
<
|
|
<
|
<
<

<
<
|
<
<
<
<
<
<
<
<
<









>
>
>
>
>
>
>




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
41
42
43
44

45
46
47
48
49
50
51
52
53


54






55
56
57


58






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


77
78

79


80


81









82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# -*-makefile-*-
# Makefile for representation nppp
# File nppp_rep.make

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

## Model targets
model_reps =  ${SYS}_sympar.m ${SYS}_simpar.m ${SYS}_state.m 
model_reps += ${SYS}_numpar.m ${SYS}_input.m ${SYS}_ode2odes.m  
model_reps += ${SYS}_def.m

## Prepend s to get the sensitivity targets
sensitivity_reps = ${model_reps:%=s%}

## Simulation targets
sims = ${SYS}_sim.m s${SYS}_ssim.m

## m-files needed for nppp
nppp_m = ${SYS}_nppp.m ${SYS}_nppp_numpar.m 

## Targets for the nppp simulation
nppp_reps = ${nppp_m} ${sims} ${model_reps} ${sensitivity_reps}

all: ${SYS}_nppp.${LANG}

echo:
	echo "sims: ${sims}"
	echo "model_reps: ${model_reps}"
	echo "sensitivity_reps: ${sensitivity_reps}"
	echo "nppp_reps: ${nppp_reps}"

${SYS}_nppp.view: ${SYS}_nppp.ps
	nppp_rep.sh ${SYS} view

${SYS}_nppp.ps: ${SYS}_nppp.fig
	nppp_rep.sh ${SYS} ps

${SYS}_nppp.fig: ${SYS}_nppp.gdat
	nppp_rep.sh ${SYS} fig

${SYS}_nppp.gdat: ${SYS}_nppp.dat2
	nppp_rep.sh ${SYS} gdat

${SYS}_nppp.dat2: ${nppp_reps}

	nppp_rep.sh ${SYS} dat2

${SYS}_nppp.m: 
	nppp_rep.sh ${SYS} m

${SYS}_nppp_numpar.m:
	nppp_rep.sh ${SYS} numpar.m

## System model reps


## Generic txt files 






${SYS}_%.txt:
	mtt ${OPTS} -q -stdin ${SYS} $* txt



## Specific m files






${SYS}_ode2odes.m: ${SYS}_rdae.r
	mtt -q -stdin ${OPTS} ${SYS} ode2odes m

${SYS}_sim.m: ${SYS}_ode2odes.m
	mtt ${OPTS} -q -stdin ${SYS} sim m

## Generic txt to m
${SYS}_%.m: ${SYS}_%.txt
	mtt ${OPTS} -q -stdin ${SYS} $* m

## r files
${SYS}_def.r: ${SYS}_abg.fig
	mtt ${OPTS} -q -stdin ${SYS} def r

${SYS}_rdae.r: 
	mtt ${OPTS} -q -stdin ${SYS} rdae r

## Sensitivity model reps


## Generic txt files 
s${SYS}_%.txt:

	mtt ${OPTS} -q -stdin s${SYS} $* txt





## Specific m files









s${SYS}_ode2odes.m: s${SYS}_rdae.r
	mtt -q -stdin ${OPTS} -s s${SYS} ode2odes m

s${SYS}_ssim.m:
	mtt -q -stdin ${OPTS} -s s${SYS} ssim m

s${SYS}_def.m:
	mtt -q -stdin ${OPTS} -s s${SYS} def m


## Generic txt to m
s${SYS}_%.m: s${SYS}_%.txt
	mtt ${OPTS} -q -stdin s${SYS} $* m


## r files
s${SYS}_rdae.r: 
	mtt ${OPTS} -q -stdin -s s${SYS} rdae r


Modified mttroot/mtt/lib/rep/nppp_rep.sh from [19f90f4533] to [43681cce8e].

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


41
42
43
44
45
46
47
48
49

## Some names
target=${sys}_${rep}.${lang}
def_file=${sys}_def.r
dat2_file=${sys}_nppp.dat2
dat2s_file=${sys}_nppps.dat2
nppp_numpar_file=${sys}_nppp_numpar.m


## Get system information
if [ -f "${def_file}" ]; then
 echo Using ${def_file}
else
  mtt -q ${sys} def r
fi

ny=`mtt_getsize $1 y`
nu=`mtt_getsize $1 u`

## Help documentation
help_short() {
cat<<EOF
Nonlinear predictive pole placement
EOF
}


help_long() {
cat<<EOF
Details go here
EOF


}


## Make the _nppp.m file
make_nppp() {
filename=${sys}_${rep}.m
echo Creating ${filename}

cat > ${filename} <<EOF    







>











|
|
|
|
<
<
|
>
|
<
<
<
>
>

<







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

41
42
43
44
45
46
47

## Some names
target=${sys}_${rep}.${lang}
def_file=${sys}_def.r
dat2_file=${sys}_nppp.dat2
dat2s_file=${sys}_nppps.dat2
nppp_numpar_file=${sys}_nppp_numpar.m
option_file=${sys}_nppp_mtt_options.txt

## Get system information
if [ -f "${def_file}" ]; then
 echo Using ${def_file}
else
  mtt -q ${sys} def r
fi

ny=`mtt_getsize $1 y`
nu=`mtt_getsize $1 u`

check_new_options() {
    if [ -f "${option_file}" ]; then
	old_options=`cat ${option_file}`
        if [ "${mtt_options}" != "${old_options}" ]; then


	   echo ${mtt_options} > ${option_file}
	fi
    else



	echo ${mtt_options} > ${option_file}
    fi
}


## Make the _nppp.m file
make_nppp() {
filename=${sys}_${rep}.m
echo Creating ${filename}

cat > ${filename} <<EOF    
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
    printf("Open-loop interval %3.2f \n", simpar.last);
    printf(" -- using info in ${sys}_simpar.txt\n");
    printf("PPP optimisation from %3.2f to %3.2f\n", simpars.first, simpars.last);
    printf(" -- using info in s${sys}_simpar.txt\n");
  endif
  
  t_horizon = [simpars.first+simpars.dt:simpars.dt:simpars.last]';
  w_s = ones(size(t_horizon))*w';

  ## Setup the indices of the adjustable stuff
  if nargin<2
    i_ppp = []
  else
    i_ppp = ppp_indices (ppp_names,sympar,sympars); # Parameters
  endif







|







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    printf("Open-loop interval %3.2f \n", simpar.last);
    printf(" -- using info in ${sys}_simpar.txt\n");
    printf("PPP optimisation from %3.2f to %3.2f\n", simpars.first, simpars.last);
    printf(" -- using info in s${sys}_simpar.txt\n");
  endif
  
  t_horizon = [simpars.first+simpars.dt:simpars.dt:simpars.last]';
  w_s = ones(length(t_horizon)-1,1)*w';

  ## Setup the indices of the adjustable stuff
  if nargin<2
    i_ppp = []
  else
    i_ppp = ppp_indices (ppp_names,sympar,sympars); # Parameters
  endif
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
  j=[];
  for i = 1:length(T_open)
    j = [j; find(T_open(i)*ones(size(t))==t)];
  endfor
  y_open = y(j,:);
  u_open = u(j,:);

  if extras.visual
    ## Plots
    gset grid; xlabel "Time (sec)"; title "${sys}"
    ty = [t y] ; 
    tu =  [t u]; 
  
    ty_open = [T_open y_open];
    tu_open = [T_open u_open];
  
    gplot  tu \
        title "u", tu_open with impulses title "Sample times"
    figfig("${sys}_u","eps");
  
    gplot  ty \
        title "y", ty_open with impulses title "Sample times"
    figfig("${sys}_y","eps");
  
    system("gv ${sys}_y.eps&");
    system("gv ${sys}_u.eps&");
  endif
endfunction

EOF
}

make_nppp_numpar() {
echo Creating ${nppp_numpar_file}







|


















|







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
  j=[];
  for i = 1:length(T_open)
    j = [j; find(T_open(i)*ones(size(t))==t)];
  endfor
  y_open = y(j,:);
  u_open = u(j,:);

  ##if extras.visual
    ## Plots
    gset grid; xlabel "Time (sec)"; title "${sys}"
    ty = [t y] ; 
    tu =  [t u]; 
  
    ty_open = [T_open y_open];
    tu_open = [T_open u_open];
  
    gplot  tu \
        title "u", tu_open with impulses title "Sample times"
    figfig("${sys}_u","eps");
  
    gplot  ty \
        title "y", ty_open with impulses title "Sample times"
    figfig("${sys}_y","eps");
  
    system("gv ${sys}_y.eps&");
    system("gv ${sys}_u.eps&");
  ##endif
endfunction

EOF
}

make_nppp_numpar() {
echo Creating ${nppp_numpar_file}
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
  extras.verbose = 0;
  extras.visual = 0;

endfunction
EOF
}

make_model() {
    
echo "Making sensitivity simulation for system ${sys} (lang ${lang})"

if [ "${lang}" = "oct" ]; then
    oct='-oct'
fi

## System
mtt -q ${mtt_parameters} -stdin ${sys} sympar m
mtt -q ${mtt_parameters} -stdin ${sys} simpar m
mtt -q ${mtt_parameters} -stdin ${oct} ${sys} state ${lang}
mtt -q ${mtt_parameters} -stdin ${oct} ${sys} numpar ${lang}
mtt -q ${mtt_parameters} -stdin ${oct} ${sys} input ${lang}
mtt -q ${mtt_parameters} -stdin ${oct} ${sys} ode2odes ${lang}
mtt -q ${mtt_parameters} -stdin ${sys} sim m

## Sensitivity system
mtt -q ${mtt_parameters} -stdin -s s${sys} sympar m
mtt -q ${mtt_parameters} -stdin -s s${sys} simpar m
mtt -q ${mtt_parameters} -stdin ${oct} -s s${sys} state ${lang}
mtt -q ${mtt_parameters} -stdin ${oct} -s s${sys} numpar ${lang}
mtt -q ${mtt_parameters} -stdin ${oct} -s s${sys} input ${lang}
mtt -q ${mtt_parameters} -stdin ${oct} -s s${sys} ode2odes ${lang}
mtt -q ${mtt_parameters} -stdin -s s${sys} ssim m

## Additional system reps for PPP
mtt -q ${mtt_parameters} -stdin  ${sys} sm m
mtt -q ${mtt_parameters} -stdin  ${sys} def m
mtt -q ${mtt_parameters} -stdin  -s s${sys} def m

}

make_dat2() {

## Inform user
echo Creating ${dat2_file}

## Use octave to generate the data
octave -q <<EOF
  [last, ppp_names, par_names, A_u, A_w, w, Q, extras] = ${sys}_nppp_numpar;
  [y,u,t] = ${sys}_nppp(last, ppp_names, par_names, A_u, A_w, w, Q, extras);
  data = [t,y,u];
  save -ascii ${dat2_file} data
EOF
}

case ${lang} in
    help_short)
        help_short
        ;;
    help_long)
        help_long
        ;;
    numpar.m)
        ## Make the numpar stuff
        make_nppp_numpar;
	;;
    m)
        ## Make the code
        make_nppp;







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<















<
<
<
<
<
<







225
226
227
228
229
230
231

































232
233
234
235
236
237
238
239
240
241
242
243
244
245
246






247
248
249
250
251
252
253
  extras.verbose = 0;
  extras.visual = 0;

endfunction
EOF
}


































make_dat2() {

## Inform user
echo Creating ${dat2_file}

## Use octave to generate the data
octave -q <<EOF
  [last, ppp_names, par_names, A_u, A_w, w, Q, extras] = ${sys}_nppp_numpar;
  [y,u,t] = ${sys}_nppp(last, ppp_names, par_names, A_u, A_w, w, Q, extras);
  data = [t,y,u];
  save -ascii ${dat2_file} data
EOF
}

case ${lang} in






    numpar.m)
        ## Make the numpar stuff
        make_nppp_numpar;
	;;
    m)
        ## Make the code
        make_nppp;
306
307
308
309
310
311
312
313

314
315
316
317
318
319
320
	gdat2fig ${sys}_${rep}
	;;
    ps)
	fig2dev -Leps ${sys}_${rep}.fig > ${sys}_${rep}.ps
	;;

    view)
	

	;;
    *)
	echo Language ${lang} not supported by nppp representation
        exit 3
esac









|
>


|




265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
	gdat2fig ${sys}_${rep}
	;;
    ps)
	fig2dev -Leps ${sys}_${rep}.fig > ${sys}_${rep}.ps
	;;

    view)
	echo Viewing ${sys}_${rep}.ps
        gv ${sys}_${rep}.ps&
	;;
    *)
	echo Language ${lang} not supported by ${rep} representation
        exit 3
esac



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