DELETED CVSROOT/checkoutlist Index: CVSROOT/checkoutlist ================================================================== --- CVSROOT/checkoutlist +++ /dev/null @@ -1,14 +0,0 @@ -# The "checkoutlist" file is used to support additional version controlled -# administrative files in $CVSROOT/CVSROOT, such as template files. -# -# The first entry on a line is a filename which will be checked out from -# the corresponding RCS file in the $CVSROOT/CVSROOT directory. -# The remainder of the line is an error message to use if the file cannot -# be checked out. -# -# File format: -# -# [] -# -# comment lines begin with '#' -syncmail DELETED CVSROOT/commitinfo Index: CVSROOT/commitinfo ================================================================== --- CVSROOT/commitinfo +++ /dev/null @@ -1,15 +0,0 @@ -# The "commitinfo" file is used to control pre-commit checks. -# The filter on the right is invoked with the repository and a list -# of files to check. A non-zero exit of the filter program will -# cause the commit to be aborted. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being committed to, relative -# to the $CVSROOT. For the first match that is found, then the remainder -# of the line is the name of the filter to run. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". DELETED CVSROOT/config Index: CVSROOT/config ================================================================== --- CVSROOT/config +++ /dev/null @@ -1,11 +0,0 @@ -# Set this to "no" if pserver shouldn't check system users/passwords -#SystemAuth=no - -# Set `PreservePermissions' to `yes' to save file status information -# in the repository. -#PreservePermissions=no - -# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top -# level of the new working directory when using the `cvs checkout' -# command. -#TopLevelAdmin=no DELETED CVSROOT/cvswrappers Index: CVSROOT/cvswrappers ================================================================== --- CVSROOT/cvswrappers +++ /dev/null @@ -1,23 +0,0 @@ -# This file affects handling of files based on their names. -# -# The -t/-f options allow one to treat directories of files -# as a single file, or to transform a file in other ways on -# its way in and out of CVS. -# -# The -m option specifies whether CVS attempts to merge files. -# -# The -k option specifies keyword expansion (e.g. -kb for binary). -# -# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) -# -# wildcard [option value][option value]... -# -# where option is one of -# -f from cvs filter value: path to filter -# -t to cvs filter value: path to filter -# -m update methodology value: MERGE or COPY -# -k expansion mode value: b, o, kkv, &c -# -# and value is a single-quote delimited value. -# For example: -#*.gif -k 'b' DELETED CVSROOT/editinfo Index: CVSROOT/editinfo ================================================================== --- CVSROOT/editinfo +++ /dev/null @@ -1,21 +0,0 @@ -# The "editinfo" file is used to allow verification of logging -# information. It works best when a template (as specified in the -# rcsinfo file) is provided for the logging procedure. Given a -# template with locations for, a bug-id number, a list of people who -# reviewed the code before it can be checked in, and an external -# process to catalog the differences that were code reviewed, the -# following test can be applied to the code: -# -# Making sure that the entered bug-id number is correct. -# Validating that the code that was reviewed is indeed the code being -# checked in (using the bug-id number or a seperate review -# number to identify this particular code set.). -# -# If any of the above test failed, then the commit would be aborted. -# -# Actions such as mailing a copy of the report to each reviewer are -# better handled by an entry in the loginfo file. -# -# One thing that should be noted is the the ALL keyword is not -# supported. There can be only one entry that matches a given -# repository. DELETED CVSROOT/loginfo Index: CVSROOT/loginfo ================================================================== --- CVSROOT/loginfo +++ /dev/null @@ -1,30 +0,0 @@ -# The "loginfo" file controls where "cvs commit" log information -# is sent. The first entry on a line is a regular expression which must match -# the directory that the change is being made to, relative to the -# $CVSROOT. If a match is found, then the remainder of the line is a filter -# program that should expect log information on its standard input. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name ALL appears as a regular expression it is always used -# in addition to the first matching regex or DEFAULT. -# -# You may specify a format string as part of the -# filter. The string is composed of a `%' followed -# by a single format character, or followed by a set of format -# characters surrounded by `{' and `}' as separators. The format -# characters are: -# -# s = file name -# V = old version number (pre-checkin) -# v = new version number (post-checkin) -# -# For example: -#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog -# or -#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog - -# Lines to mail changes -CVSROOT $CVSROOT/CVSROOT/syncmail %{sVv} gawthrop@users.sourceforge.net -DEFAULT $CVSROOT/CVSROOT/syncmail %{sVv} mtt-checkins@lists.sourceforge.net DELETED CVSROOT/modules Index: CVSROOT/modules ================================================================== --- CVSROOT/modules +++ /dev/null @@ -1,26 +0,0 @@ -# Three different line formats are valid: -# key -a aliases... -# key [options] directory -# key [options] directory files... -# -# Where "options" are composed of: -# -i prog Run "prog" on "cvs commit" from top-level of module. -# -o prog Run "prog" on "cvs checkout" of module. -# -e prog Run "prog" on "cvs export" of module. -# -t prog Run "prog" on "cvs rtag" of module. -# -u prog Run "prog" on "cvs update" of module. -# -d dir Place module in directory "dir" instead of module name. -# -l Top-level directory only -- do not recurse. -# -# NOTE: If you change any of the "Run" options above, you'll have to -# release and re-checkout any working directories of these modules. -# -# And "directory" is a path to a directory relative to $CVSROOT. -# -# The "-a" option specifies an alias. An alias is interpreted as if -# everything on the right of the "-a" had been typed on the command line. -# -# You can encode a module within a module by using the special '&' -# character to interpose another module into the current module. This -# can be useful for creating a module that consists of many directories -# spread out over the entire source repository. DELETED CVSROOT/notify Index: CVSROOT/notify ================================================================== --- CVSROOT/notify +++ /dev/null @@ -1,12 +0,0 @@ -# The "notify" file controls where notifications from watches set by -# "cvs watch add" or "cvs edit" are sent. The first entry on a line is -# a regular expression which is tested against the directory that the -# change is being made to, relative to the $CVSROOT. If it matches, -# then the remainder of the line is a filter program that should contain -# one occurrence of %s for the user to notify, and information on its -# standard input. -# -# "ALL" or "DEFAULT" can be used in place of the regular expression. -# -# For example: -#ALL mail %s -s "CVS notification" DELETED CVSROOT/rcsinfo Index: CVSROOT/rcsinfo ================================================================== --- CVSROOT/rcsinfo +++ /dev/null @@ -1,13 +0,0 @@ -# The "rcsinfo" file is used to control templates with which the editor -# is invoked on commit and import. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being made to, relative to the -# $CVSROOT. For the first match that is found, then the remainder of the -# line is the name of the file that contains the template. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". DELETED CVSROOT/syncmail Index: CVSROOT/syncmail ================================================================== --- CVSROOT/syncmail +++ /dev/null @@ -1,287 +0,0 @@ -#! /usr/bin/python - -# NOTE: Until SourceForge installs a modern version of Python on the cvs -# servers, this script MUST be compatible with Python 1.5.2. - -"""Complicated notification for CVS checkins. - -This script is used to provide email notifications of changes to the CVS -repository. These email changes will include context diffs of the changes. -Really big diffs will be trimmed. - -This script is run from a CVS loginfo file (see $CVSROOT/CVSROOT/loginfo). To -set this up, create a loginfo entry that looks something like this: - - mymodule /path/to/this/script %%s some-email-addr@your.domain - -In this example, whenever a checkin that matches `mymodule' is made, this -script is invoked, which will generate the diff containing email, and send it -to some-email-addr@your.domain. - - Note: This module used to also do repository synchronizations via - rsync-over-ssh, but since the repository has been moved to SourceForge, - this is no longer necessary. The syncing functionality has been ripped - out in the 3.0, which simplifies it considerably. Access the 2.x versions - to refer to this functionality. Because of this, the script is misnamed. - -It no longer makes sense to run this script from the command line. Doing so -will only print out this usage information. - -Usage: - - %(PROGRAM)s [options] <%%S> email-addr [email-addr ...] - -Where options is: - - --cvsroot= - Use as the environment variable CVSROOT. Otherwise this - variable must exist in the environment. - - --help / -h - Print this text. - - --context=# - -C # - Include # lines of context around lines that differ (default: 2). - - -c - Produce a context diff (default). - - -u - Produce a unified diff (smaller). - - --quiet/-q - Don't print as much status to stdout. - - <%%S> - CVS %%s loginfo expansion. When invoked by CVS, this will be a single - string containing the directory the checkin is being made in, relative - to $CVSROOT, followed by the list of files that are changing. If the - %%s in the loginfo file is %%{sVv}, context diffs for each of the - modified files are included in any email messages that are generated. - - email-addrs - At least one email address. -""" -import os -import sys -import time -import string -import getopt -import smtplib -import pwd -import socket - -from cStringIO import StringIO - -# Which SMTP server to do we connect to? Empty string means localhost. -MAILHOST = '' -MAILPORT = 25 - -# Diff trimming stuff -DIFF_HEAD_LINES = 20 -DIFF_TAIL_LINES = 20 -DIFF_TRUNCATE_IF_LARGER = 1000 - -EMPTYSTRING = '' -SPACE = ' ' -DOT = '.' -COMMASPACE = ', ' - -PROGRAM = sys.argv[0] - -BINARY_EXPLANATION_LINES = [ - "(This appears to be a binary file; contents omitted.)\n" - ] - - -def usage(code, msg=''): - print __doc__ % globals() - if msg: - print msg - sys.exit(code) - - - -def calculate_diff(filespec, contextlines): - try: - file, oldrev, newrev = string.split(filespec, ',') - except ValueError: - # No diff to report - return '***** Bogus filespec: %s' % filespec - if oldrev == 'NONE': - try: - if os.path.exists(file): - fp = open(file) - else: - update_cmd = 'cvs -fn update -r %s -p %s' % (newrev, file) - fp = os.popen(update_cmd) - lines = fp.readlines() - fp.close() - # Is this a binary file? Let's look at the first few - # lines to figure it out: - for line in lines[:5]: - for c in string.rstrip(line): - if c in string.whitespace: - continue - if c < ' ' or c > chr(127): - lines = BINARY_EXPLANATION_LINES[:] - break - lines.insert(0, '--- NEW FILE: %s ---\n' % file) - except IOError, e: - lines = ['***** Error reading new file: ', - str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()] - elif newrev == 'NONE': - lines = ['--- %s DELETED ---\n' % file] - else: - # This /has/ to happen in the background, otherwise we'll run into CVS - # lock contention. What a crock. - if contextlines > 0: - difftype = "-C " + str(contextlines) - else: - difftype = "-u" - diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s '%s'" % ( - difftype, oldrev, newrev, file) - fp = os.popen(diffcmd) - lines = fp.readlines() - sts = fp.close() - # ignore the error code, it always seems to be 1 :( -## if sts: -## return 'Error code %d occurred during diff\n' % (sts >> 8) - if len(lines) > DIFF_TRUNCATE_IF_LARGER: - removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES - del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES] - lines.insert(DIFF_HEAD_LINES, - '[...%d lines suppressed...]\n' % removedlines) - return string.join(lines, '') - - - -def getdomain(): - try: - fqdn = socket.getfqdn() - except AttributeError: - # Python 1.5.2 :( - hostname = socket.gethostname() - byaddr = socket.gethostbyaddr(socket.gethostbyname(hostname)) - aliases = byaddr[1] - aliases.insert(0, byaddr[0]) - aliases.insert(0, hostname) - for fqdn in aliases: - if '.' in fqdn: - break - else: - fqdn = 'localhost.localdomain' - parts = string.split(fqdn, DOT) - return string.join(parts[1:], DOT) - - - -def blast_mail(subject, people, filestodiff, contextlines): - # cannot wait for child process or that will cause parent to retain cvs - # lock for too long. Urg! - if not os.fork(): - # in the child - # give up the lock you cvs thang! - time.sleep(2) - # Create the smtp connection to the localhost - conn = smtplib.SMTP() - conn.connect(MAILHOST, MAILPORT) - user = pwd.getpwuid(os.getuid())[0] - domain = getdomain() - author = '%s@%s' % (user, domain) - s = StringIO() - sys.stdout = s - try: - print '''\ -From: %(author)s -To: %(people)s -Subject: %(subject)s -''' % {'author' : author, - 'people' : string.join(people, COMMASPACE), - 'subject': subject, - } - s.write(sys.stdin.read()) - # append the diffs if available - print - for file in filestodiff: - print calculate_diff(file, contextlines) - finally: - sys.stdout = sys.__stdout__ - resp = conn.sendmail(author, people, s.getvalue()) - conn.close() - os._exit(0) - - - -# scan args for options -def main(): - try: - opts, args = getopt.getopt(sys.argv[1:], 'hC:cuq', - ['context=', 'cvsroot=', 'help', 'quiet']) - except getopt.error, msg: - usage(1, msg) - - # parse the options - contextlines = 2 - verbose = 1 - for opt, arg in opts: - if opt in ('-h', '--help'): - usage(0) - elif opt == '--cvsroot': - os.environ['CVSROOT'] = arg - elif opt in ('-C', '--context'): - contextlines = int(arg) - elif opt == '-c': - if contextlines <= 0: - contextlines = 2 - elif opt == '-u': - contextlines = 0 - elif opt in ('-q', '--quiet'): - verbose = 0 - - # What follows is the specification containing the files that were - # modified. The argument actually must be split, with the first component - # containing the directory the checkin is being made in, relative to - # $CVSROOT, followed by the list of files that are changing. - if not args: - usage(1, 'No CVS module specified') - subject = args[0] - specs = string.split(args[0]) - del args[0] - - # The remaining args should be the email addresses - if not args: - usage(1, 'No recipients specified') - - # Now do the mail command - people = args - - if verbose: - print 'Mailing %s...' % string.join(people, COMMASPACE) - - if specs == ['-', 'Imported', 'sources']: - return - if specs[-3:] == ['-', 'New', 'directory']: - del specs[-3:] - elif len(specs) > 2: - L = specs[:2] - for s in specs[2:]: - prev = L[-1] - if string.count(prev, ',') < 2: - L[-1] = "%s %s" % (prev, s) - else: - L.append(s) - specs = L - - if verbose: - print 'Generating notification message...' - blast_mail(subject, people, specs[1:], contextlines) - if verbose: - print 'Generating notification message... done.' - - - -if __name__ == '__main__': - main() - sys.exit(0) DELETED CVSROOT/taginfo Index: CVSROOT/taginfo ================================================================== --- CVSROOT/taginfo +++ /dev/null @@ -1,20 +0,0 @@ -# The "taginfo" file is used to control pre-tag checks. -# The filter on the right is invoked with the following arguments: -# -# $1 -- tagname -# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d -# $3 -- repository -# $4-> file revision [file revision ...] -# -# A non-zero exit of the filter program will cause the tag to be aborted. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being committed to, relative -# to the $CVSROOT. For the first match that is found, then the remainder -# of the line is the name of the filter to run. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". DELETED CVSROOT/verifymsg Index: CVSROOT/verifymsg ================================================================== --- CVSROOT/verifymsg +++ /dev/null @@ -1,21 +0,0 @@ -# The "verifymsg" file is used to allow verification of logging -# information. It works best when a template (as specified in the -# rcsinfo file) is provided for the logging procedure. Given a -# template with locations for, a bug-id number, a list of people who -# reviewed the code before it can be checked in, and an external -# process to catalog the differences that were code reviewed, the -# following test can be applied to the code: -# -# Making sure that the entered bug-id number is correct. -# Validating that the code that was reviewed is indeed the code being -# checked in (using the bug-id number or a seperate review -# number to identify this particular code set.). -# -# If any of the above test failed, then the commit would be aborted. -# -# Actions such as mailing a copy of the report to each reviewer are -# better handled by an entry in the loginfo file. -# -# One thing that should be noted is the the ALL keyword is not -# supported. There can be only one entry that matches a given -# repository. Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -15,10 +15,13 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.353 2002/05/28 18:08:38 geraint +## Fixed [ 547294 ] CRs are not sought from MTT_CRS. +## ## Revision 1.352 2002/05/24 11:04:10 geraint ## Removed unnecessary message about *.log file not existing when -D option is used. ## ## Revision 1.351 2002/05/23 17:08:20 geraint ## `mtt sys sfun zip` now produces an input block and an interface block for MTT models. @@ -2701,11 +2704,11 @@ ifneq ($partition,) echo Doing subsystems mtt_make_subsystems ${sys} rdae r endif mtt_prepend.sh -p $1_modpar.r $1_ese.r # Add modulated parameters to start - ese2rdae_r ${cr_first} ${Subsystem}; tidy ${Subsystem}_rdae.r + ese2rdae_r ${cr_first} ${fixcc} ${Subsystem}; tidy ${Subsystem}_rdae.r ${sys}_dae.r: ${Subsystem}_rdae.r ${Subsystem}_def.r ${Subsystem}_subs.r ${Subsystem}_cr.r ifneq ($partition,) echo Doing subsystems mtt_make_subsystems ${sys} dae r Index: mttroot/mtt/bin/trans/dae2cse_r ================================================================== --- mttroot/mtt/bin/trans/dae2cse_r +++ mttroot/mtt/bin/trans/dae2cse_r @@ -13,10 +13,14 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.20 2002/04/28 18:41:26 geraint +## Fixed [ 549658 ] awk should be gawk. +## Replaced calls to awk with call to gawk. +## ## Revision 1.19 2001/10/26 01:01:49 geraint ## fixcc when rdae_is_dae (-cr). ## ## Revision 1.18 2001/10/05 23:37:32 geraint ## Fixed assignment statement in ae.r when RHS=0. @@ -127,23 +131,25 @@ esac shift done # Create the reduce output code +def2write_r $optimise $1 ae def2write_r $optimise $1 cse def2write_r $optimise $1 csex # Version without E matrix def2write_r $optimise $1 cseo +echo "Creating $1_ae.r $optimise_msg" echo "Creating $1_cse.r $solve_msg $optimise_msg $fix_msg" echo "Creating $1_csex.r $optimise_msg" echo "Creating $1_cseo.r $optimise_msg" # Remove the old log file rm -f dae2cse_r.log # Remove some files -rm -f $1_cse.r? $1_cseo.r? +rm -f $1_ae.r? $1_cse.r? $1_cseo.r? # Use reduce to accomplish the transformation $SYMBOLIC >dae2cse_r.log << EOF %Read the formatting function @@ -319,21 +325,10 @@ % No algebraic variables left! MTTNYz := 0; END; % IF MTTNyz>0 and $solve -OUT "$1_ae.r"; -IF (MTTNyz>0) THEN % not $solve (or perhaps solution failed?) -BEGIN - WRITE "MATRIX MTTyz(",MTTNyz,",1)"; - WRITE "%File: $1_ae.r"; - FOR i := 1:MTTNyz DO - WRITE "MTTyz(",i,",1) := ",MTTyz(i,1)," +0"; -END; % if MTTNyz>0 (and !$solve) -WRITE ";END;"; -SHUT "$1_ae.r"; - OUT "$1_aej.r"; IF (MTTNyz>0) THEN % as above BEGIN WRITE "MATRIX MTTyzj(",MTTNyz,",",MTTNyz,")"; WRITE "%File: $1_aej.r"; @@ -345,10 +340,22 @@ WRITE "MTTyzj(",i,",",j,") := ",didj," +0"; END; END; WRITE ";END;"; SHUT "$1_aej.r"; + +IF MTTNyz>0 THEN % not $solve or solution failed +BEGIN +OUT "$1_ae.r1"; +write "MATRIX MTTYZ(", MTTNyz, ",", 1, ")$"; +SHUT "$1_ae.r1"; +OUT "$1_ae.r2"; +write "%File: $1_ae.r"; +in ("$1_ae_write.r"); +write "END;"; +SHUT "$1_ae.r2"; +END; % Create the matrix declarations OUT "$1_cse.r1"; write "%"; IF (MTTNx > 0) THEN @@ -445,12 +452,14 @@ SHUT "$1_cseo.r2"; END; quit; EOF +touch $1_ae.r1 $1_ae.r2 touch $1_cseo.r1 touch $1_cseo.r2 +cat $1_ae.r1 $1_ae.r2 > $1_ae.r cat $1_cse.r1 $1_cse.r2 > $1_cse.r cat $1_csex.r1 $1_csex.r2 > $1_csex.r cat $1_cseo.r1 $1_cseo.r2 > $1_cseo.r if [ "$solve" = "1" ]; then Index: mttroot/mtt/bin/trans/def2write_r ================================================================== --- mttroot/mtt/bin/trans/def2write_r +++ mttroot/mtt/bin/trans/def2write_r @@ -11,10 +11,32 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.11.2.4 2002/06/05 23:34:33 geraint +## Eliminated argument list too long warnings. +## Now get a Segmentation Fault with very long equations! +## +## Revision 1.11.2.3 2002/06/05 18:23:38 geraint +## Cosmetic change. +## +## Revision 1.11.2.2 2002/06/05 17:57:47 geraint +## Main part of optimisation routine moved to separate file. +## +## Revision 1.11.2.1 2002/06/05 11:14:51 geraint +## ae.r now generated using def2write_r like cse?.r +## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r. +## +## These changes produce the desired result (optimised algebraic equations) but +## have highlighted a problem; when optimisation fails, Reduce does not write +## a result. For complicated systems, this can lead to missing assignments in +## the resultant code. +## +## Revision 1.11 2002/05/17 09:14:58 geraint +## Optimises each line in a separate session. Allows larger models to be built. +## ## Revision 1.10 2002/04/28 18:41:27 geraint ## Fixed [ 549658 ] awk should be gawk. ## Replaced calls to awk with call to gawk. ## ## Revision 1.9 2001/07/27 23:29:10 geraint @@ -79,10 +101,15 @@ Nyz=`mtt_getsize $sys yz` # Zero outputs #Npar=`wc -l $sys\_sympar.txt | gawk '{print $1}'` # Set up representation-specific stuff case $rep in + ae) + matrices='Yz' + ns="$Nyz" + ms="1" + ;; cse) matrices='EdX E' ns="$Nx $Nx" ms="1 $Nx" ;; @@ -144,48 +171,22 @@ mtt_optimise () { sys="$1" lhs="$2" - rhs="$3" - - crr="${sys}_cr.r" - dae="${sys}_dae.r" - tmp="mtt_optimise.tmp" - tmp2="mtt_optimise2.tmp" - tmp3="mtt_optimise3.tmp" - - { - cat < $tmp - - echo "optimize" >> $tmp - grep -i -e "^$lhs" $dae |\ - sed -e 's/;/\ INAME\ mtt_tmp/g' |\ - sed -e 's/:=/:=/g' >> $tmp - { - cat <> $tmp - - ${SYMBOLIC:-reduce} < $tmp >> def2write_r1.log 2>> def2write_r2.log - cat $tmp2 | gawk -v RS=';' '($2 == ":=") {print $0}' > $tmp3 - cat $tmp3 | mtt_fix_integers - rm -f $tmp $tmp2 $tmp3 - return + + lhs=`echo $lhs | sed 's/MTTEdX/MTTdX/'` + + dae="${sys}_dae.r" + tmp=mtt_optimise.tmp + + # get rhs and write to tmp file to be processed by mtt_optimise.sh + eval "grep -i -e \"^$lhs\"" $dae | eval "sed 's/\([.]*\)[;$]*$/\1/'" | eval "sed 's/\ //g'" | eval "sed 's/:=/ /'" > $tmp + eval mtt_optimise.sh $tmp + cat $tmp | mtt_fix_integers + + return 0 } # Remove log files rm -f def2write_r1.log def2write_r2.log @@ -208,11 +209,11 @@ js=`n2m 1 $m`; for i in $is; do for j in $js; do if [ ${opt:-""} = "-optimise" ]; then name=`echo MTT$matrix'('$i','$j')'` - mtt_optimise $1 "$comma$name" "$name" + mtt_optimise $1 "$comma$name" comma='' else echo 'write' name=`echo MTT$matrix'('$i','$j')'` echo ' '$comma$name ':=' $name '$' Index: mttroot/mtt/bin/trans/ese2rdae_r ================================================================== --- mttroot/mtt/bin/trans/ese2rdae_r +++ mttroot/mtt/bin/trans/ese2rdae_r @@ -12,10 +12,23 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.12.2.1 2002/06/05 11:14:51 geraint +## ae.r now generated using def2write_r like cse?.r +## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r. +## +## These changes produce the desired result (optimised algebraic equations) but +## have highlighted a problem; when optimisation fails, Reduce does not write +## a result. For complicated systems, this can lead to missing assignments in +## the resultant code. +## +## Revision 1.12 2001/07/23 23:31:17 gawthrop +## Added -cr option to load CRs first - avoids alg. loops with R +## implementation of mutiports. +## ## Revision 1.11 2001/07/06 00:46:50 gawthrop ## Added -cr option -- forces cr to be loaded before the ese.r file ## This avoids causality problems when using multi-port Rs to represent ## arbitary equations ## @@ -98,10 +111,14 @@ info=info;; -cr ) load_cr=yes; blurb2=' using cr and subs first'; ;; + -fixcc ) + include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'` + blurb3='fixing c and cc code'; + ;; -partition ) partition=yes; blurb='with partitioning'; ;; *) @@ -134,11 +151,11 @@ load_cr_comm="in \"${crname}\";" load_subs_comm="in \"${subsname}\";" fi # Inform user -echo Creating $daename $blurb $blurb2 +echo Creating $daename $blurb $blurb2 $blurb3 # Remove the old log file rm -f $logname # Use symbolic algebra to accomplish the transformation @@ -154,10 +171,13 @@ % Definitions in "$defname"; % Elementary system equations in "$esename"; + +% Fix c code if required +$include OFF Echo; OFF Nat; %Create the output file Index: mttroot/mtt/bin/trans/m/args2arg.m ================================================================== --- mttroot/mtt/bin/trans/m/args2arg.m +++ mttroot/mtt/bin/trans/m/args2arg.m @@ -26,6 +26,28 @@ % Field separator if nargin<3 FS = ';'; end; + +arg = ''; +if strcmp(args, '')==0 + L = length(args); + args_count = 0; + for i=1:n + arg_count = 0; + arg = ''; + if args_count == L + break; + end; + while args_count < L + args_count = args_count+1; + arg_count = arg_count+1; + ch = str2ch(args,args_count); + if ch==FS + break; + end; + arg = [arg ch]; + end; + end; +end; ADDED mttroot/mtt/bin/trans/mtt_optimise.sh Index: mttroot/mtt/bin/trans/mtt_optimise.sh ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/mtt_optimise.sh @@ -0,0 +1,52 @@ +#! /bin/sh + +set -e +set -x + +filename="$1" + +# set work file names + +tmp="$0.tmp" +log="$0.log" + +optimise_with_reduce () +{ + cat < $log +off echo$ +load scope$ +on double$ +on noconvert$ +on rounded$ +off int$ +off nat$ + +out "${tmp}"$ +optimize mtt_tmp0 :=: `cat ${filename} | gawk '{ print $2 }'` iname mtt_tmp$ +write "`cat ${filename} | gawk '{ print $1 }'` := mtt_tmp0"$ +shut "${tmp}"$ + +;end; +EOF +} + +optimise_with_maxima () +{ + cat ${filename} |\ + tr "\t\n" " " |\ + sed -e 's/\ //g' |\ + sed -e 's/\(MTTdX([0-9.]*,[0-9.]*)\)/\1 /' |\ + sed -e 's/\(MTTy([0-9.]*,[0-9.]*)\)/\1 /' |\ + sed -e 's/\(MTTYz([0-9.]*,[0-9.]*)\)/\1 /' |\ + sed -e 's/[A-Za-z0-9_.:()]*(D2)\(.*\)/\1/' |\ + sed -e 's/\([A-Za-z0-9_.:()]*\)(C3)/\1/g' |\ + optimise_max2r.awk |\ + tr "A-Z" "a-z" > ${tmp} +} + + +optimise_with_maxima +#cat $filename +mv ${tmp} ${filename} + +exit 0 ADDED mttroot/mtt/bin/trans/optimise_max2r.awk Index: mttroot/mtt/bin/trans/optimise_max2r.awk ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/optimise_max2r.awk @@ -0,0 +1,49 @@ +#! /usr/bin/awk -f + +# Maxima optimized expression format: +# (C1) DISPLAY2D:FALSE$ +# (C2) OPTIMIZE(x); +# (D2) x +# (C3) OPTIMIZE((1.0+a*b)/(2.0+a*b)); +# (D3) BLOCK([%1],%1:a*b,(%1+1.0)/(%1+2.0)) + +function decipher_block(lhs,rhs) +{ + s=rhs; + s=gensub(/BLOCK/, "", "1", s); # strip BLOCK keyword + s=gensub(/\(/, "", "1", s); # strip leading ( + s=gensub(/\)$/, "", "1", s); # strip trailing ) + s=gensub(/\[.*\],/, "", "g", s); # strip declarations + s=gensub(/%/, "mtt_tmp", "g", s); # rename tmp variables + s=gensub(/:/, " := ", "g", s); # fix assignment operator + + # commas delimit statements in maxima, so + # preserve commas within function calls + # replace remaining commas with semi-colons + # then put commas back in functions and reinstate parentheses + while (match(s, (/\(([^()]*),([^()]*)\)/))) { + s=gensub(/\(([^()]*),([^()]*)\)/, "(\\1__MTT_COMMA__\\2)", "g", s); + s=gensub(/\(([^,()]*)\)/, "__MTT_LPAREN__\\1__MTT_RPAREN__", "g", s); + } + s=gensub(/,/, ";\n", "g", s); + s=gensub(/__MTT_COMMA__/, ",", "g", s); + s=gensub(/__MTT_LPAREN__/, "(", "g", s); + s=gensub(/__MTT_RPAREN__/, ")", "g", s); + + # separate statements + rhs=gensub(/.*;([^;]*)\n/, "\\1", 1, s); + s=gensub(/;([^;]*)$/, ";", 1, s); + + print s; # print intermediate statements + printf "%s := %s;\n", lhs, rhs; # print final assignment +} + +# pattern matching: + +(! /.* BLOCK.*/ ) { # unoptimised statement + print $1" := "$2";"; +} + +( /.* BLOCK.*/ ) { # optimised statement + decipher_block($1,$2) +} Index: mttroot/mtt/cc/include/useful-functions.hh ================================================================== --- mttroot/mtt/cc/include/useful-functions.hh +++ mttroot/mtt/cc/include/useful-functions.hh @@ -1,16 +1,25 @@ #ifndef HAVE_USEFUL_FUNCTIONS_HH #define HAVE_USEFUL_FUNCTIONS_HH +/* Code generation directives */ +#define STANDALONE 0 +#define OCTAVEDLD 1 +#define MATLABMEX 2 +#if (! defined (CODEGENTARGET)) +#define CODEGENTARGET -1 +#endif /* (! defined (CODEGENTARGET)) */ #ifndef __cplusplus #define inline /* strip */ #define cast_to_double (double) +/* typedef unsigned int bool; const bool true = 1; const bool false = 0; +*/ #else #define cast_to_double static_cast #endif /* ! __cplusplus */ static inline double @@ -37,10 +46,11 @@ return cast_to_double ((x > 0) ? +1 : (x < 0) ? -1 : 0); } /* Octave functions */ +#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == OCTAVEDLD)) #ifdef __cplusplus static Matrix ones (const int r = 1, const int c = 1) { Matrix m (r, c, 1.0); @@ -80,9 +90,10 @@ { Matrix m (r, c, 0.0); return m; } #endif /* __cplusplus */ +#endif /* ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == OCTAVEDLD)) */ #endif /* HAVE_USEFUL_FUNCTIONS_HH */ Index: mttroot/mtt/cc/sympar_txt2h.sh ================================================================== --- mttroot/mtt/cc/sympar_txt2h.sh +++ mttroot/mtt/cc/sympar_txt2h.sh @@ -1,8 +1,23 @@ #! /bin/sh # $Id$ # $Log$ +# Revision 1.7 2002/07/10 11:53:32 geraint +# Replaced shell loop with template expansion - perceptibly quicker generation of sympar.h. +# +# Revision 1.6 2002/05/19 13:01:22 geraint +# Numerical solution of algebraic equations implemented for S-function target. +# +# Equation solving requires the Matlab Optimization Toolbox to be installed. +# +# Code has been changed from C++ to C to allow mex files to be built with LCC, +# the compiler bundled with Matlab. +# +# Parameters are now obtained from numpar.c instead of a dialogue box. +# +# `mtt sfun zip` creates all necessary files for building the model mex files. +# # Revision 1.5 2002/04/28 18:58:06 geraint # Fixed [ 549658 ] awk should be gawk. # Replaced calls to awk with call to gawk. # # Revision 1.4 2001/08/24 21:41:04 geraint @@ -66,16 +81,523 @@ declare_temp_vars () { for name in ${TMP_VAR_NAMES} do echo "" - i=0 - while [ ${i} -le ${NUM_OF_TMP_VAR} ] - do - echo "static double ${name}${i} MTT_UNUSED;" - i=`expr ${i} + 1` - done + + cat < ${OUT} Index: mttroot/mtt/doc/mtt.texi ================================================================== --- mttroot/mtt/doc/mtt.texi +++ mttroot/mtt/doc/mtt.texi @@ -14,10 +14,19 @@ @comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @comment Version control history @comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @comment $Id$ @comment $Log$ +@comment Revision 1.9 2002/07/05 13:29:34 geraint +@comment Added notes about generating dynamically linked functions for Octave and Matlab. +@comment +@comment Revision 1.8 2002/07/04 21:34:12 geraint +@comment Updated gnuplot view description to describe Tcl/Tk interface instead of obsolete txt method. +@comment +@comment Revision 1.7 2002/04/23 09:51:54 gawthrop +@comment Changed incorrect statement about searching for components. +@comment @comment Revision 1.6 2001/10/15 14:29:50 gawthrop @comment Added documentaton on [1:N] style port labels @comment @comment Revision 1.5 2001/07/23 03:35:29 geraint @comment Updated file structure (mtt/bin). @@ -433,10 +442,14 @@ * Euler integration:: * Implicit integration:: * Runge Kutta IV integration:: * Hybrd algebraic solver:: +Simulation code + +* Dynamically linked functions:: + Simulation output * Viewing results with gnuplot:: * Exporting results to SciGraphica:: @@ -660,10 +673,13 @@ * LaTeX:: Octave * Octave control system toolbox (OCST):: +* Creating GNU Octave .oct files:: +* Creating Matlab .mex files:: +* Embedding MTT models in Simulink:: Administration * Software components:: * REDUCE setup:: @@ -2315,10 +2331,44 @@ To generate an executable based on the C++ representation: @example mtt -cc [options] sys ode2odes exe @end example +@menu +* Dynamically linked functions:: +@end menu + +@node Dynamically linked functions, , Simulation code, Simulation code +@comment node-name, next, previous, up +@subsection Dynamically linked functions + +Some model representations can be compiled into dynamically loaded +code (shared objects) which are compiled prior to use in other +modelling and simulation environments; in particular, .oct files can +be generated for use in GNU Octave (@pxref{Creating GNU Octave .oct +files}) and .mex files can be generated for use in Matlab +(@pxref{Creating Matlab .mex files}) or Simulink (@pxref{Embedding MTT +models in Simulink}). The use of compiled (and possibly +compiler-optimised) code can offer significant processing speed +advantages over equivalent interpreted functions (e.g. .m files) for +computationally intensive procedures. + +The C++ code generated by @strong{MTT} allows the same code to be +generated as standalone code, Octave .oct files or Matlab .mexglx +files. Although @strong{MTT} usually takes care of the compilation +options, if it is necessary to compile the code on a machine on which +@strong{MTT} is not installed, the appropriate flag should be passed +to the compiler pre-processor: +@itemize @bullet +@item +@code{-DCODEGENTARGET=STANDALONE} +@item +@code{-DCODEGENTARGET=OCTAVEDLD} +@item +@code{-DCODEGENTARGET=MATLABMEX} +@end itemize + @node Simulation output, , Simulation code, Simulation @comment node-name, next, previous, up @section Simulation output @cindex Simulation output The view (@pxref{Views}) representation provides a graphical @@ -2359,42 +2409,29 @@ @node Viewing results with gnuplot, Exporting results to SciGraphica, Simulation output, Simulation output @comment node-name, next, previous, up@subsection @subsection Viewing results with gnuplot @cindex gnuplot -Simulation results may be viewed in -@uref{http://www.gnuplot.org,gnuplot} with the command +Simulation plots may be conveniently selected, viewed with +@uref{http://www.gnuplot.org,gnuplot} +and saved to file (in PostScript format) using the command @example mtt [options] rc gnuplot view @end example -The plot format is controlled by the file @emph{sys_gnuplot.txt}. A default version -of this file, which will cause gnuplot to plot the time-history of each state -and each output individually, may be created with the command - -@example -mtt rc gnuplot txt -@end example - -resulting in - -@example -wait=-1 -set data style lines -set xlabel "time" -set grid -set term X11 - -plot "rc_odes.dat2" using 1:4 axes x1y1 title "rc_c_c; -pause(wait); -plot "rc_odes.dat2" using 1:2 axes x1y1 title "rc_e2_e2 -; pause(wait); -@end example - -The file is used as an input to the gnuplot program and may therefore be -edited to contain any valid gnuplot commands. +This will cause a menu to be displayed, from which states and outputs may be selected for viewing. Clicking on a @emph{parameter name} will cause a new window to be opened displaying the time history of the selected parameter. Selecting the @emph{print} option in the main window provides the option of saving to file a plot of the last selected parameter. Clicking on the @emph{title bar} of the main window (``Outputs'' or ``States'') will alter the order in which the parameter names are displayed. + +It should be noted that unlike other representations, if a simulation has been previously run in a directory, this command will @emph{not} cause @strong{MTT} to re-run a simulation, even if any of the input files have been changed. + +If it is desired to re-run a simulation, it is advisable to run the command + +@example +mtt [options] rc odeso view ; mtt [options] rc gnuplot view +@end example + +As with @strong{xMTT} (@pxref{Menu-driven interface}), the Wish Tcl/Tk interpreter must be installed to make use of this feature. @node Exporting results to SciGraphica, , Viewing results with gnuplot, Simulation output @comment node-name, next, previous, up @subsection Exporting results to SciGraphica @cindex SciGraphica @@ -3561,11 +3598,11 @@ %% ss1 acts as a flow sensor - it imposes zero effort. ss2 SS 0,external @end example -@node Other component labels , Component names, SS component labels , Labels (lbl) +@node Other component labels, Component names, SS component labels , Labels (lbl) @comment node-name, next, previous, up @subsection Other component labels @cindex Other component labels In addition to the label there are two information fields, @@ -4540,10 +4577,19 @@ # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # %% Version control history # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # %% $Id$ # %% $Log$ +# %% Revision 1.9 2002/07/05 13:29:34 geraint +# %% Added notes about generating dynamically linked functions for Octave and Matlab. +# %% +# %% Revision 1.8 2002/07/04 21:34:12 geraint +# %% Updated gnuplot view description to describe Tcl/Tk interface instead of obsolete txt method. +# %% +# %% Revision 1.7 2002/04/23 09:51:54 gawthrop +# %% Changed incorrect statement about searching for components. +# %% # %% Revision 1.6 2001/10/15 14:29:50 gawthrop # %% Added documentaton on [1:N] style port labels # %% # %% Revision 1.5 2001/07/23 03:35:29 geraint # %% Updated file structure (mtt/bin). @@ -5814,13 +5860,16 @@ @end example @menu * Octave control system toolbox (OCST):: +* Creating GNU Octave .oct files:: +* Creating Matlab .mex files:: +* Embedding MTT models in Simulink:: @end menu -@node Octave control system toolbox (OCST), , Octave, Octave +@node Octave control system toolbox (OCST), Creating GNU Octave .oct files, Octave, Octave @comment node-name, next, previous, up @subsection Octave control system toolbox (OCST) @cindex Octave @cindex toolbox @cindex OCST @@ -5854,11 +5903,143 @@ @example step(rc); bode(rc); @end example - +@node Creating GNU Octave .oct files, Creating Matlab .mex files, Octave control system toolbox (OCST), Octave +@comment node-name, next, previous, up +@subsection Creating GNU Octave .oct files +@cindex Creating GNU Octave .oct files + +GNU Octave dynamically loaded functions (.oct files) can be created by +instructing @strong{MTT} to create the ``oct'' representation: + +@example + mtt [options] sys ode oct +@end example + +This will cause @strong{MTT} to create the C++ representation of the system +(sys_ode.cc) and to then compile it as a shared object suitable for +use within Octave. The resultant file may be used in an identical +manner to the equivalent, but generally slower, interpreted .m file. + +Usage information for the function may be obtained within Octave in the usual manner: + +@example + octave:1> help rc_ode + + rc_ode is the dynamically-linked function from the file + /home/mttuser/rc/rc_ode.oct + + Usage: [mttdx] = rc_ode(mttx,mttu,mttt,mttpar) + Octave ode representation of system rc + Generated by MTT on Fri Jul 5 11:23:08 BST 2002 +@end example + +Note that the first line of output from Octave identifies whether the +compiled or interpreted function is being used. + +Alternatively, standard representations may be generated using the +Octave DLDs by use of the ``-oct'' switch: + +@example + mtt -oct rc odeso view +@end example + +In order to successfully generate .oct files, Octave must be correctly +configured prior to compilation and certain headers and libraries must +be correctly installed on the system (@pxref{.oct file dependencies}). + +@node Creating Matlab .mex files, Embedding MTT models in Simulink, Creating GNU Octave .oct files, Octave +@comment node-name, next, previous, up +@subsection Creating Matlab .mex files +@cindex Creating Matlab .mex files + +On GNU/Linux systems, Matlab dynamically linked executables (.mexglx +files) can created by instructing @strong{MTT} to create the +``mexglx'' representation: + +@example + mtt [options] sys ode mexglx +@end example + +This will cause @strong{MTT} to create the C++ representation of the +system (sys_ode.cc) and to then compile it as a shared object suitable +for use within Matlab. + +If it is necessary to compile mex files for another platform, then the +usual C++ representation (generated with the -cc flag) can be created +and the resultant file compiled with the -DCODEGENTARGET=MATLABMEX +flag on the target platform. + +@example + mtt_machine: + mtt -cc rc ode cc + + matlab_machine: + matlab> mex -DCODEGENTARGET=MATLABMEX rc_ode.cc +@end example + +@node Embedding MTT models in Simulink, , Creating Matlab .mex files, Octave +@comment node-name, next, previous, up +@subsection Embedding MTT models in Simulink +@cindex Embedding MTT models in Simulink + +It is possible to embed @strong{MTT} functions or entire @strong{MTT} +models within Simulink simulations as Sfun blocks. If the zip package +is installed on the system, the command + +@example + mtt sys sfun zip +@end example + +will create a compressed archive containing sys.mdl, which may be +embedded into a larger Simulink model. Also contained within the +archive will be four sys_sfun*.c files, + +@itemize @bullet +@item +sys_sfun.c +model state and output equations +@item +sys_sfun_ae.c +model algebraic equations +@item +sys_sfun_input.c +model inputs +@item +sys_sfun_interface.c +interface between MTT model and Simulink +@end itemize + +The last of these files must be edited to correctly map the inputs and +outputs between the @strong{MTT} and Simulink models. The two sections +to edit are clearly marked with + +@example + @code{/* Start EDIT */} + @code{....} + @code{/* End EDIT */} +@end example + +These four files should then be compiled with the Matlab ``mex'' +compiler as described in the @emph{README} file in the archive. + +If it is desired to compile the .mex files directly from within +@strong{MTT} on a machine which has the Matlab header files installed, +this may be done with the command + +@example + mtt sys sfun mexglx +@end example + +which will generated the four .mex files and the .mdl file. In this +case, the user must ensure that @emph{sys_sfun_interface.c} has been +correctly edited prior to compilation. + +Note that solution of algebraic equations within Simulink is not +possible unless the @emph{Matlab Optimisation Toolbox} is installed. @node LaTeX, , Octave, Language tools @comment node-name, next, previous, up @section LaTeX @cindex LaTeX @@ -5984,17 +6165,41 @@ @end example @node .oct file dependencies, , .octaverc, Octave setup @comment node-name, next, previous, up Additionally, it is necessary to @subsection .oct file dependencies -Successful compilation of .oct code requires that Octave has been configured -to use dynamically linked libraries and that the Octave library @code{liboctave} -and the Octave modified version of @code{libkpathsea} are available on the - system. +Successful compilation of .oct code requires that Octave has been +configured to use dynamically linked libraries and that the Octave +libraries @code{liboctave}, @code{libcruft} and @code{liboctinterp} +are available on the system. This can be acheived by compiling Octave from the source code, configured with the options @code{--enable-shared} and @code{--enable-dl}. + +A number of additional libraries and headers are also required to be +installed on a system. These include, +@itemize @bullet +@item +@emph{ncurses} and @emph{readline} + terminal control routines +@item +@emph{blas} or @emph{altas} + basic linear algebra subprograms, usually optimised for the specific processor +@item +@emph{fftw} + fast Fourier transform routines +@item +@emph{g2c} + GNU Fortran to C conversion routines +@item +@emph{kpathsea} + TeX path search routines +@end itemize + +Note that on many GNU/Linux distributions, the necessary headers are +contained in development packages which must be installed in addition +to the standard library package. Further information on configuring and installing Octave to handle dynamic libraries (DLDs) can be found in the @uref{http://www.octave.org/docs.html,Octave documentation}. Index: mttroot/mtt/lib/reduce/fix_c.r ================================================================== --- mttroot/mtt/lib/reduce/fix_c.r +++ mttroot/mtt/lib/reduce/fix_c.r @@ -7,18 +7,20 @@ ON ROUNDED$ % No integer output %% Changes x^y to pow(x,y) OPERATOR pow$ FOR ALL x,y LET x^y = pow(x,y)$ % Use the pow function - + %% Derivatives FOR ALL f,g,x LET df(pow(f,g),x)= pow(f,g-1) * (df(f,x)*g + df(g,x)*f*log(f))$ %% Special cases FOR ALL x LET pow(x,0) = 1$ FOR ALL x LET pow(x,1) = x$ + FOR ALL x,y,z LET pow(x,y)*pow(x,z) = pow(x,y+z)$ + FOR ALL x,y,z LET pow(pow(x,y),z) = pow(x,y*z)$ OPERATOR fabs$ FOR ALL x let abs(x) = fabs(x)$ ADDED mttroot/mtt/lib/rep/ident_rep.make Index: mttroot/mtt/lib/rep/ident_rep.make ================================================================== --- /dev/null +++ mttroot/mtt/lib/rep/ident_rep.make @@ -0,0 +1,101 @@ +# -*-makefile-*- +# Makefile for representation ident +# File ident_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 ident +ident_m = ${SYS}_ident.m ${SYS}_ident_numpar.m + +## Targets for the ident simulation +ident_reps = ${ident_m} ${sims} ${model_reps} ${sensitivity_reps} + +## ps output files +psfiles = ${SYS}_ident.ps ${SYS}_ident.basis.ps ${SYS}_ident.par.ps ${SYS}_ident.U.ps +figfiles = ${psfiles:%.ps=%.fig} + +all: ${SYS}_ident.${LANG} + +echo: + echo "sims: ${sims}" + echo "model_reps: ${model_reps}" + echo "sensitivity_reps: ${sensitivity_reps}" + echo "ident_reps: ${ident_reps}" + +${SYS}_ident.view: ${SYS}_ident.ps + ident_rep.sh ${SYS} view + +${psfiles}: ${SYS}_ident.fig + ident_rep.sh ${SYS} ps + +${SYS}_ident.gdat: ${SYS}_ident.dat2 + ident_rep.sh ${SYS} gdat + +${SYS}_ident.fig ${SYS}_ident.dat2: ${ident_reps} + ident_rep.sh ${SYS} dat2 + +${SYS}_ident.m: + ident_rep.sh ${SYS} m + +${SYS}_ident_numpar.m: + ident_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 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 + + ADDED mttroot/mtt/lib/rep/ident_rep.sh Index: mttroot/mtt/lib/rep/ident_rep.sh ================================================================== --- /dev/null +++ mttroot/mtt/lib/rep/ident_rep.sh @@ -0,0 +1,331 @@ +#! /bin/sh + +## ident_rep.sh +## DIY representation "ident" for mtt +# Copyright (C) 2002 by Peter J. Gawthrop + +sys=$1 +rep=ident +lang=$2 +mtt_parameters=$3 +rep_parameters=$4 + +## Some names +target=${sys}_${rep}.${lang} +def_file=${sys}_def.r +dat2_file=${sys}_ident.dat2 +dat2s_file=${sys}_idents.dat2 +ident_numpar_file=${sys}_ident_numpar.m +option_file=${sys}_ident_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 _ident.m file +make_ident() { +filename=${sys}_${rep}.m +echo Creating ${filename} + +cat > ${filename} <0 + P = P(1:n-1,:); # Loose last point + PP = []; + for j=1:m + pp = [P(:,j) P(:,j)]'; + PP = [PP pp(:)]; + endfor + + oneplot; + gset output "${sys}_ident.par.fig" + title(""); + xlabel("Time (s)"); + ylabel("Parameters"); + plot(TT,PP); + endif + + [n,m] = size(U); + if m>0 oneplot; + gset output "${sys}_ident.U.fig" + title(""); + xlabel("Time (s)"); + ylabel("U"); + [n,m] = size(U); + U = U(1:n-1,:); # Loose last point + UU = []; + for j=1:m + uu = [U(:,j) U(:,j)]'; + UU = [UU uu(:)]; + endfor + plot(TT,UU); + endif + +endfunction + +EOF +} + +make_ident_numpar() { +echo Creating ${ident_numpar_file} +cat > ${sys}_ident_numpar.m < ${fig}.ps + done + ;; + view) + pss=`ls ${sys}_ident*.ps` + echo Viewing ${pss} + for ps in ${pss}; do + gv ${ps}& + done + ;; + *) + echo Language ${lang} not supported by ${rep} representation + exit 3 +esac + + Index: mttroot/mtt/lib/rep/sfun_rep.sh ================================================================== --- mttroot/mtt/lib/rep/sfun_rep.sh +++ mttroot/mtt/lib/rep/sfun_rep.sh @@ -1377,10 +1377,10 @@ ### main program -set_debug 0 -check_for_valid_input "$*" +#set_debug 0 +#check_for_valid_input "$*" OPTS="$1" SYS="$2" REP="$3" LANG="$4" make $make_debug -f ${MTT_REP}/sfun_rep/Makefile ${2}_${3}.${4} exit 0