Overview
Comment:Revised to incorporate new ssim (sensitivity simulation)
representation (m only just now).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 5fc249a8b0234c9a555dccfd3d6b237889553e99f1c22d112cb7731e29ed7a63
User & Date: gawthrop@users.sourceforge.net on 2001-04-03 14:49:42
Other Links: branch diff | manifest | tags
Context
2001-04-03
14:51:30
Equivalent to the c pow function (computes x^y) check-in: bc591b3819 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
14:49:42
Revised to incorporate new ssim (sensitivity simulation)
representation (m only just now).
check-in: 5fc249a8b0 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2001-04-02
17:36:20
Resolved $sys name clash when using -s check-in: 06cc77a126 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/mtt from [19a5e855c5] to [4213d56b9a].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$



## Revision 1.297  2001/03/29 19:20:45  gawthrop
## Can now use c representations of crs when using -c option
##
## Revision 1.296  2001/03/27 01:07:34  geraint
## Improved determination of Octave version for ode2odes.exe creation.
## Removed FORCE check_update of .txts.
##







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.298  2001/04/02 17:36:20  gawthrop
## Resolved $sys name clash when using -s
##
## Revision 1.297  2001/03/29 19:20:45  gawthrop
## Can now use c representations of crs when using -c option
##
## Revision 1.296  2001/03/27 01:07:34  geraint
## Improved determination of Octave version for ode2odes.exe creation.
## Removed FORCE check_update of .txts.
##
1534
1535
1536
1537
1538
1539
1540

1541

1542
1543
1544
1545
1546
1547
1548
      n_found=`echo $comp_path | wc | awk '{print $2}'`

      if [ "$n_found" = "1" ]; then
         echo Copying $2 from $comp_path to $destination
         cp $comp_path/*_*.* $destination
         exit 0
      elif [ "$n_found" = "0" ]; then

         echo Component $2 not found - is MTT_COMPONENTS set correctly?

         exit 1
      elif [ "$n_found" > "1" ]; then
         echo "Multiple versions of $2 found (see below) - use a more explicit alias"
         mtt -q find $2
         exit 2
      fi
    fi







>
|
>







1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
      n_found=`echo $comp_path | wc | awk '{print $2}'`

      if [ "$n_found" = "1" ]; then
         echo Copying $2 from $comp_path to $destination
         cp $comp_path/*_*.* $destination
         exit 0
      elif [ "$n_found" = "0" ]; then
	if [ "$quiet" != "quiet" ]; then    
           echo Component $2 not found - is MTT_COMPONENTS set correctly?
        fi
         exit 1
      elif [ "$n_found" > "1" ]; then
         echo "Multiple versions of $2 found (see below) - use a more explicit alias"
         mtt -q find $2
         exit 2
      fi
    fi
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
esac

################################
# This is the main mtt programme
################################


echo Target is $target, Subsystem is $Subsystem, options are $mtt_switches
$MAKE -S $verbose  -f  -  $target << EOF

# Cancel implicit rules I don't want
%.dvi: %.tex

# MTT implicit rules
## .oct files







|







1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
esac

################################
# This is the main mtt programme
################################


#echo Target is $target, Subsystem is $Subsystem, options are $mtt_switches
$MAKE -S $verbose  -f  -  $target << EOF

# Cancel implicit rules I don't want
%.dvi: %.tex

# MTT implicit rules
## .oct files
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910

ifeq ("$sensitivity","sensitivity")
ifeq ("$level","0")
$1_abg.fig: $sys_abg.fig
	abg2sensitivity_fig $sys_s
else # Either find the sensitivity model or fetch the model and create sensitivity model
$1_abg.fig:
	mtt -q -u $mtt_switches compcopy $1 || abg2sensitivity_fig $sys
endif
endif

ifneq ("$sensitivity","sensitivity")
ifneq ("$level","0")
# If level>0, try and get subsystem files; creating if necessary
$1_abg.fig:







|







1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915

ifeq ("$sensitivity","sensitivity")
ifeq ("$level","0")
$1_abg.fig: $sys_abg.fig
	abg2sensitivity_fig $sys_s
else # Either find the sensitivity model or fetch the model and create sensitivity model
$1_abg.fig:
	mtt -q -u $mtt_switches compcopy $1 || abg2sensitivity_fig $sys_s
endif
endif

ifneq ("$sensitivity","sensitivity")
ifneq ("$level","0")
# If level>0, try and get subsystem files; creating if necessary
$1_abg.fig:
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
#SUMMARY numpar	numerical parameter declaration (c) 
#SUMMARY numpar	numerical parameter declaration (view) 
$1_numpar.c:  $1_numpar.txt $1_sympar.c
	txt2c $1 numpar



#SUMMARY input	numerical input declaration (m) 
$1_input.m:  $1_input.txt $1_sympars.txt
	mtt_txt2m $1 input

#SUMMARY input	numerical input declaration (m) 
$1_logic.m:  $1_logic.txt $1_switch.txt
	mtt_txt2m $1 logic

#SUMMARY state	state declaration  -- default (txt)
#$1_state.txt: 
#	mtt $mtt_switches $1 struc txt; 
#	mtt $mtt_switches $1 ss r; 







|
<
<
<
<







2166
2167
2168
2169
2170
2171
2172
2173




2174
2175
2176
2177
2178
2179
2180
#SUMMARY numpar	numerical parameter declaration (c) 
#SUMMARY numpar	numerical parameter declaration (view) 
$1_numpar.c:  $1_numpar.txt $1_sympar.c
	txt2c $1 numpar



#SUMMARY logic	logic input declaration (m) 




$1_logic.m:  $1_logic.txt $1_switch.txt
	mtt_txt2m $1 logic

#SUMMARY state	state declaration  -- default (txt)
#$1_state.txt: 
#	mtt $mtt_switches $1 struc txt; 
#	mtt $mtt_switches $1 ss r; 
2501
2502
2503
2504
2505
2506
2507

2508


2509
2510
2511


2512
2513
2514
2515
2516
2517
2518
$1_simpar.p : $1_def.r $1_simpar.m
	mtt_m2p $1_simpar.m
$1_numpar.p : $1_def.r $1_numpar.m
	mtt_m2p $1_numpar.m
$1_state.p : $1_def.r $1_state.m
	mtt_m2p $1_state.m


ifeq ($stdin,stdin)


$1_input.p : $1_def.r
	make_stdin $1 p
else


$1_input.p : $1_def.r $1_input.m
	mtt_m2p $1_input.m
endif

$1_ode.p : $1_def.r $1_ode.m
	mtt_m2p $1_ode.m
$1_odeo.p : $1_def.r $1_odeo.m







>

>
>



>
>







2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
$1_simpar.p : $1_def.r $1_simpar.m
	mtt_m2p $1_simpar.m
$1_numpar.p : $1_def.r $1_numpar.m
	mtt_m2p $1_numpar.m
$1_state.p : $1_def.r $1_state.m
	mtt_m2p $1_state.m

#SUMMARY input	numerical input declaration (m) 
ifeq ($stdin,stdin)
$1_input.m : $1_def.r
	make_stdin $1 m
$1_input.p : $1_def.r
	make_stdin $1 p
else
$1_input.m:  $1_input.txt $1_sympars.txt
	mtt_txt2m $1 input
$1_input.p : $1_def.r $1_input.m
	mtt_m2p $1_input.m
endif

$1_ode.p : $1_def.r $1_ode.m
	mtt_m2p $1_ode.m
$1_odeo.p : $1_def.r $1_odeo.m

Added mttroot/mtt/bin/trans/make_ssim version [d5e1c0a187].































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#!/bin/sh

## Makes the sensitivity simulation
## Copyright (C) 2001 by Peter J. Gawthrop

sys=$1
lang=$2

outfile=${sys}_ssim.${lang}

echo Creating $outfile
make_m() {
mtt_header ${sys} ssim m >  ${outfile}
cat >> ${outfile} <<EOF

  ## Pass input as a global
  global MTT_input MTT_input_index MTT_input_last

  [nx2,ny2] = ${sys}_def;
  ny = ny2/2;
  y_par = [];
  MTT_input = u;
  [MTT_input_last,m] = size(u);

  for i=index
    MTT_input_index = 0;
    p = par;
    p(i) = 1;
    [mtt_data] = ${sys}_ode2odes(x0,p,simpar);
    if (i==index(1))
      y = mtt_data(:,2:1+ny);
    endif
    y_par = [y_par, mtt_data(:,2+ny:1+2*ny)];
  endfor
endfunction

EOF

}

case ${lang} in
    m)
	make_m
	;;
    *)
	echo Language ${lang} not supported - sorry
esac

Modified mttroot/mtt/bin/trans/make_stdin from [506a71f422] to [d40985b5b8].

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
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

## 	$Id$	

# Copyright (C) 1999 by Peter J. Gawthrop

# Tell user
Sys=$1
lang=$2
date=`date`

Nu=`grep "MTTNu " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'`

echo  "Creating $1_input.$2 for standard input"




cat <<EOF > $1_input.$2 
PROCEDURE $1_input(VAR mttu : InputVector;
                       mttt : REAL;
                       mttx : StateVector;
                       mtty : OutputVector);



{Created by MTT on $date for standard input to simulation}

VAR t : REAL; Start:BOOLEAN;

BEGIN{$1_input}
  {Zap comments}








|





>
|
>
|

>
>
>
|

<

|
>
>







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
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

## 	$Id$	

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

# Tell user
Sys=$1
lang=$2
date=`date`
outfile=$1_input.$2

Nu=`mtt_getsize $Sys u` # Inputs 
echo  "Creating $outfile for standard input"

## Pascal code
make_p()
{
cat <<EOF > $outfile
PROCEDURE $1_input(VAR mttu : InputVector;

                       mttx : StateVector;
                       mtty : OutputVector;
                       mttt : REAL;
                       par  : ParameterVector);

{Created by MTT on $date for standard input to simulation}

VAR t : REAL; Start:BOOLEAN;

BEGIN{$1_input}
  {Zap comments}
37
38
39
40
41
42
43



















































  FOR mtti:=1 TO $Nu DO {Read the inputs}
    read(mttu[mtti]);
  readln; {Next line}


END{$1_input};
EOF


























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
  FOR mtti:=1 TO $Nu DO {Read the inputs}
    read(mttu[mtti]);
  readln; {Next line}


END{$1_input};
EOF
}

make_m() {
mtt_header $Sys input m stdin > $outfile
cat >> $outfile <<EOF
## The "standard input"
global MTT_input MTT_input_index MTT_input_last
  
  MTT_input_index = min(++MTT_input_index,MTT_input_last);
  mttu = MTT_input(MTT_input_index,:);
## END Code
endfunction
EOF

}


make_cc() {
cat > $outfile <<EOF
#include "${Sys}_def.h"

DEFUN_DLD (sidRC_input, args, ,
"Usage: [mttu] = sidRC_input(mttx,mtty,mttt,mttpar)
Octave input representation of system sidRC");

{
  static ColumnVector	u (MTTNU);
  static Matrix mtt_input;
  octave_value_list retval;
  
  mtt_input = octave_value (get_global_value ("MTT_input"));

  retval (0)	= octave_value (mtt_input);
  return (retval);
}
EOF
}

case $lang in
    p)
	make_p
	;;
    m)
	make_m
	;;
    cc)
	make_cc
	;;
    *)
	echo language $lang not supported - sorry
esac

Modified mttroot/mtt/bin/trans/mtt_header from [61f3b439e7] to [6a295989c6].

8
9
10
11
12
13
14



15
16
17
18
19
20
21
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.29  2001/03/27 13:10:23  geraint
## Improved determination of Octave version.
##
## Revision 1.28  2001/02/17 03:48:17  geraint
## Use assignment LHS to gather tmp variable names.
## Prevents collection of long expressions, eg: tmp34*(tmp75
##







>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.30  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.29  2001/03/27 13:10:23  geraint
## Improved determination of Octave version.
##
## Revision 1.28  2001/02/17 03:48:17  geraint
## Use assignment LHS to gather tmp variable names.
## Prevents collection of long expressions, eg: tmp34*(tmp75
##
121
122
123
124
125
126
127
128

129


130

131
132
133
134
135
136
137
###############################################################

# Arguments
system=$1
rep=$2
language=$3
fun_name=${1}_${2}
#args=$4

#output=$5


#extras=$6


# Find system constants
Nx=`mtt_getsize $system x` # States
Nxx=`mtt_getsize $system xx` # States x States
Nu=`mtt_getsize $system u` # Inputs 
Ny=`mtt_getsize $system y` # Outputs 
Nyz=`mtt_getsize $system yz` # Zero outputs







|
>
|
>
>
|
>







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
###############################################################

# Arguments
system=$1
rep=$2
language=$3
fun_name=${1}_${2}

other=$4 # Anything else eg stdin

if [ -z "$system" ]; then
  echo 'Usage: mtt_header sys rep lang [stdin]'
  exit
fi

# Find system constants
Nx=`mtt_getsize $system x` # States
Nxx=`mtt_getsize $system xx` # States x States
Nu=`mtt_getsize $system u` # Inputs 
Ny=`mtt_getsize $system y` # Outputs 
Nyz=`mtt_getsize $system yz` # Zero outputs
183
184
185
186
187
188
189
190
191
192
193
194







195

196
197
198
199
200
201
202
	inputs=no;
	parameters=yes;
        output='mtta,mttb,mttc,mttd,mtte'
        args=mttpar
        zeromatrices='a b c d e';
	;;
   input)
	states=yes;
	inputs=no;
	parameters=yes;
        output=mttu
        args=$inputeqnargs







        declareinputs=yes

	;;
    logic)
	states=no;
	inputs=no;
	parameters=yes;
        output=mttopen
        args=$eqnargs







<

<


>
>
>
>
>
>
>
|
>







190
191
192
193
194
195
196

197

198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
	inputs=no;
	parameters=yes;
        output='mtta,mttb,mttc,mttd,mtte'
        args=mttpar
        zeromatrices='a b c d e';
	;;
   input)

	inputs=no;

        output=mttu
        args=$inputeqnargs
        if [ "$other" = "stdin" ]; then
	  states=no;
	  parameters=no;
          declareinputs=no;
        else
	  states=yes;
	  parameters=yes;
          declareinputs=yes
        fi
	;;
    logic)
	states=no;
	inputs=no;
	parameters=yes;
        output=mttopen
        args=$eqnargs
263
264
265
266
267
268
269







270
271
272
273
274
275
276
	states=no;
	inputs=no;
	parameters=yes;
        output=mttx
        args=mttpar
        declarestates=yes
	;;







    *)
	echo Representation $rep not supported - sorry; exit 1
esac

## Sort out parentheses
if [ -n "$args" ]; then
    Args='('$args')'







>
>
>
>
>
>
>







276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
	states=no;
	inputs=no;
	parameters=yes;
        output=mttx
        args=mttpar
        declarestates=yes
	;;
    ssim)
	states=no;
        inputs=no;
	parameters=no;
        output='y,y_par'
        args='x0,par,simpar,u,index'
	;;
    *)
	echo Representation $rep not supported - sorry; exit 1
esac

## Sort out parentheses
if [ -n "$args" ]; then
    Args='('$args')'
285
286
287
288
289
290
291

292

293
294
295
296
297
298
299
    m)
	Lc='##';
	Rc='';
	Lb='(';
	Rb=')';
	function="function"
	declaration="$Output$1_$rep$Args;"

	noglobals=true; # Fudge to make mtt_m2p work

        start='## BEGIN Code'
        finish='## END Code'
        var_declaration=
        declarestates=no
        declareinputs=no
	declareswitches=no
	;;







>
|
>







305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
    m)
	Lc='##';
	Rc='';
	Lb='(';
	Rb=')';
	function="function"
	declaration="$Output$1_$rep$Args;"
        if [ "$other" != "stdin" ]; then
	  noglobals=true; # Fudge to make mtt_m2p work
        fi     
        start='## BEGIN Code'
        finish='## END Code'
        var_declaration=
        declarestates=no
        declareinputs=no
	declareswitches=no
	;;


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