/[ascend]/trunk/doc/syntax.lyx
ViewVC logotype

Diff of /trunk/doc/syntax.lyx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 828 by johnpye, Tue Aug 22 02:24:05 2006 UTC revision 1384 by jpye, Fri Apr 6 16:15:11 2007 UTC
# Line 1  Line 1 
1  #LyX 1.4.1 created this file. For more info see http://www.lyx.org/  #LyX 1.4.3 created this file. For more info see http://www.lyx.org/
2  \lyxformat 245  \lyxformat 245
3  \begin_document  \begin_document
4  \begin_header  \begin_header
# Line 34  Line 34 
34  \begin_body  \begin_body
35    
36  \begin_layout Chapter  \begin_layout Chapter
37  Syntax and semantics  Syntax reference
38  \begin_inset LatexCommand \label{cha:ASCENDSyntax}  \begin_inset LatexCommand \label{cha:ASCENDSyntax}
39    
40  \end_inset  \end_inset
# Line 128  The syntax for a computer language is of Line 128  The syntax for a computer language is of
128  \end_layout  \end_layout
129    
130  \begin_deeper  \begin_deeper
131  \begin_layout Section  \begin_layout Chapter
132  Preliminaries  Preliminaries
133  \end_layout  \end_layout
134    
# Line 238  The ASCEND IV parser is very picky and p Line 238  The ASCEND IV parser is very picky and p
238   them learn how to avoid errors.   them learn how to avoid errors.
239  \end_layout  \end_layout
240    
241  \begin_layout Subsection  \begin_layout Section
242  Punctuation  Punctuation
243  \begin_inset LatexCommand \index{punctuation}  \begin_inset LatexCommand \index{punctuation}
244    
# Line 247  Punctuation Line 247  Punctuation
247    
248  \end_layout  \end_layout
249    
250    \end_deeper
251  \begin_layout Standard  \begin_layout Standard
252  This section covers both the punctuation that must be understood to read  This section covers both the punctuation that must be understood to read
253   this document and the punctuation of ASCEND code.   this document and the punctuation of ASCEND code.
254  \end_layout  \end_layout
255    
 \end_deeper  
256  \begin_layout List  \begin_layout List
257  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
258  keywords  keywords
# Line 285  Tips: Special notes and hints are someti Line 285  Tips: Special notes and hints are someti
285  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
286    
287  \bar under  \bar under
 *3*  
 \begin_inset LatexCommand \index{*3*}  
   
 \end_inset  
   
 :  
 \bar default  
  This indicates that what follows is specific to ASCEND IIIc and may disappear  
  in a future version of ASCEND IV.  
  Generally ASCEND IV will provide some equivalent functionality at 1/10th  
  of the ASCEND III price.  
 \end_layout  
   
 \begin_layout List  
 \labelwidthstring 00000.00000.00000.000  
   
 \bar under  
 *4*  
 \bar default  
   
 \begin_inset LatexCommand \index{*4*}  
   
 \end_inset  
   
  This indicates that what follows is specific to ASCEND IV and may not be  
  available in ASCEND IIIc.  
  Generally ASCEND III may provide some very klugey equivalent functionality,  
  often at a very high price in terms of increased compilation time or debugging  
  difficulty.  
 \end_layout  
   
 \begin_layout List  
 \labelwidthstring 00000.00000.00000.000  
   
 \bar under  
 *4+*  
 \bar default  
   
 \begin_inset LatexCommand \index{*4+*}  
   
 \end_inset  
   
  ASCEND IV functionality that is not fully implemented at the time of this  
  writing.  
  The precise syntax of the final implementation may vary slightly from what  
  is presented here.  
  A revision of this document will be made at the time of implementation.  
 \end_layout  
   
 \begin_layout List  
 \labelwidthstring 00000.00000.00000.000  
   
 \bar under  
288  LHS  LHS
289  \begin_inset LatexCommand \index{LHS}  \begin_inset LatexCommand \index{LHS}
290    
# Line 427  Groupings: Line 374  Groupings:
374  \InsetSpace ~  \InsetSpace ~
375    
376  \bar default  \bar default
377   In documentation optional fields   In documentation
378    \series bold
379    optional fields
380    \series default
381    
382  \begin_inset LatexCommand \index{optional fields}  \begin_inset LatexCommand \index{optional fields}
383    
384  \end_inset  \end_inset
# Line 437  Groupings: Line 388  Groupings:
388    
389  \begin_layout List  \begin_layout List
390  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
391    
392    \family typewriter
393  (*\InsetSpace ~  (*\InsetSpace ~
394  *)  *)
395    \family default
396    
397  \begin_inset LatexCommand \index{(* *)}  \begin_inset LatexCommand \index{(* *)}
398    
399  \end_inset  \end_inset
400    
401   Comment.   Comment.
402   *3* Anything inside these is a comment.   Anything inside these is a comment.
403   Comments DO NOT nest in ASCEND IIIc.   Comments can nest
  Comments may extend over many lines.  
  *4* Comments DO nest  
404  \begin_inset LatexCommand \index{nest}  \begin_inset LatexCommand \index{nest}
405    
406  \end_inset  \end_inset
407    
408   in ASCEND IV.   in ASCEND and span several lines.
409  \end_layout  \end_layout
410    
411  \begin_layout List  \begin_layout List
412  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
413    
414    \family typewriter
415  (\InsetSpace ~  (\InsetSpace ~
416  )  )
417    \family default
418    
419  \begin_inset LatexCommand \index{( )}  \begin_inset LatexCommand \index{( )}
420    
421  \end_inset  \end_inset
# Line 490  tip: The compiler can simplify relation Line 447  tip: The compiler can simplify relation
447    
448  \begin_layout List  \begin_layout List
449  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
450    
451    \family typewriter
452  {\InsetSpace ~  {\InsetSpace ~
453  }  }
454    \family default
455    
456  \begin_inset LatexCommand \index{{ }}  \begin_inset LatexCommand \index{{ }}
457    
458  \end_inset  \end_inset
# Line 511  tip: The compiler can simplify relation Line 472  tip: The compiler can simplify relation
472    
473  \begin_layout List  \begin_layout List
474  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
475    
476    \family typewriter
477  [\InsetSpace ~  [\InsetSpace ~
478  ]  ]
479    \family default
480    
481  \begin_inset LatexCommand \index{[ ]}  \begin_inset LatexCommand \index{[ ]}
482    
483  \end_inset  \end_inset
# Line 532  tip: The compiler can simplify relation Line 497  tip: The compiler can simplify relation
497    
498  \begin_layout List  \begin_layout List
499  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
500    
501    \family typewriter
502  .  .
503    \family default
504    
505  \begin_inset LatexCommand \index{.}  \begin_inset LatexCommand \index{.}
506    
507  \end_inset  \end_inset
# Line 551  tip: The compiler can simplify relation Line 520  tip: The compiler can simplify relation
520    
521  \begin_layout List  \begin_layout List
522  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
523    
524    \family typewriter
525  ..  ..
526    \family default
527    
528  \begin_inset LatexCommand \index{..}  \begin_inset LatexCommand \index{..}
529    
530  \end_inset  \end_inset
# Line 572  tip: The compiler can simplify relation Line 545  tip: The compiler can simplify relation
545    
546  \begin_layout List  \begin_layout List
547  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
548    
549    \family typewriter
550  :  :
551    \family default
552    
553  \begin_inset LatexCommand \index{:}  \begin_inset LatexCommand \index{:}
554    
555  \end_inset  \end_inset
# Line 589  tip: The compiler can simplify relation Line 566  tip: The compiler can simplify relation
566    
567  \begin_layout List  \begin_layout List
568  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
569    
570    \family typewriter
571  ::  ::
572    \family default
573    
574  \begin_inset LatexCommand \index{::}  \begin_inset LatexCommand \index{::}
575    
576  \end_inset  \end_inset
# Line 612  tip: The compiler can simplify relation Line 593  tip: The compiler can simplify relation
593    
594  \begin_layout List  \begin_layout List
595  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
596    
597    \family typewriter
598  ;  ;
599    \family default
600    
601  \begin_inset LatexCommand \index{;}  \begin_inset LatexCommand \index{;}
602    
603  \end_inset  \end_inset
# Line 627  tip: The compiler can simplify relation Line 612  tip: The compiler can simplify relation
612  \end_layout  \end_layout
613    
614  \begin_deeper  \begin_deeper
615  \begin_layout Subsection  \begin_layout Section
616  Basic Elements  Basic Elements
617  \begin_inset LatexCommand \index{basic elements}  \begin_inset LatexCommand \index{basic elements}
618    
# Line 659  value Line 644  value
644    
645  \end_inset  \end_inset
646    
647   TRUE  
648    \family sans
649    TRUE
650    \family default
651    
652  \begin_inset LatexCommand \index{TRUE}  \begin_inset LatexCommand \index{TRUE}
653    
654  \end_inset  \end_inset
655    
656   or FALSE   or
657    \family sans
658    FALSE
659    \family default
660    
661  \begin_inset LatexCommand \index{FALSE}  \begin_inset LatexCommand \index{FALSE}
662    
663  \end_inset  \end_inset
664    
665  .  .
666   Can't get much simpler, eh? In the language definition TRUE and FALSE do   Can't get much simpler, eh? In the language definition
667   not map to 1 and 0 or any other type of numeric value.  \family sans
668    TRUE
669    \family default
670     and
671    \family sans
672    FALSE
673    \family default
674     do not map to 1 and 0 or any other type of numeric value.
675   (In the implementation, of course, they do.)   (In the implementation, of course, they do.)
676  \end_layout  \end_layout
677    
# Line 704  value Line 704  value
704    
705   A signed whole number up to the maximum that can be represented by the   A signed whole number up to the maximum that can be represented by the
706   computer on which one is running ASCEND.   computer on which one is running ASCEND.
707   MAX_INTEGER  
708    \family sans
709    MAX_INTEGER
710    \family default
711    
712  \begin_inset LatexCommand \index{MAX\_INTEGER}  \begin_inset LatexCommand \index{MAX\_INTEGER}
713    
714  \end_inset  \end_inset
# Line 756  value Line 760  value
760    
761   has an optional negative sign followed by a string of digits and at most   has an optional negative sign followed by a string of digits and at most
762   one decimal point.   one decimal point.
763   The exponent is the letter e or E followed by an integer.   The exponent is the letter
764    \family typewriter
765    e
766    \family default
767     or
768    \family typewriter
769    E
770    \family default
771     followed by an integer.
772   The number must not exceed the largest the computer is able to handle.   The number must not exceed the largest the computer is able to handle.
773   There can be no blank characters in a real.   There can be no blank characters in a real.
774   MAX_REAL  
775    \family sans
776    MAX_REAL
777    \family default
778    
779  \begin_inset LatexCommand \index{MAX\_REAL}  \begin_inset LatexCommand \index{MAX\_REAL}
780    
781  \end_inset  \end_inset
# Line 806  while the following are not: Line 822  while the following are not:
822  \begin_layout LyX-Code  \begin_layout LyX-Code
823  \align block  \align block
824  1.  1.
825   2 (*contains a blank within it*)   2    (*contains a blank within it*)
826  \end_layout  \end_layout
827    
828  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 814  while the following are not: Line 830  while the following are not:
830  1.3e2.0 (*exponent has a decimal in it*)  1.3e2.0 (*exponent has a decimal in it*)
831  \end_layout  \end_layout
832    
833  \begin_layout List  \begin_layout LyX-Code
834  \labelwidthstring 00000.00000.00000.000  
835  +1.3 (* illegal unary + sign.  \family typewriter
836    +1.3    (* illegal unary + sign.
837   x = +1.3 not allowed*)   x = +1.3 not allowed*)
838  \end_layout  \end_layout
839    
# Line 846  We store all real values as double preci Line 863  We store all real values as double preci
863    
864  \end_inset  \end_inset
865    
866   numbers in the MKS   numbers in the metre-kilogram-second (MKS)
867  \begin_inset LatexCommand \index{MKS}  \begin_inset LatexCommand \index{MKS}
868    
869  \end_inset  \end_inset
# Line 871  Dimensionality Line 888  Dimensionality
888  :  :
889  \bar default  \bar default
890   Real values have dimensionality such as length/time for velocity.   Real values have dimensionality such as length/time for velocity.
891   Dimensionality is to be distinguished from the units such as ft/s.  
892    \series bold
893    Dimensionality
894    \series default
895     is to be distinguished from the
896    \series bold
897    units
898    \series default
899     such as ft/s.
900   ASCEND takes care of mapping between units   ASCEND takes care of mapping between units
901  \begin_inset LatexCommand \index{units}  \begin_inset LatexCommand \index{units}
902    
# Line 907  L Line 932  L
932    
933  \end_inset  \end_inset
934    
935  ; meter, m  ; metre, m
936  \end_layout  \end_layout
937    
938  \begin_layout List  \begin_layout List
# Line 1053  ality. Line 1078  ality.
1078    
1079  \begin_layout Standard  \begin_layout Standard
1080  Dimensions may be any combination of these symbols along with rounded parenthese  Dimensions may be any combination of these symbols along with rounded parenthese
1081  s, (), and the operators *, ^ and /.  s, (), and the operators *,
1082   Examples include M/T or M*L^2/T^2/TMP {this latter means (M*(L^2)/(T^2))/TMP}.  \family typewriter
1083   The second operand for the to the power operator, ^, must be an integer  ^
1084   value (e.g., -2 or 3) because fractional powers of dimensional numbers are  \family default
1085   physically undefined.   and
1086    \family typewriter
1087    /
1088    \family default
1089    .
1090     Examples include
1091    \family typewriter
1092    M/T
1093    \family default
1094     or
1095    \family typewriter
1096    M*L^2/T^2/TMP
1097    \family default
1098     {this latter means
1099    \family typewriter
1100    (M*(L^2)/(T^2))/TMP
1101    \family default
1102    }.
1103     The second operand for the to-the-power-of operator,
1104    \family typewriter
1105    ^
1106    \family default
1107    , must be an integer value (e.g., -2 or 3) because fractional powers of dimensiona
1108    l numbers are physically undefined
1109    \begin_inset Note Note
1110    status open
1111    
1112    \begin_layout Standard
1113    although we do seem them occasionally...
1114    \end_layout
1115    
1116    \end_inset
1117    
1118    .
1119  \end_layout  \end_layout
1120    
1121  \begin_layout Standard  \begin_layout Standard
1122  If the dimensionality for a real value is undefined, then ASCEND gives it  If the dimensionality for a real value is undefined, then ASCEND gives it
1123   a wild card dimensionality   a wildcard dimensionality
1124  \begin_inset LatexCommand \index{wild card dimensionality}  \begin_inset LatexCommand \index{wild card dimensionality}
1125    
1126  \end_inset  \end_inset
# Line 1070  If the dimensionality for a real value i Line 1128  If the dimensionality for a real value i
1128  .  .
1129   If ASCEND can later deduce its dimensionality from its use in a model definitio   If ASCEND can later deduce its dimensionality from its use in a model definitio
1130  n it will do so.  n it will do so.
1131   For example consider the real variable a, suppose a has wild card dimensionalit   For example consider the real variable
1132  y, b has dimensionality of L/T.  \family typewriter
1133    a
1134    \family default
1135    , suppose
1136    \family typewriter
1137    a
1138    \family default
1139     has wildcard dimensionality,
1140    \family typewriter
1141    b
1142    \family default
1143     has dimensionality of
1144    \family typewriter
1145    L/T
1146    \family default
1147    .
1148   Then the statement:   Then the statement:
1149  \end_layout  \end_layout
1150    
# Line 1095  equation. Line 1168  equation.
1168  \begin_layout List  \begin_layout List
1169  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
1170  \InsetSpace ~  \InsetSpace ~
1171   a + b = 3 {ft/s};  
1172    \family typewriter
1173    a + b = 3 {ft/s};
1174  \end_layout  \end_layout
1175    
1176  \begin_deeper  \begin_deeper
1177  \begin_layout Standard  \begin_layout Standard
1178  requires that a have the same dimensionality as the other two terms, namely,  requires that
1179   L/T.  \family typewriter
1180   ASCEND will assign this dimensionality to a.  a
1181    \family default
1182     have the same dimensionality as the other two terms, namely,
1183    \family typewriter
1184    L/T
1185    \family default
1186    .
1187     ASCEND will assign this dimensionality to
1188    \family typewriter
1189    a
1190    \family default
1191    .
1192   The user will be warned of dimensionally inconsistent equations.   The user will be warned of dimensionally inconsistent equations.
1193  \end_layout  \end_layout
1194    
# Line 1120  expression Line 1206  expression
1206  \end_inset  \end_inset
1207    
1208   may be composed of any combination of unit names defined by the system   may be composed of any combination of unit names defined by the system
1209   and any numerical constants combined with times (*), divide(/) and to the   and any numerical constants combined with times (
1210   power (^) operators.  \family typewriter
1211   The RHS of ^ must be an integer.  *
1212   Parentheses can be used to group subexpressions EXCEPT a divide operator  \family default
1213   may not be followed by a grouped subexpression.  ), divide(
1214    \family typewriter
1215    /
1216    \family default
1217    ) and to the power (
1218    \family typewriter
1219    ^
1220    \family default
1221    ) operators.
1222     The RHS of
1223    \family typewriter
1224    ^
1225    \family default
1226     must be an integer.
1227     Parentheses can be used to group subexpressions with the exception that
1228     a divide operator may
1229    \emph on
1230    not
1231    \emph default
1232     be followed by a grouped subexpression.
1233    
1234  \end_layout  \end_layout
1235    
1236  \begin_deeper  \begin_deeper
1237  \begin_layout Standard  \begin_layout Standard
1238  So, {kg/m/s} is fine, but {kg/(m*s)} is not.  So,
1239    \family typewriter
1240    {kg/m/s}
1241    \family default
1242     is fine, but
1243    \family typewriter
1244    {kg/(m*s)}
1245    \family default
1246     is not.
1247   Although the two expressions are mathematically equivalent, it makes the   Although the two expressions are mathematically equivalent, it makes the
1248   system programming and output formatting easier to code and faster to execute   system programming and output formatting easier to code and faster to execute
1249   if we disallow expressions of the latter sort.   if we disallow expressions of the latter sort.
1250  \end_layout  \end_layout
1251    
1252  \begin_layout Standard  \begin_layout Standard
1253  The units understood by the system are defined in the  The units understood by the system are defined in the first part of this
1254  \begin_inset Quotes eld   manual.
 \end_inset  
   
 howTo  
 \begin_inset LatexCommand \cite{key-1}  
   
 \end_inset  
   
   
 \begin_inset Quotes erd  
 \end_inset  
   
  book available on the ASCEND web site.  
1255   Note that several units defined are really values of interesting constants   Note that several units defined are really values of interesting constants
1256   in SI, e.g.   in SI, e.g.
1257   R :== 1{GAS_C} yields the correct value of the thermodynamic gas constant.  
1258    \family typewriter
1259    R :== 1{GAS_C}
1260    \family default
1261     yields the correct value of the thermodynamic gas constant.
1262   Users can define additional units.   Users can define additional units.
1263  \end_layout  \end_layout
1264    
# Line 1169  Units Line 1274  Units
1274    
1275  \end_inset  \end_inset
1276    
1277   A Unit expression unit expression must be enclosed in curly braces {}.   A Unit expression unit expression must be enclosed in curly braces
1278    \family typewriter
1279    {}
1280    \family default
1281    .
1282   When a real number is used in a mathematical expression in ASCEND, it must   When a real number is used in a mathematical expression in ASCEND, it must
1283   have a set of units expressed with it.   have a set of units expressed with it.
1284   If it does not, ASCEND assumes the number is dimensionless, which may not   If it does not, ASCEND assumes the number is dimensionless, which may not
1285   be the intent of the modeler.   be the intent of the modeler.
1286   An example is shown in the dimensionally consistent equation above where   An example is shown in the dimensionally consistent equation above where
1287   the number 3 has the units {ft/s} associated with it.   the number 3 has the units
1288    \family typewriter
1289    {ft/s}
1290    \family default
1291     associated with it.
1292    
1293  \end_layout  \end_layout
1294    
# Line 1313  values Line 1426  values
1426    
1427  \end_inset  \end_inset
1428    
1429   Set values are lists of elements, all of type integer_constant or all of   Set values are lists of elements, all of type
1430   type symbol_constant, enclosed between square brackets [].  \family sans
1431    integer_constant
1432    \family default
1433     or all of type
1434    \family sans
1435    symbol_constant
1436    \family default
1437    , enclosed between square brackets
1438    \family typewriter
1439    []
1440    \family default
1441    .
1442   The following are examples of sets:   The following are examples of sets:
1443  \end_layout  \end_layout
1444    
# Line 1367  Section\InsetSpace ~ Line 1491  Section\InsetSpace ~
1491    
1492  \begin_deeper  \begin_deeper
1493  \begin_layout Standard  \begin_layout Standard
1494  The value range 1..5 is an allowable shorthand for the integers 1, 2, 3, 4  The value range
1495   and 5 while the value range 2..n_stages (where n_stages must be of type integer_c  \family typewriter
1496  onstant) means all integers from 2 to n_stages.  1..5
1497   If n_stages is less than 2, then the third set is empty.  \family default
1498   The repeated occurrence of 1 in the fourth set is ignored.   is an allowable shorthand for the integers 1, 2, 3, 4 and 5 while the value
1499     range
1500    \family typewriter
1501    2..n_stages
1502    \family default
1503     (where
1504    \family typewriter
1505    n_stages
1506    \family default
1507     must be of type
1508    \family sans
1509    integer_constant
1510    \family default
1511    ) means all integers from 2 to
1512    \family typewriter
1513    n_stages
1514    \family default
1515    .
1516     If
1517    \family typewriter
1518    n_stages
1519    \family default
1520     is less than 2, then the third set is empty.
1521     The repeated occurrence of
1522    \family typewriter
1523    1
1524    \family default
1525     in the fourth set is ignored.
1526   The fifth set is the empty set   The fifth set is the empty set
1527  \begin_inset LatexCommand \index{empty set}  \begin_inset LatexCommand \index{empty set}
1528    
# Line 1394  We use the term set in an almost pure ma Line 1545  We use the term set in an almost pure ma
1545    
1546  \end_inset  \end_inset
1547    
1548   (CARD   (
1549    \family sans
1550    CARD
1551    \family default
1552    
1553  \begin_inset LatexCommand \index{CARD}  \begin_inset LatexCommand \index{CARD}
1554    
1555  \end_inset  \end_inset
1556    
1557  (set)).  
1558    \family typewriter
1559    (set)
1560    \family default
1561    ).
1562   Repeated elements used in defining a set are ignored.   Repeated elements used in defining a set are ignored.
1563   The elements of sets cannot themselves be sets in ASCEND; i.e., there can   The elements of sets cannot themselves be sets in ASCEND; i.e., there can
1564   be no sets of set.   be no sets of set.
# Line 1457  column[areas][processes] Line 1616  column[areas][processes]
1616    
1617  \begin_layout Standard  \begin_layout Standard
1618  where components, areas and processes are sets.  where components, areas and processes are sets.
1619   For example components could be the set of symbols ['ethylene', 'propylene'],   For example components could be the set of symbols
1620   areas the set of symbols ['feed_prep', 'prod_purification'] while processes  \family typewriter
1621   could be the set ['alcohol_manuf', 'poly_propropylene_manuf'].  ['ethylene', 'propylene']
1622   Note that the third example (column) is a list of lists (the way that ASCEND  \family default
1623   permits a multiply subscripted array).  , areas the set of symbols
1624    \family typewriter
1625    ['feed_prep', 'prod_purification']
1626    \family default
1627     while processes could be the set
1628    \family typewriter
1629    ['alcohol_manuf', 'poly_propropylene_manuf']
1630    \family default
1631    .
1632     Note that the third example (
1633    \family typewriter
1634    column
1635    \family default
1636    ) is a list of lists (the way that ASCEND permits a multiply subscripted
1637     array).
1638    
1639  \end_layout  \end_layout
1640    
# Line 1482  column['feed_prep'][alcohol_manuf'] Line 1655  column['feed_prep'][alcohol_manuf']
1655  \end_layout  \end_layout
1656    
1657  \begin_layout Standard  \begin_layout Standard
1658  provided that n_stages is 1 or larger.  provided that
1659    \family typewriter
1660    n_stages
1661    \family default
1662     is 1 or larger.
1663    
1664  \end_layout  \end_layout
1665    
# Line 1525  jagged Line 1702  jagged
1702    
1703  \end_inset  \end_inset
1704    
1705   (* 4 *) Arrays can be sparse   Arrays can be sparse
1706  \begin_inset LatexCommand \index{sparse}  \begin_inset LatexCommand \index{sparse}
1707    
1708  \end_inset  \end_inset
# Line 1594  flow[2][7], flow[2][3], flow[2][5] Line 1771  flow[2][7], flow[2][3], flow[2][5]
1771  flow[3][4], flow[3][6]  flow[3][4], flow[3][6]
1772  \end_layout  \end_layout
1773    
 \begin_layout Standard  
 Sparse arrays of models and variables are new to ASCEND IV.  
 \end_layout  
   
1774  \end_deeper  \end_deeper
1775  \begin_layout List  \begin_layout List
1776  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
# Line 1610  instances Line 1783  instances
1783  \begin_deeper  \begin_deeper
1784  \begin_layout Standard  \begin_layout Standard
1785  Each array is itself an object.  Each array is itself an object.
1786   That is, when you write "a[1..2] IS_A real;" three objects get created: a[1],   That is, when you write
1787   a[2], and a.  \family typewriter
1788   a is an array instance which has parts named [1] and [2] that are real  a[1..2] IS_A real
1789   instances.  \family default
1790    , three objects get created:
1791    \family typewriter
1792    a[1]
1793    \family default
1794    ,
1795    \family typewriter
1796    a[2]
1797    \family default
1798    , and
1799    \family typewriter
1800    a
1801    \family default
1802    .
1803     The object
1804    \family typewriter
1805    a
1806    \family default
1807     is an array instance which has parts named
1808    \family typewriter
1809    [1]
1810    \family default
1811     and
1812    \family typewriter
1813    [2]
1814    \family default
1815     that are real instances.
1816   When a parameterized model requires an array, you pass it the single item   When a parameterized model requires an array, you pass it the single item
1817   a, not the elements a[1..2].  
1818    \family typewriter
1819    a
1820    \family default
1821    , not the elements
1822    \family typewriter
1823    a[1..2]
1824    \family default
1825    .
1826  \end_layout  \end_layout
1827    
1828  \end_deeper  \end_deeper
# Line 1849  lists Line 2056  lists
2056  \end_layout  \end_layout
2057    
2058  \begin_deeper  \begin_deeper
2059  \begin_layout Subsection  \begin_layout Section
2060  Basic Concepts  Basic Concepts
2061  \end_layout  \end_layout
2062    
# Line 1926  types Line 2133  types
2133    
2134   It is possible to create an instance that does not have a corresponding   It is possible to create an instance that does not have a corresponding
2135   type definition in the library.   type definition in the library.
2136   The type of such an instance is said to be implicit.   The type of such an instance is said to be
2137   (Some people use the word anonymous  \series bold
2138    implicit
2139    \series default
2140    
2141    \begin_inset Foot
2142    status collapsed
2143    
2144    \begin_layout Standard
2145     (Some people use the word
2146    \emph on
2147    anonymous
2148    \emph default
2149    
2150  \begin_inset LatexCommand \index{type, anonymous}  \begin_inset LatexCommand \index{type, anonymous}
2151    
2152  \end_inset  \end_inset
# Line 1939  types Line 2158  types
2158    
2159  .  .
2160   However, no computable type is anonymous and the implicit type of an instance   However, no computable type is anonymous and the implicit type of an instance
2161   is theoretically computable).   is theoretically computable)
2162    \end_layout
2163    
2164    \end_inset
2165    
2166    .
2167   The simplest example of an implicit type is the type of an instance compiled   The simplest example of an implicit type is the type of an instance compiled
2168   from the built-in definition integer_constant.   from the built-in definition
2169    \family sans
2170    integer_constant
2171    \family default
2172    .
2173   For example:   For example:
2174  \end_layout  \end_layout
2175    
# Line 1959  j:== 3; Line 2187  j:== 3;
2187  \end_layout  \end_layout
2188    
2189  \begin_layout Standard  \begin_layout Standard
2190  Instances i and j, though of the same formal type, are implicit type incompatibl  Instances
2191  e because they have been assigned distinct values.  \family typewriter
2192    i
2193    \family default
2194     and
2195    \family typewriter
2196    j
2197    \family default
2198    , though of the same formal type, are implicit type incompatible because
2199     they have been assigned distinct values.
2200  \end_layout  \end_layout
2201    
2202  \begin_layout Standard  \begin_layout Standard
# Line 2000  Ambiguity is warned about loudly because Line 2236  Ambiguity is warned about loudly because
2236    
2237  \begin_layout Standard  \begin_layout Standard
2238  Assume a type, stream, and a refinement of stream, heat_stream, which adds  Assume a type, stream, and a refinement of stream, heat_stream, which adds
2239   the new variable H.   the new variable
2240    \family typewriter
2241    H
2242    \family default
2243    .
2244   Now, if we write:   Now, if we write:
2245  \end_layout  \end_layout
2246    
# Line 2026  END mixer; Line 2266  END mixer;
2266    
2267  \begin_layout Standard  \begin_layout Standard
2268  We see the parser can find the definition of H in the type heat_stream,  We see the parser can find the definition of H in the type heat_stream,
2269   so output.H is well defined.   so
2270   The author of the mixer model may intend to refine input[1] and input[2]  \family typewriter
2271    output.H
2272    \family default
2273     is well defined.
2274     The author of the mixer model may intend to refine
2275    \family typewriter
2276    input[1]
2277    \family default
2278     and
2279    \family typewriter
2280    input[2]
2281    \family default
2282   to be objects of different types, say steam_stream and electric_stream,   to be objects of different types, say steam_stream and electric_stream,
2283   where each defines an H suitable for use in the equation.   where each defines an
2284   The parser cannot read the authors mind, so it warns that input[1].H and  \family typewriter
2285   input[2].H are ambiguous in the mixer definition.  H
2286    \family default
2287     suitable for use in the equation.
2288     The parser cannot read the authors mind, so it warns that
2289    \family typewriter
2290    input[1].H
2291    \family default
2292     and
2293    \family typewriter
2294    input[2].H
2295    \family default
2296     are ambiguous in the mixer definition.
2297   The mixer model is not highly reusable except by the author, but sometimes   The mixer model is not highly reusable except by the author, but sometimes
2298   reusability is not a high priority objective.   reusability is not a high priority objective.
2299   The mixer definition is allowed, but it may cause problems in instantiation   The mixer definition is allowed, but it may cause problems in instantiation
# Line 2109  Phase 3 compiles as many logical arithme Line 2371  Phase 3 compiles as many logical arithme
2371  \end_layout  \end_layout
2372    
2373  \begin_layout Standard  \begin_layout Standard
2374  Phase 4 compiles as many conditional programming statements (WHENs) as possible.  Phase 4 compiles as many conditional programming statements (
2375   Some WHEN relations may be impossible to compile because the discrete variables  \family sans
2376  , models, or relations they depend on do not exist.  WHEN
2377    \family default
2378    s) as possible.
2379     Some
2380    \family sans
2381    WHEN
2382    \family default
2383     relations may be impossible to compile because the discrete variables,
2384     models, or relations they depend on do not exist.
2385   This is determined in a single pass.   This is determined in a single pass.
2386  \end_layout  \end_layout
2387    
2388  \begin_layout Standard  \begin_layout Standard
2389  Phase 5 executes the variable defaulting statements made in the declarative  Phase 5 executes the variable defaulting statements made in the declarative
2390   section of each model IF AND ONLY IF there are no pending statements from   section of each model
2391   phases 1-4 anywhere in the simulation.  \emph on
2392    if and only if
2393    \emph default
2394     there are no pending statements from phases 1-4 anywhere in the simulation.
2395  \end_layout  \end_layout
2396    
2397  \end_deeper  \end_deeper
# Line 2155  Structure building or modifying statemen Line 2428  Structure building or modifying statemen
2428   or merge.   or merge.
2429  \end_layout  \end_layout
2430    
2431  \begin_layout Section  \begin_layout Chapter
2432  Data Type Declarations  Data Type Declarations
2433  \begin_inset LatexCommand \index{data type declarations}  \begin_inset LatexCommand \index{data type declarations}
2434    
# Line 2171  In the spectrum of OO languages, ASCEND Line 2444  In the spectrum of OO languages, ASCEND
2444  \end_inset  \end_inset
2445    
2446  , though it is rather more a hybrid.  , though it is rather more a hybrid.
2447   We have atom and model definitions, called types, and the compiled objects   We have atom and model definitions, called
2448   themselves, called instances.  \series bold
2449    types
2450    \series default
2451    , and the compiled objects themselves, called
2452    \series bold
2453    instances
2454    \series default
2455    .
2456   ASCEND instances have a record of what type they were constructed from.   ASCEND instances have a record of what type they were constructed from.
2457  \end_layout  \end_layout
2458    
# Line 2192  qualifiers Line 2472  qualifiers
2472    
2473  \begin_layout List  \begin_layout List
2474  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
2475    
2476    \family sans
2477  UNIVERSAL  UNIVERSAL
2478    \family default
2479    
2480  \begin_inset LatexCommand \index{UNIVERSAL}  \begin_inset LatexCommand \index{UNIVERSAL}
2481    
2482  \end_inset  \end_inset
2483    
2484   Universal is an optional modifier of all ATOM, CONSTANT.   Universal is an optional modifier of all
2485   and MODEL definitions.  \family sans
2486   If UNIVERSAL precedes the definition, then ALL instances of that type will  ATOM
2487   actually refer to the first instance of the type that is created.  \family default
2488    ,
2489    \family sans
2490    CONSTANT
2491    \family default
2492     and
2493    \family sans
2494    MODEL
2495    \family default
2496     definitions.
2497     If
2498    \family sans
2499    UNIVERSAL
2500    \family default
2501     precedes the definition, then
2502    \emph on
2503    all
2504    \emph default
2505     instances of that type will actually refer to the first instance of the
2506     type that is created.
2507   This saves memory and ensures global consistency of data.   This saves memory and ensures global consistency of data.
2508    
2509  \end_layout  \end_layout
# Line 2241  Tip:\InsetSpace ~ Line 2544  Tip:\InsetSpace ~
2544  Do\InsetSpace ~  Do\InsetSpace ~
2545  not\InsetSpace ~  not\InsetSpace ~
2546  use\InsetSpace ~  use\InsetSpace ~
2547  UNIVERSAL\InsetSpace ~  
2548    \family sans
2549    UNIVERSAL
2550    \family default
2551    \InsetSpace ~
2552  variables\InsetSpace ~  variables\InsetSpace ~
2553  in\InsetSpace ~  in\InsetSpace ~
2554  relations.  relations.
# Line 2249  relations. Line 2556  relations.
2556    
2557  \begin_deeper  \begin_deeper
2558  \begin_layout Standard  \begin_layout Standard
2559  It is important to note that, because variables must store information about  It is important to note that, because
2560   which relations they occur in, it is a very bad idea to use UNIVERSAL typed  \emph on
2561   variables in relations.  variables
2562    \emph default
2563     must store information about which relations they occur in, it is a very
2564     bad idea to use
2565    \family sans
2566    UNIVERSAL
2567    \family default
2568     typed variables in relations.
2569   The construction and maintenance of the relation list becomes very expensive   The construction and maintenance of the relation list becomes very expensive
2570   for universal variables.   for universal variables.
2571   UNIVERSAL constants are fine to use, though, because there are no relation  
2572   links for constants.  \family sans
2573    UNIVERSAL
2574    \family default
2575    
2576    \emph on
2577    constants
2578    \emph default
2579     are fine to use, though, because there are no relation links for constants.
2580  \end_layout  \end_layout
2581    
2582  \begin_layout Subsection  \begin_layout Section
2583  Models  Models
2584  \end_layout  \end_layout
2585    
2586  \end_deeper  \end_deeper
2587  \begin_layout List  \begin_layout List
2588  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
2589    
2590    \family sans
2591  MODEL  MODEL
2592    \family default
2593    
2594  \begin_inset LatexCommand \index{MODEL}  \begin_inset LatexCommand \index{MODEL}
2595    
2596  \end_inset  \end_inset
# Line 2367  Models Line 2692  Models
2692    
2693  \end_inset  \end_inset
2694    
2695   (* 4 *) Parameterizing models makes them easier to understand and faster   Parameterizing models makes them easier to understand and faster for the
2696   for the system to compile.   system to compile.
2697   The syntax for a parameterized model vaguely resembles a function call   The syntax for a parameterized model vaguely resembles a function call
2698   in imperative languages, but it is NOT.   in imperative languages, but it is NOT.
2699   When constructing a reusable model, all the constants that determine the   When constructing a reusable model, all the constants that determine the
# Line 2457  END flowsheet; Line 2782  END flowsheet;
2782    
2783  \begin_layout Standard  \begin_layout Standard
2784  In this example, the column model takes the first argument, ntrays, by reference.  In this example, the column model takes the first argument, ntrays, by reference.
2785   That is, ct.ntrays is an alias for the flowsheet instance tower4size.   That is,
2786   tower4size must be compiled and assigned a value before we will attempt  \family typewriter
2787   to compile the column model instance ct.   ct.ntrays
2788   The second argument is taken by value, [c5,c6], and assigned to components,  \family default
2789   a column part that was declared with IS_A in the parameter list.   is an alias for the flowsheet instance
2790   There is only one name for this set, ct.components.  \family typewriter
2791   Note that in the flowsheet model there is no part that is a set of symbol_const  tower4size
2792  ant.  \family default
2793    .
2794    
2795    \family typewriter
2796    tower4size
2797    \family default
2798     must be compiled and assigned a value before we will attempt to compile
2799     the column model instance
2800    \family typewriter
2801    ct
2802    \family default
2803    .
2804     The second argument is taken by value,
2805    \family typewriter
2806    [c5,c6]
2807    \family default
2808    , and assigned to components, a column part that was declared with
2809    \family sans
2810    IS_A
2811    \family default
2812     in the parameter list.
2813     There is only one name for this set,
2814    \family typewriter
2815    ct.components
2816    \family default
2817    .
2818     Note that in the
2819    \family typewriter
2820    flowsheet
2821    \family default
2822     model there is no part that is a set of
2823    \family sans
2824    symbol_constant
2825    \family default
2826    .
2827    
2828  \end_layout  \end_layout
2829    
# Line 2482  The use of parameters in ASCEND modeling Line 2841  The use of parameters in ASCEND modeling
2841   which are not issues in the very earliest phase of developing novel models.   which are not issues in the very earliest phase of developing novel models.
2842  \end_layout  \end_layout
2843    
2844  \begin_layout Subsection  \begin_layout Section
2845  Sets  Sets
2846  \begin_inset LatexCommand \index{sets}  \begin_inset LatexCommand \index{sets}
2847    
# Line 2504  Arrays in ASCEND, as already discussed i Line 2863  Arrays in ASCEND, as already discussed i
2863    
2864  , are defined over sets.  , are defined over sets.
2865   A set is simply an instance with a set value.   A set is simply an instance with a set value.
2866   The elements of sets are NOT instances or sets.   The elements of sets are
2867    \emph on
2868    not
2869    \emph default
2870     instances or sets.
2871  \end_layout  \end_layout
2872    
2873  \end_deeper  \end_deeper
# Line 2535  my_symbol_set IS_A set OF symbol_constan Line 2898  my_symbol_set IS_A set OF symbol_constan
2898  \end_deeper  \end_deeper
2899  \begin_layout List  \begin_layout List
2900  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
2901    
2902    \family typewriter
2903  :==  :==
2904    \family default
2905    
2906  \begin_inset LatexCommand \index{:==}  \begin_inset LatexCommand \index{:==}
2907    
2908  \end_inset  \end_inset
# Line 2563  The RHS of such an assignment must be ei Line 2930  The RHS of such an assignment must be ei
2930  Set\InsetSpace ~  Set\InsetSpace ~
2931  Operations  Operations
2932  \bar default  \bar default
2933   UNION  
2934    \family sans
2935    UNION
2936    \family default
2937    
2938  \begin_inset LatexCommand \index{UNION}  \begin_inset LatexCommand \index{UNION}
2939    
2940  \end_inset  \end_inset
2941    
2942    
2943    \family typewriter
2944  [setlist]  [setlist]
2945  \end_layout  \end_layout
2946    
# Line 2576  Operations Line 2949  Operations
2949  A function taken over a list of sets.  A function taken over a list of sets.
2950   The result is the set that includes all the members of all the sets in   The result is the set that includes all the members of all the sets in
2951   the list.   the list.
2952   Note that the result of the UNION operation is an unordered set and the   Note that the result of the
2953   argument order to the union function does not matter.  \family sans
2954    UNION
2955    \family default
2956     operation is an unordered set and the argument order to the union function
2957     does not matter.
2958   The syntax is:   The syntax is:
2959  \end_layout  \end_layout
2960    
# Line 2589  A function taken over a list of sets. Line 2966  A function taken over a list of sets.
2966    
2967  \end_inset  \end_inset
2968    
2969   UNION[list_of_sets]  
2970    \family typewriter
2971    UNION[list_of_sets]
2972  \end_layout  \end_layout
2973    
2974  \begin_layout List  \begin_layout List
2975  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
2976  A+B\InsetSpace ~  
2977    \family typewriter
2978    A+B
2979    \family default
2980    \InsetSpace ~
2981  is\InsetSpace ~  is\InsetSpace ~
2982  shorthand\InsetSpace ~  shorthand\InsetSpace ~
2983  for UNION[A,B]  for
2984    \family typewriter
2985    UNION[A,B]
2986  \end_layout  \end_layout
2987    
2988  \begin_deeper  \begin_deeper
# Line 2614  B := [2, 4, 6, 8]; Line 2999  B := [2, 4, 6, 8];
2999  \end_layout  \end_layout
3000    
3001  \begin_layout Standard  \begin_layout Standard
3002  Then UNION[A, B] is equal to the set [1, 2, 3, 4, 5, 6, 8, 9] which equals  Then
3003   [1..6, 8, 9] which equals [[1..9] - [7]].  \family typewriter
3004    UNION[A, B]
3005    \family default
3006     is equal to the set
3007    \family typewriter
3008    [1, 2, 3, 4, 5, 6, 8, 9]
3009    \family default
3010     which equals
3011    \family typewriter
3012    [1..6, 8, 9]
3013    \family default
3014     which equals
3015    \family typewriter
3016    [[1..9] - [7]]
3017    \family default
3018    .
3019  \end_layout  \end_layout
3020    
3021  \end_deeper  \end_deeper
3022  \begin_layout List  \begin_layout List
3023  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3024    
3025    \family sans
3026  INTERSECTION  INTERSECTION
3027    \family default
3028    
3029  \begin_inset LatexCommand \index{INTERSECTION}  \begin_inset LatexCommand \index{INTERSECTION}
3030    
3031  \end_inset  \end_inset
# Line 2638  INTERSECTION Line 3042  INTERSECTION
3042    
3043  \end_inset  \end_inset
3044    
3045   Equivalent to INTERSECTION[list_of_sets].   Equivalent to
3046    \family sans
3047    INTERSECTION
3048    \family typewriter
3049    [list_of_sets]
3050    \family default
3051    .
3052  \end_layout  \end_layout
3053    
3054  \begin_layout List  \begin_layout List
3055  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3056  A*B\InsetSpace ~  
3057    \family typewriter
3058    A*B
3059    \family default
3060    \InsetSpace ~
3061  is\InsetSpace ~  is\InsetSpace ~
3062  shorthand\InsetSpace ~  shorthand\InsetSpace ~
3063  for\InsetSpace ~  for\InsetSpace ~
3064  INTERSECTION[A,B]  I
3065    \family typewriter
3066    NTERSECTION[A,B]
3067  \end_layout  \end_layout
3068    
3069  \begin_deeper  \begin_deeper
3070  \begin_layout Standard  \begin_layout Standard
3071  For the sets A and B defined just above, INTERSECTION[A, B] is the set [2].  For the sets A and B defined just above,
3072   The * shorthand for intersection is NOT recommended for use except in libraries  \family typewriter
3073   no one will look at.  INTERSECTION[A, B]
3074    \family default
3075     is the set
3076    \family typewriter
3077    [2]
3078    \family default
3079    .
3080     The
3081    \family typewriter
3082    *
3083    \family default
3084     shorthand for intersection is
3085    \emph on
3086    not
3087    \emph default
3088     recommended for use except in libraries no one will look at.
3089  \end_layout  \end_layout
3090    
3091  \end_deeper  \end_deeper
# Line 2672  difference Line 3103  difference
3103   The syntax is   The syntax is
3104  \end_layout  \end_layout
3105    
3106  \begin_layout List  \begin_deeper
3107  \labelwidthstring 00000.00000.00000.000  \begin_layout LyX-Code
3108    
3109    \family typewriter
3110    first_set
3111    \family default
3112  -  -
3113  \begin_inset LatexCommand \index{-, sets}  \begin_inset LatexCommand \index{-, sets}
3114    
3115  \end_inset  \end_inset
3116    
3117    
3118  \family typewriter  \family typewriter
3119  \InsetSpace ~   second_set
 \InsetSpace ~  
 \InsetSpace ~  
 first_set - second_set  
3120  \end_layout  \end_layout
3121    
 \begin_deeper  
3122  \begin_layout Standard  \begin_layout Standard
3123  For the sets A and B defined above, the set difference A - B is the set  For the sets
3124   [1, 3, 5, 9] while the set difference B - A is the set [4, 6, 8].  \family typewriter
3125    A
3126    \family default
3127     and
3128    \family typewriter
3129    B
3130    \family default
3131     defined above, the set difference
3132    \family typewriter
3133    A - B
3134    \family default
3135     is the set
3136    \family typewriter
3137    [1, 3, 5, 9]
3138    \family default
3139     while the set difference
3140    \family typewriter
3141    B - A
3142    \family default
3143     is the set
3144    \family typewriter
3145    [4, 6, 8]
3146    \family default
3147    .
3148  \end_layout  \end_layout
3149    
3150  \end_deeper  \end_deeper
3151  \begin_layout List  \begin_layout List
3152  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3153    
3154    \family sans
3155  CARD  CARD
3156    \family default
3157    
3158  \begin_inset LatexCommand \index{CARD}  \begin_inset LatexCommand \index{CARD}
3159    
3160  \end_inset  \end_inset
# Line 2712  CARD Line 3170  CARD
3170    
3171  \begin_layout List  \begin_layout List
3172  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3173    
3174    \family sans
3175  CHOICE  CHOICE
3176    \family default
3177    
3178  \begin_inset LatexCommand \index{CHOICE}  \begin_inset LatexCommand \index{CHOICE}
3179    
3180  \end_inset  \end_inset
3181    
3182  [set] Choose one.  [set] Choose one.
3183   The result of running the CHOICE function over a set is an arbitrary (but   The result of running the
3184   consistent: for any set instance you always get the same result) single  \family sans
3185   element of that set.  CHOICE
3186    \family default
3187     function over a set is an arbitrary (but consistent: for any set instance
3188     you always get the same result) single element of that set.
3189    
3190  \end_layout  \end_layout
3191    
3192  \begin_deeper  \begin_deeper
3193  \begin_layout Standard  \begin_layout Standard
3194  Running CHOICE[A] gives any member from the set A.  Running
3195    \family typewriter
3196    CHOICE[A]
3197    \family default
3198     gives any member from the set A.
3199   The result is a member, not a set.   The result is a member, not a set.
3200   To make the result into a set, it must be enclosed in square brackets.   To make the result into a set, it must be enclosed in square brackets.
3201   Thus [CHOICE[A]] is a set with a single element arbitrarily chosen from   Thus
3202   the set A.  \family typewriter
3203    [CHOICE[A]]
3204    \family default
3205     is a set with a single element arbitrarily chosen from the set A.
3206   Good modelers do not leave modeling decisions to the compiler; they do   Good modelers do not leave modeling decisions to the compiler; they do
3207   not use CHOICE[].   not use
3208    \family sans
3209    CHOICE
3210    \family default
3211    .
3212   We are stuck with it for historical reasons.   We are stuck with it for historical reasons.
3213  \end_layout  \end_layout
3214    
# Line 2751  A_less_one :== A - [CHOICE[A]]; Line 3227  A_less_one :== A - [CHOICE[A]];
3227  \end_deeper  \end_deeper
3228  \begin_layout List  \begin_layout List
3229  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3230    
3231    \family sans
3232  IN  IN
3233    \family default
3234    
3235  \begin_inset LatexCommand \index{IN}  \begin_inset LatexCommand \index{IN}
3236    
3237  \end_inset  \end_inset
3238    
3239   lhs IN rhs can only be well explained by examples.  
3240   IN is used in index expressions.  \family typewriter
3241   If lhs is a simple and not previously defined name, it is created as a  lhs IN rhs
3242   temporary loop index which will take on the values of the rhs set definition.  \family default
3243   If lhs is something that already exists, the result of lhs IN rhs is a   can only be well explained by examples.
3244   boolean value; stare at the model set_example below which demonstrates  
3245   both IN and SUCH_THAT.  \family sans
3246   If you still are not satisfied, you might examine [[westerbergksets]].  IN
3247    \family default
3248     is used in index expressions.
3249     If
3250    \family typewriter
3251    lhs
3252    \family default
3253     is a simple and not previously defined name, it is created as a temporary
3254     loop index which will take on the values of the rhs set definition.
3255     If lhs is something that already exists, the result of
3256    \family typewriter
3257    lhs IN rhs
3258    \family default
3259     is a boolean value; stare at the model
3260    \family typewriter
3261    set_example
3262    \family default
3263     below which demonstrates both
3264    \family sans
3265    IN
3266    \family default
3267     and
3268    \family sans
3269    SUCH_THAT
3270    \family default
3271    .
3272     If you still are not satisfied, you might examine [[westerbergksets]]
3273    \begin_inset Note Note
3274    status open
3275    
3276    \begin_layout Standard
3277    fix this reference
3278    \end_layout
3279    
3280    \end_inset
3281    
3282    .
3283  \end_layout  \end_layout
3284    
3285  \begin_layout List  \begin_layout List
3286  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3287    
3288    \family sans
3289  SUCH_THAT  SUCH_THAT
3290    \family default
3291    
3292  \begin_inset LatexCommand \index{SUCH\_THAT}  \begin_inset LatexCommand \index{SUCH\_THAT}
3293    
3294  \end_inset  \end_inset
3295    
3296  \InsetSpace ~   Set expressions can be rather clever.
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *) Set expressions can be rather clever.  
3297   We will give a detailed example from chemistry because unordered sets are   We will give a detailed example from chemistry because unordered sets are
3298   unfamiliar to most people and set arithmetic is quite powerful.   unfamiliar to most people and set arithmetic is quite powerful.
3299   In this example we see arrays of sets and sparse arrays.   In this example we see arrays of sets and sparse arrays.
# Line 2788  MODEL set_example; Line 3305  MODEL set_example;
3305  \end_layout  \end_layout
3306    
3307  \begin_layout LyX-Code  \begin_layout LyX-Code
3308  (* we define a sparse matrix of reaction    (* we define a sparse matrix of reaction
3309  \end_layout  \end_layout
3310    
3311  \begin_layout LyX-Code  \begin_layout LyX-Code
3312  coefficient information and the species       coefficient information and the species
3313  \end_layout  \end_layout
3314    
3315  \begin_layout LyX-Code  \begin_layout LyX-Code
3316  balance equations.       balance equations.
3317   *)   *)
3318  \end_layout  \end_layout
3319    
3320  \begin_layout LyX-Code  \begin_layout LyX-Code
3321  rxns IS_A set OF integer_constant;    rxns IS_A set OF integer_constant;
3322  \end_layout  \end_layout
3323    
3324  \begin_layout LyX-Code  \begin_layout LyX-Code
3325  rxns :== [1..3];    rxns :== [1..3];
3326  \end_layout  \end_layout
3327    
3328  \begin_layout LyX-Code  \begin_layout LyX-Code
3329  species IS_A set OF symbol_constant;    species IS_A set OF symbol_constant;
3330  \end_layout  \end_layout
3331    
3332  \begin_layout LyX-Code  \begin_layout LyX-Code
3333  species :== ['A','B','C','D'];    species :== ['A','B','C','D'];
3334  \end_layout  \end_layout
3335    
3336  \begin_layout LyX-Code  \begin_layout LyX-Code
3337  reactants[rxns] IS_A set OF symbol_constant; (* species    reactants[rxns] IS_A set OF symbol_constant; (* species
3338  \end_layout  \end_layout
3339    
3340  \begin_layout LyX-Code  \begin_layout LyX-Code
3341     in each rxn_j *)       in each rxn_j *)
3342  \end_layout  \end_layout
3343    
3344  \begin_layout LyX-Code  \begin_layout LyX-Code
3345  reactants[1] :== ['A','B','C'];    reactants[1] :== ['A','B','C'];
3346  \end_layout  \end_layout
3347    
3348  \begin_layout LyX-Code  \begin_layout LyX-Code
3349  reactants[2] :== ['A','C'];    reactants[2] :== ['A','C'];
3350  \end_layout  \end_layout
3351    
3352  \begin_layout LyX-Code  \begin_layout LyX-Code
3353  reactants[3] :== ['A','B','D'];    reactants[3] :== ['A','B','D'];
3354  \end_layout  \end_layout
3355    
3356  \begin_layout LyX-Code  \begin_layout LyX-Code
3357  reactions[species] IS_A set OF integer_constant;    reactions[species] IS_A set OF integer_constant;
3358  \end_layout  \end_layout
3359    
3360  \begin_layout LyX-Code  \begin_layout LyX-Code
3361  FOR i IN species CREATE (* rxns for each species i *)    FOR i IN species CREATE (* rxns for each species i *)
3362  \end_layout  \end_layout
3363    
3364  \begin_layout LyX-Code  \begin_layout LyX-Code
3365  reactions[i] :== [j IN rxns SUCH_THAT i IN reactants[j]];      reactions[i] :== [j IN rxns SUCH_THAT i IN reactants[j]];
3366  \end_layout  \end_layout
3367    
3368  \begin_layout LyX-Code  \begin_layout LyX-Code
3369  END FOR;    END FOR;
3370  \end_layout  \end_layout
3371    
3372  \begin_layout LyX-Code  \begin_layout LyX-Code
3373  (* Define sparse stoichiometric matrix.    (* Define sparse stoichiometric matrix.
3374   Values of eta_ij   Values of eta_ij
3375  \end_layout  \end_layout
3376    
3377  \begin_layout LyX-Code  \begin_layout LyX-Code
3378     set later.*)       set later.*)
3379  \end_layout  \end_layout
3380    
3381  \begin_layout LyX-Code  \begin_layout LyX-Code
3382  FOR j IN rxns CREATE    FOR j IN rxns CREATE
3383  \end_layout  \end_layout
3384    
3385  \begin_layout LyX-Code  \begin_layout LyX-Code
3386  FOR i IN reactants[j] CREATE      FOR i IN reactants[j] CREATE
3387  \end_layout  \end_layout
3388    
3389  \begin_layout LyX-Code  \begin_layout LyX-Code
3390  (* eta_ij --> mole i/mole rxn j*)        (* eta_ij --> mole i/mole rxn j*)
3391  \end_layout  \end_layout
3392    
3393  \begin_layout LyX-Code  \begin_layout LyX-Code
3394  eta[i][j] IS_A real_constant;        eta[i][j] IS_A real_constant;
3395  \end_layout  \end_layout
3396    
3397  \begin_layout LyX-Code  \begin_layout LyX-Code
3398  END FOR;      END FOR;
3399  \end_layout  \end_layout
3400    
3401  \begin_layout LyX-Code  \begin_layout LyX-Code
3402  END FOR;    END FOR;
3403  \end_layout  \end_layout
3404    
3405  \begin_layout LyX-Code  \begin_layout LyX-Code
3406  production[species] IS_A molar_rate;    production[species] IS_A molar_rate;
3407  \end_layout  \end_layout
3408    
3409  \begin_layout LyX-Code  \begin_layout LyX-Code
3410  rate[rxns] IS_A molar_rate; (* mole rxn j/time *)    rate[rxns] IS_A molar_rate; (* mole rxn j/time *)
3411  \end_layout  \end_layout
3412    
3413  \begin_layout LyX-Code  \begin_layout LyX-Code
3414  FOR i IN species CREATE    FOR i IN species CREATE
3415  \end_layout  \end_layout
3416    
3417  \begin_layout LyX-Code  \begin_layout LyX-Code
3418  gen_eqn[i]: production[i] =      gen_eqn[i]: production[i] =
3419  \end_layout  \end_layout
3420    
3421  \begin_layout LyX-Code  \begin_layout LyX-Code
3422  SUM[eta[i][j]*rate[j] | j IN reactions[i]];      SUM[eta[i][j]*rate[j] | j IN reactions[i]];
3423  \end_layout  \end_layout
3424    
3425  \begin_layout LyX-Code  \begin_layout LyX-Code
3426  END FOR;    END FOR;
3427  \end_layout  \end_layout
3428    
3429  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 2915  END set_example; Line 3432  END set_example;
3432    
3433  \begin_layout List  \begin_layout List
3434  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3435  "|  "
3436    \family typewriter
3437    |
3438    \family default
3439    
3440  \begin_inset LatexCommand \index{|}  \begin_inset LatexCommand \index{|}
3441    
3442  \end_inset  \end_inset
3443    
3444  " is shorthand for SUCH_THAT.  " is shorthand for
3445    \family sans
3446    SUCH_THAT
3447    \family default
3448    .
3449  \end_layout  \end_layout
3450    
3451  \begin_deeper  \begin_deeper
3452  \begin_layout Standard  \begin_layout Standard
3453  The array eta has only 8 elements, and we defined those elements in a set  The array
3454   for each reaction.  \family typewriter
3455   The equation needs to know about the set of reactions for a species i,  eta
3456   and that set is calculated automatically in the models first FOR/CREATE  \family default
3457     has only 8 elements, and we defined those elements in a set for each reaction.
3458     The equation needs to know about the set of reactions for a species
3459    \family typewriter
3460    i
3461    \family default
3462    , and that set is calculated automatically in the models first
3463    \family sans
3464    FOR/CREATE
3465    \family default
3466   statement.   statement.
3467    
3468  \end_layout  \end_layout
3469    
 \end_deeper  
 \begin_layout List  
 \labelwidthstring 00000.00000.00000.000  
 |  
 \end_layout  
   
 \begin_deeper  
3470  \begin_layout Standard  \begin_layout Standard
3471  The | symbol is the ASCEND III notation for SUCH_THAT.  The
3472   We noted that "|" is often read as "for all", which is different in that  \family typewriter
3473   "for all" makes one think of a FOR loop where the loop index is on the  |
3474   left of an IN operator.  \family default
3475   For example, the j loop in the SUM of gen_eqn[i] above.   symbol is the ASCEND III notation for
3476    \family sans
3477    SUCH_THAT
3478    \family default
3479    .
3480     We noted that "
3481    \family typewriter
3482    |
3483    \family default
3484    " is often read as "for all", which is different in that "for all" makes
3485     one think of a
3486    \family sans
3487    FOR
3488    \family default
3489     loop where the loop index is on the left of an
3490    \family sans
3491    IN
3492    \family default
3493     operator.
3494     For example, the
3495    \family typewriter
3496    j
3497    \family default
3498     loop in the
3499    \family sans
3500    SUM
3501    \family default
3502     of
3503    \family typewriter
3504    gen_eqn[i]
3505    \family default
3506     above.
3507    
3508  \end_layout  \end_layout
3509    
3510  \begin_layout Subsection  \begin_layout Section
3511  Constants  Constants
3512  \begin_inset LatexCommand \index{constants}  \begin_inset LatexCommand \index{constants}
3513    
# Line 2962  Constants Line 3520  Constants
3520  ASCEND supports real, integer, boolean and character string constants.  ASCEND supports real, integer, boolean and character string constants.
3521   Constants in ASCEND do not have any attributes other than their value.   Constants in ASCEND do not have any attributes other than their value.
3522   Constants are scalar quantities that can be assigned exactly once.   Constants are scalar quantities that can be assigned exactly once.
3523   Constants may only be assigned using the :== operator and the RHS expression   Constants may only be assigned using the
3524   they are assigned from must itself be constant.  \family typewriter
3525    :==
3526    \family default
3527     operator and the RHS expression they are assigned from must itself be constant.
3528   Constants do not have subparts.   Constants do not have subparts.
3529   Integer and symbol constants may be used in determining the definitions   Integer and symbol constants may be used in determining the definitions
3530   of sets.   of sets.
# Line 2986  Sets could be considered constant becaus Line 3547  Sets could be considered constant becaus
3547  \end_deeper  \end_deeper
3548  \begin_layout List  \begin_layout List
3549  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3550    
3551    \family sans
3552  real_constant  real_constant
3553    \family default
3554    
3555  \begin_inset LatexCommand \index{real\_constant}  \begin_inset LatexCommand \index{real\_constant}
3556    
3557  \end_inset  \end_inset
# Line 3026  CONSTANT hydrogen_weight Line 3591  CONSTANT hydrogen_weight
3591  \end_deeper  \end_deeper
3592  \begin_layout List  \begin_layout List
3593  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3594    
3595    \family sans
3596  integer_constant  integer_constant
3597    \family default
3598    
3599  \begin_inset LatexCommand \index{integer\_constant}  \begin_inset LatexCommand \index{integer\_constant}
3600    
3601  \end_inset  \end_inset
# Line 3034  integer_constant Line 3603  integer_constant
3603   Integer number.   Integer number.
3604   Principally used in determining model structure.   Principally used in determining model structure.
3605   If appearing in equations, integers are evaluated as dimensionless reals.   If appearing in equations, integers are evaluated as dimensionless reals.
3606   Typical use is inside a MODEL definition and looks like:   Typical use is inside a
3607    \family sans
3608    MODEL
3609    \family default
3610     definition and looks like:
3611  \end_layout  \end_layout
3612    
3613  \begin_deeper  \begin_deeper
# Line 3053  tray[1..n_trays] IS_A vl_equilibrium_tra Line 3626  tray[1..n_trays] IS_A vl_equilibrium_tra
3626  \end_deeper  \end_deeper
3627  \begin_layout List  \begin_layout List
3628  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3629    
3630    \family sans
3631  symbol_constant  symbol_constant
3632    \family default
3633    
3634  \begin_inset LatexCommand \index{symbol\_constant}  \begin_inset LatexCommand \index{symbol\_constant}
3635    
3636  \end_inset  \end_inset
# Line 3064  symbol_constant Line 3641  symbol_constant
3641    
3642  \begin_layout List  \begin_layout List
3643  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3644    
3645    \family sans
3646  boolean_constant  boolean_constant
3647    \family default
3648    
3649  \begin_inset LatexCommand \index{boolean\_constant}  \begin_inset LatexCommand \index{boolean\_constant}
3650    
3651  \end_inset  \end_inset
# Line 3113  LHS_list :== RHS; Line 3694  LHS_list :== RHS;
3694  Here it is required that the one or more items in the LHS be of the same  Here it is required that the one or more items in the LHS be of the same
3695   constant type and that RHS is a single-valued expression made up of values,   constant type and that RHS is a single-valued expression made up of values,
3696   operators, and other constants.   operators, and other constants.
3697   The :== is used to make clear to both the user and the system what scalar   The
3698   objects are constants.  \family typewriter
3699    :==
3700    \family default
3701     is used to make clear to both the user and the system what scalar objects
3702     are constants.
3703    
3704  \end_layout  \end_layout
3705    
3706  \begin_layout Subsection  \begin_layout Section
3707  Variables  Variables
3708  \begin_inset LatexCommand \index{variables}  \begin_inset LatexCommand \index{variables}
3709    
# Line 3131  Variables Line 3716  Variables
3716  There are four built-in types which may be used to construct variables:  There are four built-in types which may be used to construct variables:
3717   symbol, boolean, integer, and real.   symbol, boolean, integer, and real.
3718   At this time symbol types have special restrictions.   At this time symbol types have special restrictions.
3719   Refinements of these variable base types are defined with the ATOM statement.   Refinements of these variable base types are defined with the
3720    \family sans
3721    ATOM
3722    \family default
3723     statement.
3724   Atom types may declare attribute fields with types real, integer, boolean,   Atom types may declare attribute fields with types real, integer, boolean,
3725   symbol, and set.   symbol, and set.
3726   These attributes are NOT independent objects and therefore cannot be refined,   These attributes are
3727   merged, or put in a refinement clique (ARE_ALIKEd).  \emph on
3728    not
3729    \emph default
3730     independent objects and therefore cannot be refined, merged, or put in
3731     a refinement clique (
3732    \family sans
3733    ARE_ALIKE
3734    \family default
3735    d).
3736  \end_layout  \end_layout
3737    
3738  \end_deeper  \end_deeper
3739  \begin_layout List  \begin_layout List
3740  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3741    
3742    \family sans
3743  ATOM  ATOM
3744    \family default
3745    
3746  \begin_inset LatexCommand \index{ATOM}  \begin_inset LatexCommand \index{ATOM}
3747    
3748  \end_inset  \end_inset
# Line 3195  atom_type_name Line 3796  atom_type_name
3796  \end_deeper  \end_deeper
3797  \begin_layout List  \begin_layout List
3798  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3799    
3800    \family sans
3801  DEFAULT  DEFAULT
3802    \family default
3803    
3804  \begin_inset LatexCommand \index{DEFAULT}  \begin_inset LatexCommand \index{DEFAULT}
3805    
3806  \end_inset  \end_inset
3807    
3808  ,\InsetSpace ~  ,
3809    \family sans
3810    \InsetSpace ~
3811  DIMENSION  DIMENSION
3812    \family default
3813    
3814  \begin_inset LatexCommand \index{DIMENSION}  \begin_inset LatexCommand \index{DIMENSION}
3815    
3816  \end_inset  \end_inset
3817    
3818  ,\InsetSpace ~  ,\InsetSpace ~
3819  and\InsetSpace ~  and\InsetSpace ~
3820    
3821    \family sans
3822  DIMENSIONLESS  DIMENSIONLESS
3823    \family default
3824    
3825  \begin_inset LatexCommand \index{DIMENSIONLESS}  \begin_inset LatexCommand \index{DIMENSIONLESS}
3826    
3827  \end_inset  \end_inset
# Line 3218  DIMENSIONLESS Line 3831  DIMENSIONLESS
3831    
3832  \begin_deeper  \begin_deeper
3833  \begin_layout Standard  \begin_layout Standard
3834  The DIMENSION attribute is for variables whose base type is real.  The
3835    \family sans
3836    DIMENSION
3837    \family default
3838     attribute is for variables whose base type is real.
3839   It is an optional field.   It is an optional field.
3840   If not defined for any atom with base type real, the dimensions will be   If not defined for any atom with base type real, the dimensions will be
3841   left as undefined.   left as undefined.
# Line 3232  The DIMENSION attribute is for variables Line 3849  The DIMENSION attribute is for variables
3849  \end_deeper  \end_deeper
3850  \begin_layout List  \begin_layout List
3851  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
3852    
3853    \family sans
3854  solver_var  solver_var
3855    \family default
3856    
3857  \begin_inset LatexCommand \index{solver\_var}  \begin_inset LatexCommand \index{solver\_var}
3858    
3859  \end_inset  \end_inset
3860    
3861   is a special case of ATOM and we will say much more about it in Section   is a special case of
3862    \family sans
3863    ATOM
3864    \family default
3865     and we will say much more about it in Section
3866  \begin_inset LatexCommand \vref{sub:x.6.1Variables-for-solvers}  \begin_inset LatexCommand \vref{sub:x.6.1Variables-for-solvers}
3867    
3868  \end_inset  \end_inset
# Line 3377  symbol Line 4001  symbol
4001    
4002  \end_inset  \end_inset
4003    
4004   * 4 * Symbol valued variable quantity.   Symbol valued variable quantity.
4005   We do not yet have operators for building symbols out of other symbols.   We do not yet have operators for building symbols out of other symbols.
4006  \end_layout  \end_layout
4007    
# Line 3451  We use an ordinary equals (=) when defin Line 4075  We use an ordinary equals (=) when defin
4075  \end_deeper  \end_deeper
4076  \begin_layout List  \begin_layout List
4077  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
4078    \begin_inset Note Note
4079    status open
4080    
4081    \begin_layout List
4082    \labelwidthstring 00000.00000.00000.000
4083    
4084  \bar under  \bar under
4085  Tabular\InsetSpace ~  Tabular\InsetSpace ~
# Line 3473  assignments Line 4102  assignments
4102   Here are some examples:   Here are some examples:
4103  \end_layout  \end_layout
4104    
 \begin_deeper  
4105  \begin_layout LyX-Code  \begin_layout LyX-Code
4106  DATA ~(* ~4+ ~*)  DATA ~(* ~4+ ~*)
4107  \end_layout  \end_layout
4108    
4109    \begin_deeper
4110  \begin_layout LyX-Code  \begin_layout LyX-Code
4111  MODEL tabular_ex;  MODEL tabular_ex;
4112  \end_layout  \end_layout
# Line 3605  For sparse arrays of variables or consta Line 4234  For sparse arrays of variables or consta
4234   along with the values to be assigned.   along with the values to be assigned.
4235  \end_layout  \end_layout
4236    
4237  \begin_layout Subsection  \end_inset
4238    
4239    
4240    \end_layout
4241    
4242    \begin_deeper
4243    \begin_layout Standard
4244    
4245    \end_layout
4246    
4247    \begin_layout Section
4248  Relations  Relations
4249  \begin_inset LatexCommand \index{relations}  \begin_inset LatexCommand \index{relations}
4250    
# Line 3654  Each additive term in a mathematical exp Line 4293  Each additive term in a mathematical exp
4293  \begin_layout Standard  \begin_layout Standard
4294  An expression may contain an index variable as a part of the calculation  An expression may contain an index variable as a part of the calculation
4295   if that index variable is over a set whose elements are of type integer.   if that index variable is over a set whose elements are of type integer.
4296   (See the FOR/CREATE and FOR/DO statements below.) An example is:   (See the
4297    \family sans
4298    FOR/CREATE
4299    \family default
4300     and
4301    \family sans
4302    FOR/DO
4303    \family default
4304    statements below.) An example is:
4305  \end_layout  \end_layout
4306    
4307  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 3716  objective_type LHS Line 4363  objective_type LHS
4363  \end_layout  \end_layout
4364    
4365  \begin_layout Standard  \begin_layout Standard
4366  Objective_type is either MAXIMIZE or MINIMIZE.  Objective_type is either
4367    \family sans
4368    MAXIMIZE
4369    \family default
4370     or
4371    \family sans
4372    MINIMIZE
4373    \family default
4374    .
4375   RHS and LHS must be one or more variables, constants, and operators in   RHS and LHS must be one or more variables, constants, and operators in
4376   a normal algebraic expression.   a normal algebraic expression.
4377   The operators allowed are defined below and in Section   The operators allowed are defined below and in Section
# Line 3727  Objective_type is either MAXIMIZE or MIN Line 4382  Objective_type is either MAXIMIZE or MIN
4382  .  .
4383   Variable integers, booleans, and symbols are not allowed as operands in   Variable integers, booleans, and symbols are not allowed as operands in
4384   numerical relations, nor are boolean constants.   numerical relations, nor are boolean constants.
4385   Integer indices declared in FOR/CREATE loops are allowed in relations,   Integer indices declared in
4386   and they are treated as integer constants.  \family sans
4387    FOR/CREATE
4388    \family default
4389     loops are allowed in relations, and they are treated as integer constants.
4390  \end_layout  \end_layout
4391    
4392  \end_deeper  \end_deeper
# Line 3806  Equations must be dimensionally correct. Line 4464  Equations must be dimensionally correct.
4464  \end_deeper  \end_deeper
4465  \begin_layout List  \begin_layout List
4466  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
4467    
4468    \family sans
4469  MAXIMIZE  MAXIMIZE
4470    \family default
4471    
4472  \begin_inset LatexCommand \index{MAXIMIZE}  \begin_inset LatexCommand \index{MAXIMIZE}
4473    
4474  \end_inset  \end_inset
4475    
4476  ,\InsetSpace ~  ,\InsetSpace ~
4477    
4478    \family sans
4479  MINIMIZE  MINIMIZE
4480    \family default
4481    
4482  \begin_inset LatexCommand \index{MINIMIZE}  \begin_inset LatexCommand \index{MINIMIZE}
4483    
4484  \end_inset  \end_inset
# Line 3945  Operators Line 4611  Operators
4611    
4612  \begin_layout List  \begin_layout List
4613  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
4614    
4615    \family typewriter
4616  ordered_function  ordered_function
4617  \begin_inset LatexCommand \index{ordered\_function}  \begin_inset LatexCommand \index{ordered\_function}
4618    
4619  \end_inset  \end_inset
4620    
4621  () unary real valued functions.  ()
4622    \family default
4623     unary real valued functions.
4624   The unary real functions we support are given in section Section   The unary real functions we support are given in section Section
4625  \begin_inset LatexCommand \vref{sub:x.6.3Single-operand-real}  \begin_inset LatexCommand \vref{sub:x.6.3Single-operand-real}
4626    
# Line 3972  terms: Line 4642  terms:
4642    
4643  \begin_layout List  \begin_layout List
4644  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
4645    
4646    \family sans
4647  SUM  SUM
4648    \family default
4649    
4650  \begin_inset LatexCommand \index{SUM}  \begin_inset LatexCommand \index{SUM}
4651    
4652  \end_inset  \end_inset
4653    
4654    
4655    \family typewriter
4656  [term\InsetSpace ~  [term\InsetSpace ~
4657  set] Add all expressions in the functions list.  set]
4658    \family default
4659     Add all expressions in the functions list.
4660  \end_layout  \end_layout
4661    
4662  \begin_deeper  \begin_deeper
4663  \begin_layout Standard  \begin_layout Standard
4664  For the SUM, the base type real items can be arbitrary arithmetic expressions.  For the
4665    \family sans
4666    SUM
4667    \family default
4668    , the base type real items can be arbitrary arithmetic expressions.
4669   The resulting items must all be dimensionally compatible.   The resulting items must all be dimensionally compatible.
4670  \end_layout  \end_layout
4671    
# Line 4009  SUM[y[i] | i IN components] = 1; Line 4691  SUM[y[i] | i IN components] = 1;
4691    
4692  \bar under  \bar under
4693  Empty\InsetSpace ~  Empty\InsetSpace ~
4694  SUM[]\InsetSpace ~  
4695    \family sans
4696    SUM
4697    \family default
4698    \InsetSpace ~
4699  yields\InsetSpace ~  yields\InsetSpace ~
4700  wild\InsetSpace ~  wildcard\InsetSpace ~
4701  0.  
4702    \family typewriter
4703    0
4704    \family default
4705    .
4706  \end_layout  \end_layout
4707    
4708  \begin_deeper  \begin_deeper
4709  \begin_layout Standard  \begin_layout Standard
4710  When a SUM is compiled over a list which is empty it generates a wild dimensione  When a
4711  d 0.  \family sans
4712    SUM
4713    \family default
4714     is compiled over a list which is empty it generates a wildcard-dimensioned
4715    
4716    \family typewriter
4717    0
4718    \family default
4719    .
4720   This will sometimes cause our dimension checking routines to fail.   This will sometimes cause our dimension checking routines to fail.
4721   The best way to prevent this is to make sure the SUM never actually encounters   The best way to prevent this is to make sure the SUM never actually encounters
4722   an empty list.   an empty list.
# Line 4030  SUM[Q[possibly_empty_set], 0{watt}]; Line 4728  SUM[Q[possibly_empty_set], 0{watt}];
4728  \end_layout  \end_layout
4729    
4730  \begin_layout Standard  \begin_layout Standard
4731  In the above, the variables Q[i] (if they exist) have the dimensionality  In the above, the variables
4732   associated with an energy rate.  \family typewriter
4733   When the set is empty, the 0 is the only term in the SUM and establishes  Q[i]
4734   the dimensionality of the result.  \family default
4735   When the set is NOT empty the compiler will simplify away the trailing   (if they exist) have the dimensionality associated with an energy rate.
4736   0 in the sum.   When the set is empty, the
4737    \family typewriter
4738    0
4739    \family default
4740     is the only term in the
4741    \family sans
4742    SUM
4743    \family default
4744     and establishes the dimensionality of the result.
4745     When the set is
4746    \emph on
4747    not
4748    \emph default
4749     empty the compiler will simplify away the trailing
4750    \family typewriter
4751    0
4752    \family default
4753     in the sum.
4754  \end_layout  \end_layout
4755    
4756  \end_deeper  \end_deeper
# Line 4065  functions: Line 4780  functions:
4780  (Not implemented - only under confused consideration at this time.) The following  (Not implemented - only under confused consideration at this time.) The following
4781   functions only work in methods as they are not smooth function and would   functions only work in methods as they are not smooth function and would
4782   destroy a Newton-based solution algorithm if used in defining a model equation:   destroy a Newton-based solution algorithm if used in defining a model equation:
4783    \begin_inset Note Note
4784    status open
4785    
4786    \begin_layout Standard
4787    Clarification required
4788    \end_layout
4789    
4790    \end_inset
4791    
4792    
4793  \end_layout  \end_layout
4794    
4795  \end_deeper  \end_deeper
# Line 4091  set] (* 4+ *) minimum value on list of a Line 4816  set] (* 4+ *) minimum value on list of a
4816  \end_layout  \end_layout
4817    
4818  \begin_deeper  \begin_deeper
4819  \begin_layout Subsection  \begin_layout Standard
4820    \begin_inset Note Note
4821    status open
4822    
4823    \begin_layout Section
4824  Derivatives  Derivatives
4825  \begin_inset LatexCommand \index{derivatives}  \begin_inset LatexCommand \index{derivatives}
4826    
4827  \end_inset  \end_inset
4828    
4829   in relations (* 4+ *)   in relations
4830  \end_layout  \end_layout
4831    
4832  \begin_layout Standard  \begin_layout Standard
# Line 4110  Simply put, we would like to have genera Line 4839  Simply put, we would like to have genera
4839   work.   work.
4840  \end_layout  \end_layout
4841    
4842  \begin_layout Subsection  \end_inset
4843    
4844    
4845    \end_layout
4846    
4847    \begin_layout Section
4848  External relations  External relations
4849  \begin_inset LatexCommand \index{relations, external}  \begin_inset LatexCommand \index{relations, external}
4850    
# Line 4126  External relations Line 4860  External relations
4860    
4861  \begin_layout Standard  \begin_layout Standard
4862  We cannot document these at the present time.  We cannot document these at the present time.
4863   The only reference for them is [[abbottthesis]].   Some details are available in Kirk Abbott's thesis
4864    \begin_inset LatexCommand \cite{Abbott1996a}
4865    
4866    \end_inset
4867    
4868    , or check the wiki at
4869    \family sans
4870    http://ascendwiki.cheme.cmu.edu/
4871  \end_layout  \end_layout
4872    
4873  \begin_layout Subsection  \begin_layout Section
4874  Conditional relations  Conditional modelling
4875  \begin_inset LatexCommand \index{relations, conditional}  \begin_inset LatexCommand \index{relations, conditional}
4876    
4877  \end_inset  \end_inset
# Line 4141  Conditional relations Line 4881  Conditional relations
4881    
4882  \end_inset  \end_inset
4883    
4884   (* 4 *)  
4885    \end_layout
4886    
4887    \begin_layout Subsection
4888    Conditional relations
4889  \end_layout  \end_layout
4890    
4891  \begin_layout Standard  \begin_layout Standard
# Line 4163  END CONDITIONAL; Line 4907  END CONDITIONAL;
4907  \end_layout  \end_layout
4908    
4909  \begin_layout Standard  \begin_layout Standard
4910  A CONDITIONAL statement can appear anywhere in the declarative portion of  A
4911   the model and it contains only relations to be used as boundaries.  \family sans
4912    CONDITIONAL
4913    \family default
4914     statement can appear anywhere in the declarative portion of the model and
4915     it contains only relations to be used as boundaries.
4916   That is, these real arithmetic equations are used in expressing logical   That is, these real arithmetic equations are used in expressing logical
4917   condition equations via the SATISFIED operator.   condition equations via the
4918    \family sans
4919    SATISFIED
4920    \family default
4921     operator.
4922  \end_layout  \end_layout
4923    
4924  \begin_layout Subsection  \begin_layout Subsection
4925  Logical relations (* 4 *)  Logical relations
4926  \end_layout  \end_layout
4927    
4928  \end_deeper  \end_deeper
# Line 4191  expression Line 4943  expression
4943    
4944  \end_inset  \end_inset
4945    
4946   An expression whose value is TRUE or FALSE is a logical expression.   An expression whose value is
4947    \family sans
4948    TRUE
4949    \family default
4950     or
4951    \family sans
4952    FALSE
4953    \family default
4954     is a logical expression.
4955   Such expressions may contain boolean variables.   Such expressions may contain boolean variables.
4956   If A,B, and laminar are boolean, then the following is a logical expression:   If A,B, and laminar are boolean, then the following is a logical expression:
4957  \end_layout  \end_layout
# Line 4211  A OR (B AND laminar) Line 4971  A OR (B AND laminar)
4971    
4972  \begin_layout Standard  \begin_layout Standard
4973  The plus operator acts like an OR among the terms while the times operator  The plus operator acts like an OR among the terms while the times operator
4974   acts like an AND.   acts like an
4975   Think of TRUE being equal to 1 and FALSE being equal to 0 with the 1+1=0+1=1+0=  \family sans
4976  1, 0+0=0, 1*1=1 and 0*1=1*0=0*0=0.  AND
4977   If A = FALSE, B=TRUE and laminar is TRUE, this expression has the value  \family default
4978    .
4979     Think of
4980    \family sans
4981    TRUE
4982    \family default
4983     being equal to 1 and
4984    \family sans
4985    FALSE
4986    \family default
4987     being equal to 0 with the 1+1=0+1=1+0=1, 0+0=0, 1*1=1 and 0*1=1*0=0*0=0.
4988     If A =
4989    \family sans
4990    FALSE
4991    \family default
4992    , B=
4993    \family sans
4994    TRUE
4995    \family default
4996     and laminar is
4997    \family sans
4998    TRUE
4999    \family default
5000    , this expression has the value
5001  \end_layout  \end_layout
5002    
5003  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 4231  or in terms of ones and zeros Line 5014  or in terms of ones and zeros
5014    
5015  \begin_layout Standard  \begin_layout Standard
5016  Logical relations are then made by putting together logical expressions  Logical relations are then made by putting together logical expressions
5017   with the boolean relational operators == and !=.   with the boolean relational operators
5018    \family typewriter
5019    ==
5020    \family default
5021     and
5022    \family typewriter
5023    !=
5024    \family default
5025    .
5026   Since we have no logical solving engine we have not pushed the implementation   Since we have no logical solving engine we have not pushed the implementation
5027   of logical relations very hard yet.   of logical relations very hard yet.
5028  \end_layout  \end_layout
5029    
5030  \begin_layout Subsection  \begin_layout Section
5031    
5032    \family sans
5033  NOTES  NOTES
5034    \family default
5035    
5036  \begin_inset LatexCommand \index{NOTES}  \begin_inset LatexCommand \index{NOTES}
5037    
5038  \end_inset  \end_inset
5039    
  (* 4 *)  
 \end_layout  
5040    
 \begin_layout Standard  
 Within a MODEL (or METHOD) definition annotations (hereafter called notes)  
  may be made on a part declared in the MODEL, or on the MODEL (or METHOD)  
  itself.  
  Short notes may be made when defining or refining an object by enclosing  
  the note in "double quotes." Longer notes may be made in a block statement.  
5041  \end_layout  \end_layout
5042    
5043  \begin_layout Standard  \begin_layout Standard
5044  Each note is entered in a database with the name of the file, name of MODEL,  Within a
5045   name of METHOD if applicable, and the language (a kind of keyword) in which  \family sans
5046   the note is written.  MODEL
5047   Users, user interfaces, and other programs may query this database for  \family default
5048     (or
5049    \family sans
5050    METHOD
5051    \family default
5052    ) definition annotations (hereafter called notes) may be made on a part
5053     declared in the
5054    \family sans
5055    MODEL
5056    \family default
5057    , or on the
5058    \family sans
5059    MODEL
5060    \family default
5061     (or
5062    \family sans
5063    METHOD
5064    \family default
5065    ) itself.
5066     Short notes may be made when defining or refining an object by enclosing
5067     the note in double quotes (
5068    \family typewriter
5069    "
5070    \family default
5071    ).
5072     Longer notes may be made in a block statement.
5073    \end_layout
5074    
5075    \begin_layout Standard
5076    Each note is entered in a database with the name of the file, name of
5077    \family sans
5078    MODEL
5079    \family default
5080    , name of
5081    \family sans
5082    METHOD
5083    \family default
5084     if applicable, and the language (a kind of keyword) in which the note is
5085     written.
5086     Users, user interfaces, and other programs may query this database for
5087   information on models and simulations.   information on models and simulations.
5088   The block notes may include code fragments in other languages that you   The block notes may include code fragments in other languages that you
5089   wish to embed in your MODEL or any other kind of text.   wish to embed in your
5090    \family sans
5091    MODEL
5092    \family default
5093     or any other kind of text.
5094  \end_layout  \end_layout
5095    
5096  \begin_layout Standard  \begin_layout Standard
# Line 4275  L[1..10] "L[i] is the length of the ith Line 5105  L[1..10] "L[i] is the length of the ith
5105  \end_layout  \end_layout
5106    
5107  \begin_layout LyX-Code  \begin_layout LyX-Code
5108  IS_A distance;           IS_A distance;
5109  \end_layout  \end_layout
5110    
5111  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 4287  thetaJ "angle between horizon and jupite Line 5117  thetaJ "angle between horizon and jupite
5117  \end_layout  \end_layout
5118    
5119  \begin_layout LyX-Code  \begin_layout LyX-Code
5120  IS_A angle;           IS_A angle;
5121  \end_layout  \end_layout
5122    
5123  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 4295  car.tires "using car in Minnesota, you b Line 5125  car.tires "using car in Minnesota, you b
5125  \end_layout  \end_layout
5126    
5127  \begin_layout LyX-Code  \begin_layout LyX-Code
5128  IS_REFINED_TO snow_tire;           IS_REFINED_TO snow_tire;
5129  \end_layout  \end_layout
5130    
5131  \begin_layout Standard  \begin_layout Standard
5132  In the second IS_A statement concerning two angles, we see that a short  In the second
5133   note in double quotes goes with the name immediately to its left.  \family sans
5134    IS_A
5135    \family default
5136     statement concerning two angles, we see that a short note in double quotes
5137     goes with the name immediately to its left.
5138   We also see that the note comes before the comma if the name is part of   We also see that the note comes before the comma if the name is part of
5139   a list of names.   a list of names.
5140   In the third statement, we see that not only simple names but also qualified   In the third statement, we see that not only simple names but also qualified
# Line 4310  In the second IS_A statement concerning Line 5144  In the second IS_A statement concerning
5144    
5145  \begin_layout Standard  \begin_layout Standard
5146  Longer notes are made in block statements of the form below.  Longer notes are made in block statements of the form below.
5147   These blocks can appear in a METHOD or MODEL.   These blocks can appear in a
5148    \family sans
5149    METHOD
5150    \family default
5151     or
5152    \family sans
5153    MODEL
5154    \family default
5155    .
5156   These blocks can also be written separately before or after a model as   These blocks can also be written separately before or after a model as
5157   we shall see.   we shall see.
5158  \end_layout  \end_layout
# Line 4320  NOTES Line 5162  NOTES
5162  \end_layout  \end_layout
5163    
5164  \begin_layout LyX-Code  \begin_layout LyX-Code
5165  'language or keyword' list.of, names {    'language or keyword' list.of, names {
5166  \end_layout  \end_layout
5167    
5168  \begin_layout LyX-Code  \begin_layout LyX-Code
5169  free-form block of text to store in the      free-form block of text to store in the
5170  \end_layout  \end_layout
5171    
5172  \begin_layout LyX-Code  \begin_layout LyX-Code
5173  database exactly as written.      database exactly as written.
5174  \end_layout  \end_layout
5175    
5176  \begin_layout LyX-Code  \begin_layout LyX-Code
5177  }    }
5178  \end_layout  \end_layout
5179    
5180  \begin_layout LyX-Code  \begin_layout LyX-Code
5181  some.other.name {    some.other.name {
5182  \end_layout  \end_layout
5183    
5184  \begin_layout LyX-Code  \begin_layout LyX-Code
5185  this note has the same language or keyword as      this note has the same language or keyword as
5186  \end_layout  \end_layout
5187    
5188  \begin_layout LyX-Code  \begin_layout LyX-Code
5189  the first since we didn't define a new keyword      the first since we didn't define a new keyword
5190  \end_layout  \end_layout
5191    
5192  \begin_layout LyX-Code  \begin_layout LyX-Code
5193  in single quotes before the name list.      in single quotes before the name list.
5194  \end_layout  \end_layout
5195    
5196  \begin_layout LyX-Code  \begin_layout LyX-Code
5197  }    }
5198  \end_layout  \end_layout
5199    
5200  \begin_layout LyX-Code  \begin_layout LyX-Code
5201  'another language' some.other.name {    'another language' some.other.name {
5202  \end_layout  \end_layout
5203    
5204  \begin_layout LyX-Code  \begin_layout LyX-Code
5205  en espanol      en espanol
5206  \end_layout  \end_layout
5207    
5208  \begin_layout LyX-Code  \begin_layout LyX-Code
5209  }    }
5210  \end_layout  \end_layout
5211    
5212  \begin_layout LyX-Code  \begin_layout LyX-Code
5213  'fortran' SELF {    'fortran' SELF {
5214  \end_layout  \end_layout
5215    
5216  \begin_layout LyX-Code  \begin_layout LyX-Code
5217  This model should be solved with subroutine      This model should be solved with subroutine
5218  \end_layout  \end_layout
5219    
5220  \begin_layout LyX-Code  \begin_layout LyX-Code
5221  LSODE.      LSODE.
5222  \end_layout  \end_layout
5223    
5224  \begin_layout LyX-Code  \begin_layout LyX-Code
5225  This note demonstrates that "SELF" can be used      This note demonstrates that "SELF" can be used
5226  \end_layout  \end_layout
5227    
5228  \begin_layout LyX-Code  \begin_layout LyX-Code
5229  to annotate the entire model instead of a      to annotate the entire model instead of a
5230  \end_layout  \end_layout
5231    
5232  \begin_layout LyX-Code  \begin_layout LyX-Code
5233  named part.      named part.
5234  \end_layout  \end_layout
5235    
5236  \begin_layout LyX-Code  \begin_layout LyX-Code
5237  }    }
5238  \end_layout  \end_layout
5239    
5240  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 4409  ADD NOTES IN name_of_model; Line 5251  ADD NOTES IN name_of_model;
5251  \end_layout  \end_layout
5252    
5253  \begin_layout LyX-Code  \begin_layout LyX-Code
5254  'language or keyword' list.of, names {    'language or keyword' list.of, names {
5255  \end_layout  \end_layout
5256    
5257  \begin_layout LyX-Code  \begin_layout LyX-Code
5258  more text      more text
5259  \end_layout  \end_layout
5260    
5261  \begin_layout LyX-Code  \begin_layout LyX-Code
5262  } (* more than one note may be made in this    } (* more than one note may be made in this
5263  \end_layout  \end_layout
5264    
5265  \begin_layout LyX-Code  \begin_layout LyX-Code
5266  block if desired.      block if desired.
5267   *)   *)
5268  \end_layout  \end_layout
5269    
# Line 4430  END NOTES; Line 5272  END NOTES;
5272  \end_layout  \end_layout
5273    
5274  \begin_layout LyX-Code  \begin_layout LyX-Code
5275  ADD NOTES IN name_of_model METHOD  ADD NOTES IN name_of_model METHOD name_of_method;
 \end_layout  
   
 \begin_layout LyX-Code  
 name_of_method;  
5276  \end_layout  \end_layout
5277    
5278  \begin_layout LyX-Code  \begin_layout LyX-Code
5279  'language or keyword' SELF {    'language or keyword' SELF {
5280  \end_layout  \end_layout
5281    
5282  \begin_layout LyX-Code  \begin_layout LyX-Code
5283  This method proves Fermat's last theorem and      This method proves Fermat's last theorem and
5284  \end_layout  \end_layout
5285    
5286  \begin_layout LyX-Code  \begin_layout LyX-Code
5287  makes toast.      makes toast.
5288  \end_layout  \end_layout
5289    
5290  \begin_layout LyX-Code  \begin_layout LyX-Code
5291  }    }
5292  \end_layout  \end_layout
5293    
5294  \begin_layout LyX-Code  \begin_layout LyX-Code
5295  'humor' SELF {    'humor' SELF {
5296  \end_layout  \end_layout
5297    
5298  \begin_layout LyX-Code  \begin_layout LyX-Code
5299  ASCEND is not expected to make either proving      ASCEND is not expected to make either proving
5300  \end_layout  \end_layout
5301    
5302  \begin_layout LyX-Code  \begin_layout LyX-Code
5303  FLT or toasting possible.      FLT or toasting possible.
5304  \end_layout  \end_layout
5305    
5306  \begin_layout LyX-Code  \begin_layout LyX-Code
5307  }    }
5308  \end_layout  \end_layout
5309    
5310  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 4512  Experience has shown that even documenta Line 5350  Experience has shown that even documenta
5350   code and documentation that results from undisciplined modeling.   code and documentation that results from undisciplined modeling.
5351  \end_layout  \end_layout
5352    
5353  \begin_layout Section  \begin_layout Chapter
5354  Declarative statements  Declarative statements
5355  \begin_inset LatexCommand \index{statements, declarative}  \begin_inset LatexCommand \index{statements, declarative}
5356    
# Line 4535  Declarative statements Line 5373  Declarative statements
5373  We have already seen several examples that included declarative statements.  We have already seen several examples that included declarative statements.
5374   Here we will be more systematic in defining things.   Here we will be more systematic in defining things.
5375   The statements we describe are legal within the declarative portion of   The statements we describe are legal within the declarative portion of
5376   an ATOM or MODEL definition.   an
5377   The declarative portion stops at the keyword METHODS if it is present in  \family sans
5378   the definition or at the end of the definition.  ATOM
5379    \family default
5380     or
5381    \family sans
5382    MODEL
5383    \family default
5384     definition.
5385     The declarative portion stops at the keyword
5386    \family sans
5387    METHODS
5388    \family default
5389     if it is present in the definition or at the end of the definition.
5390  \end_layout  \end_layout
5391    
5392  \end_deeper  \end_deeper
# Line 4552  Statements Line 5401  Statements
5401    
5402  \end_inset  \end_inset
5403    
5404   Statements in ASCEND terminate with a semicolon (;).   Statements in ASCEND terminate with a semicolon (
5405    \family typewriter
5406    ;
5407    \family default
5408    ).
5409   Statements may extend over any number of lines.   Statements may extend over any number of lines.
5410   They may have blank lines in the middle of them.   They may have blank lines in the middle of them.
5411   There may be several statements on a single line.   There may be several statements on a single line.
# Line 4577  statements Line 5430  statements
5430  \end_inset  \end_inset
5431    
5432   Some statements in ASCEND can contain other statements as a part of them.   Some statements in ASCEND can contain other statements as a part of them.
5433   The declarative compound statements are the ALIASES/IS_A, CONDITIONAL,   The declarative compound statements are the
5434   FOR/CREATE, SELECT/CASE, and WHEN/CASE statements.  \family sans
5435   The procedural compound statements allowed only in methods are the FOR/DO,  ALIASES
5436   FOR/CHECK, SWITCH (* 4 *) and the IF statements.  \family default
5437   Compound statements end with "END word;", where word matches the beginning  /
5438   of the syntax block, e.g.  \family sans
5439   END FOR.and they can be nested, with some exceptions which are noted later.  IS_A
5440    \family default
5441    ,
5442    \family sans
5443    CONDITIONAL
5444    \family default
5445    ,
5446    \family sans
5447    FOR/CREATE
5448    \family default
5449    ,
5450    \family sans
5451    SELECT/CASE
5452    \family default
5453    , and
5454    \family sans
5455    WHEN/CASE
5456    \family default
5457     statements.
5458     The procedural compound statements allowed only in methods are the
5459    \family sans
5460    FOR/DO
5461    \family default
5462    ,
5463    \family sans
5464    FOR/CHECK
5465    \family default
5466    ,
5467    \family sans
5468    SWITCH
5469    \family default
5470     and the
5471    \family sans
5472    IF
5473    \family default
5474     statements.
5475     Compound statements end with "
5476    \family sans
5477    END
5478    \family default
5479    
5480    \family typewriter
5481    word
5482    \family default
5483    ;", where word matches the beginning of the syntax block, e.g.
5484    
5485    \family sans
5486    END FOR
5487    \family default
5488    .and they can be nested, with some exceptions which are noted later.
5489    
5490  \end_layout  \end_layout
5491    
5492  \begin_layout List  \begin_layout List
5493  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5494    
5495    \family sans
5496  \bar under  \bar under
5497  CASE\InsetSpace ~  CASE
5498    \family default
5499    \InsetSpace ~
5500  statements  statements
5501  \bar default  \bar default
5502    
# Line 4604  statements Line 5509  statements
5509    
5510  \end_inset  \end_inset
5511    
5512   (*4*) WHEN/CASE, CONDITIONAL, and SELECT/CASE handle modeling alternatives  
5513   within a single definition.  \family sans
5514    WHEN/CASE
5515    \family default
5516    ,
5517    \family sans
5518    CONDITIONAL
5519    \family default
5520    , and
5521    \family sans
5522    SELECT/CASE
5523    \family default
5524     handle modeling alternatives within a single definition.
5525   The easy way to remember the difference is that the first picks which equations   The easy way to remember the difference is that the first picks which equations
5526   to solve WHEN discrete variables have certain values, while the second   to solve
5527   SELECTs which statements to compile based on discrete constants.  \family sans
5528   (* 4 *) SWITCH statements handle flow of control in methods, in a slightly  WHEN
5529   more generalized form than the C language switch statement.  \family default
5530     discrete variables have certain values, while the second
5531    \family sans
5532    SELECT
5533    \family default
5534    s which statements to compile based on discrete constants.
5535     SWITCH statements handle flow of control in methods, in a slightly more
5536     generalized form than the C language switch statement.
5537  \end_layout  \end_layout
5538    
5539  \begin_layout List  \begin_layout List
# Line 4631  declarations Line 5554  declarations
5554    
5555  \begin_deeper  \begin_deeper
5556  \begin_layout Standard  \begin_layout Standard
5557  MODEL and ATOM type definitions and METHOD definitions are not really compound  
5558   statements because they require a name following their END word that matches  \family sans
5559   the name given at the beginning of the definition.  MODEL
5560    \family default
5561     and
5562    \family sans
5563    ATOM
5564    \family default
5565     type definitions and
5566    \family sans
5567    METHOD
5568    \family default
5569     definitions are not really compound statements because they require a name
5570     following their
5571    \family sans
5572    END
5573    \family default
5574     word that matches the name given at the beginning of the definition.
5575   These definitions cannot be nested.   These definitions cannot be nested.
5576  \end_layout  \end_layout
5577    
# Line 4656  Well start with an extremely brief synop Line 5594  Well start with an extremely brief synop
5594  \end_deeper  \end_deeper
5595  \begin_layout List  \begin_layout List
5596  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5597    
5598    \family sans
5599  IS_A  IS_A
5600    \family default
5601    
5602  \begin_inset LatexCommand \index{IS\_A}  \begin_inset LatexCommand \index{IS\_A}
5603    
5604  \end_inset  \end_inset
5605    
5606   Constructor.   Constructor.
5607   Calls for one or more named instances to be compiled using the type specified.   Calls for one or more named instances to be compiled using the type specified.
5608   (* 4 *) If the type is one that requires parameters, the parameters must   If the type is one that requires parameters, the parameters must be supplied
5609   be supplied in () following the type name.   in
5610    \family typewriter
5611    ()
5612    \family default
5613     following the type name.
5614  \end_layout  \end_layout
5615    
5616  \begin_layout List  \begin_layout List
5617  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5618    
5619    \family sans
5620  IS_REFINED_TO  IS_REFINED_TO
5621    \family default
5622    
5623  \begin_inset LatexCommand \index{IS\_REFINED\_TO}  \begin_inset LatexCommand \index{IS\_REFINED\_TO}
5624    
5625  \end_inset  \end_inset
# Line 4678  IS_REFINED_TO Line 5628  IS_REFINED_TO
5628   Causes the already compiled instance(s) named to have their type changed   Causes the already compiled instance(s) named to have their type changed
5629   to a more refined type.   to a more refined type.
5630   This causes an incremental recompilation of the instance(s).   This causes an incremental recompilation of the instance(s).
5631   IS_REFINED_TO is not a redefinition of the named instances because refinement  
5632   can only add compatible information.  \family sans
5633    IS_REFINED_TO
5634    \family default
5635     is not a redefinition of the named instances because refinement can only
5636     add compatible information.
5637   The instances retain all the structure that originally defined them.   The instances retain all the structure that originally defined them.
5638   (* 4 *) If the type being refined to requires arguments, these must be   If the type being refined to requires arguments, these must be supplied,
5639   supplied, even if the same arguments were required in the IS_A of the originall   even if the same arguments were required in the
5640  y less refined declaration of the instance.  \family sans
5641    IS_A
5642    \family default
5643     of the originally less refined declaration of the instance.
5644    
5645  \end_layout  \end_layout
5646    
5647  \begin_layout List  \begin_layout List
5648  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5649    
5650    \family sans
5651  ALIASES  ALIASES
5652    \family default
5653    
5654  \begin_inset LatexCommand \index{ALIASES}  \begin_inset LatexCommand \index{ALIASES}
5655    
5656  \end_inset  \end_inset
5657    
5658  \InsetSpace ~   Part alternate naming statement.
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *) Part alternate naming statement.  
5659   Establishes another name for an instance at the same scope or in a child   Establishes another name for an instance at the same scope or in a child
5660   instance.   instance.
5661   The equivalent of an ALIASES in ASCEND III is to create another part with  \begin_inset Foot
5662   the desired name and merge it immediately via ARE_THE_SAME with the part  status collapsed
5663   being renamed, a rather expensive and unintuitive process.  
5664    \begin_layout Standard
5665    The equivalent of an
5666    \family sans
5667    ALIASES
5668    \family default
5669     in ASCEND III was to create another part with the desired name and merge
5670     it immediately via
5671    \family sans
5672    ARE_THE_SAME
5673    \family default
5674     with the part being renamed, a rather expensive and unintuitive process.
5675    \end_layout
5676    
5677    \end_inset
5678    
5679    
5680  \end_layout  \end_layout
5681    
5682  \begin_layout List  \begin_layout List
5683  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5684    
5685    \family sans
5686  ALIASES/IS_A  ALIASES/IS_A
5687    \family default
5688    
5689  \begin_inset LatexCommand \index{ALIASES/IS\_A}  \begin_inset LatexCommand \index{ALIASES/IS\_A}
5690    
5691  \end_inset  \end_inset
5692    
5693  \InsetSpace ~  
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
5694  \end_layout  \end_layout
5695    
5696  \begin_deeper  \begin_deeper
# Line 4731  Creates an array of alternate names for Line 5706  Creates an array of alternate names for
5706  \end_deeper  \end_deeper
5707  \begin_layout List  \begin_layout List
5708  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5709    
5710    \family sans
5711  WILL_BE  WILL_BE
5712    \family default
5713    
5714  \begin_inset LatexCommand \index{WILL\_BE}  \begin_inset LatexCommand \index{WILL\_BE}
5715    
5716  \end_inset  \end_inset
5717    
5718  \InsetSpace ~   Forward declaration statement.
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *) Forward declaration statement.  
5719   Promises that a part with the given type will be constructed by an as yet   Promises that a part with the given type will be constructed by an as yet
5720   unknown IS_A statement above the current scope.   unknown IS_A statement above the current scope.
5721   At present WILL_BE is legal only in defining parameters.   At present
5722    \family sans
5723    WILL_BE
5724    \family default
5725     is legal only in defining parameters.
5726   Were it legal in the body of a model, compiling models would be very expensive.   Were it legal in the body of a model, compiling models would be very expensive.
5727  \end_layout  \end_layout
5728    
5729  \begin_layout List  \begin_layout List
5730  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5731    
5732    \family sans
5733  ARE_THE_SAME  ARE_THE_SAME
5734    \family default
5735    
5736  \begin_inset LatexCommand \index{ARE\_THE\_SAME}  \begin_inset LatexCommand \index{ARE\_THE\_SAME}
5737    
5738  \end_inset  \end_inset
# Line 4764  ARE_THE_SAME Line 5748  ARE_THE_SAME
5748    
5749  \begin_layout List  \begin_layout List
5750  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5751    
5752    \family sans
5753  WILL_BE_THE_SAME  WILL_BE_THE_SAME
5754    \family default
5755    
5756  \begin_inset LatexCommand \index{WILL\_BE\_THE\_SAME}  \begin_inset LatexCommand \index{WILL\_BE\_THE\_SAME}
5757    
5758  \end_inset  \end_inset
5759    
5760  \InsetSpace ~  
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
5761  \end_layout  \end_layout
5762    
5763  \begin_deeper  \begin_deeper
# Line 4786  d. Line 5771  d.
5771  \end_deeper  \end_deeper
5772  \begin_layout List  \begin_layout List
5773  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5774    
5775    \family sans
5776  WILL_NOT_BE_THE_SAME  WILL_NOT_BE_THE_SAME
5777    \family default
5778    
5779  \begin_inset LatexCommand \index{WILL\_NOT\_BE\_THE\_SAME}  \begin_inset LatexCommand \index{WILL\_NOT\_BE\_THE\_SAME}
5780    
5781  \end_inset  \end_inset
5782    
5783  \InsetSpace ~  
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
5784  \end_layout  \end_layout
5785    
5786  \begin_deeper  \begin_deeper
# Line 4811  Structural condition statement restricti Line 5797  Structural condition statement restricti
5797  \end_deeper  \end_deeper
5798  \begin_layout List  \begin_layout List
5799  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5800    \begin_inset Note Note
5801    status open
5802    
5803    \begin_layout List
5804    \labelwidthstring 00000.00000.00000.000
5805    
5806    \family sans
5807  ARE_NOT_THE_SAME  ARE_NOT_THE_SAME
5808    \family default
5809    
5810  \begin_inset LatexCommand \index{ARE\_NOT\_THE\_SAME}  \begin_inset LatexCommand \index{ARE\_NOT\_THE\_SAME}
5811    
5812  \end_inset  \end_inset
5813    
5814  \InsetSpace ~  
 (*\InsetSpace ~  
 4+\InsetSpace ~  
 *)  
5815  \end_layout  \end_layout
5816    
 \begin_deeper  
5817  \begin_layout Standard  \begin_layout Standard
5818  Cannot be merged.  Cannot be merged.
5819   We believe it is useful to say that two objects cannot be merged and still   We believe it is useful to say that two objects cannot be merged and still
# Line 4831  Cannot be merged. Line 5822  Cannot be merged.
5822   The implementation is simple.   The implementation is simple.
5823  \end_layout  \end_layout
5824    
5825  \end_deeper  \end_inset
5826    
5827    
5828    \end_layout
5829    
5830  \begin_layout List  \begin_layout List
5831  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5832    
5833    \family sans
5834  ARE_ALIKE  ARE_ALIKE
5835    \family default
5836    
5837  \begin_inset LatexCommand \index{ARE\_ALIKE}  \begin_inset LatexCommand \index{ARE\_ALIKE}
5838    
5839  \end_inset  \end_inset
# Line 4854  ARE_ALIKE Line 5853  ARE_ALIKE
5853    
5854  \begin_layout List  \begin_layout List
5855  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5856    
5857    \family sans
5858  FOR/CREATE  FOR/CREATE
5859    \family default
5860    
5861  \begin_inset LatexCommand \index{FOR/CREATE}  \begin_inset LatexCommand \index{FOR/CREATE}
5862    
5863  \end_inset  \end_inset
# Line 4865  FOR/CREATE Line 5868  FOR/CREATE
5868    
5869  \begin_layout List  \begin_layout List
5870  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5871    
5872    \family sans
5873  FOR/CHECK  FOR/CHECK
5874    \family default
5875    
5876  \begin_inset LatexCommand \index{FOR/CHECK}  \begin_inset LatexCommand \index{FOR/CHECK}
5877    
5878  \end_inset  \end_inset
# Line 4880  FOR/CHECK Line 5887  FOR/CHECK
5887    
5888  \begin_layout List  \begin_layout List
5889  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5890    
5891    \family sans
5892  SELECT/CASE  SELECT/CASE
5893    \family default
5894    
5895  \begin_inset LatexCommand \index{SELECT/CASE}  \begin_inset LatexCommand \index{SELECT/CASE}
5896    
5897  \end_inset  \end_inset
5898    
5899  \InsetSpace ~  
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
5900  \end_layout  \end_layout
5901    
5902  \begin_deeper  \begin_deeper
5903  \begin_layout Standard  \begin_layout Standard
5904  Select a subset of statements to compile.  Select a subset of statements to compile.
5905   Given the values of the specified constants, SELECT compiles all cases   Given the values of the specified constants,
5906   that match those values.  \family sans
5907   A name cannot be defined two different ways inside the SELECT statement,  SELECT
5908   but it may be defined outside the case statement and then refined in different  \family default
5909   ways in separate cases.   compiles all cases that match those values.
5910     A name cannot be defined two different ways inside the
5911    \family sans
5912    SELECT
5913    \family default
5914     statement, but it may be defined outside the case statement and then refined
5915     in different ways in separate cases.
5916  \end_layout  \end_layout
5917    
5918  \end_deeper  \end_deeper
5919  \begin_layout List  \begin_layout List
5920  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5921    
5922    \family sans
5923  CONDITIONAL  CONDITIONAL
5924    \family default
5925    
5926  \begin_inset LatexCommand \index{CONDITIONAL}  \begin_inset LatexCommand \index{CONDITIONAL}
5927    
5928  \end_inset  \end_inset
5929    
5930  \InsetSpace ~  
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
5931  \end_layout  \end_layout
5932    
5933  \begin_deeper  \begin_deeper
5934  \begin_layout Standard  \begin_layout Standard
5935  Describe bounding relations.  Describe bounding relations.
5936   The relations written inside a CONDITIONAL statement must all be labelled.   The relations written inside a
5937    \family sans
5938    CONDITIONAL
5939    \family default
5940     statement must all be labelled.
5941   These relations can be used to define regions in which alternate sets of   These relations can be used to define regions in which alternate sets of
5942   equations apply using the WHEN statement.   equations apply using the
5943    \family sans
5944    WHEN
5945    \family default
5946     statement.
5947  \end_layout  \end_layout
5948    
5949  \end_deeper  \end_deeper
5950  \begin_layout List  \begin_layout List
5951  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
5952    
5953    \family sans
5954  WHEN/CASE  WHEN/CASE
5955    \family default
5956    
5957  \begin_inset LatexCommand \index{WHEN/CASE}  \begin_inset LatexCommand \index{WHEN/CASE}
5958    
5959  \end_inset  \end_inset
5960    
5961  \InsetSpace ~   When logical variables have certain values, use certain relations or model
5962  (*\InsetSpace ~   parts in defining a mathematical problem.
 4\InsetSpace ~  
 *) When logical variables have certain values, use certain relations  
  or model parts in defining a mathematical problem.  
5963   The relations are not defined inside the WHEN statement because all the   The relations are not defined inside the WHEN statement because all the
5964   relations must be compiled regardless of which values the logical variables   relations must be compiled regardless of which values the logical variables
5965   have at any given moment.   have at any given moment.
# Line 5701  END FOR; Line 6725  END FOR;
6725  \end_layout  \end_layout
6726    
6727  \begin_layout Standard  \begin_layout Standard
6728  FOR loops can be nested to produce sparse arrays as illustrated in Arrays  
6729   can be jagged(  \family sans
6730    FOR
6731    \family default
6732     loops can be nested to produce sparse arrays as illustrated in Arrays can
6733     be jagged(
6734  \begin_inset LatexCommand \vpageref{lyx:Arrays-can-be}  \begin_inset LatexCommand \vpageref{lyx:Arrays-can-be}
6735    
6736  \end_inset  \end_inset
# Line 5715  FOR loops can be nested to produce spars Line 6743  FOR loops can be nested to produce spars
6743  \end_deeper  \end_deeper
6744  \begin_layout List  \begin_layout List
6745  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
6746    
6747    \family sans
6748  SELECT/CASE  SELECT/CASE
6749    \family default
6750    
6751  \begin_inset LatexCommand \index{SELECT/CASE}  \begin_inset LatexCommand \index{SELECT/CASE}
6752    
6753  \end_inset  \end_inset
6754    
6755  \InsetSpace ~  
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
6756  \end_layout  \end_layout
6757    
6758  \begin_deeper  \begin_deeper
# Line 5731  SELECT/CASE Line 6760  SELECT/CASE
6760  Declarative.  Declarative.
6761   Order does not matter.   Order does not matter.
6762   All matching cases are executed.   All matching cases are executed.
6763   The OTHERWISE   The
6764    \family sans
6765    OTHERWISE
6766    \family default
6767    
6768  \begin_inset LatexCommand \index{OTHERWISE}  \begin_inset LatexCommand \index{OTHERWISE}
6769    
6770  \end_inset  \end_inset
6771    
6772   is executed if present and no other CASEs match.   is executed if present and no other
6773   SELECT is not allowed inside FOR.  \family sans
6774   Writing FOR statements inside SELECT is allowed.  CASE
6775    \family default
6776    s match.
6777    
6778    \family sans
6779    SELECT
6780    \family default
6781     is not allowed inside
6782    \family sans
6783    FOR
6784    \family default
6785    .
6786     Writing
6787    \family sans
6788    FOR
6789    \family default
6790     statements inside
6791    \family sans
6792    SELECT
6793    \family default
6794     is allowed.
6795  \end_layout  \end_layout
6796    
6797  \end_deeper  \end_deeper
6798  \begin_layout List  \begin_layout List
6799  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
6800    
6801    \family sans
6802  CONDITIONAL  CONDITIONAL
6803    \family default
6804    
6805  \begin_inset LatexCommand \index{CONDITIONAL}  \begin_inset LatexCommand \index{CONDITIONAL}
6806    
6807  \end_inset  \end_inset
6808    
6809  \InsetSpace ~  
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
6810  \end_layout  \end_layout
6811    
6812  \begin_deeper  \begin_deeper
6813  \begin_layout Standard  \begin_layout Standard
6814  Both real and logical relations are allowed in CONDITIONAL statements.  Both real and logical relations are allowed in
6815   CONDITIONAL is really just a shorthand for setting the $boundary flag on  \family sans
6816   a whole batch of relations, since $boundary is a write-once attribute invisible  CONDITIONAL
6817   through the user interface and methods at this time.  \family default
6818     statements.
6819    \begin_inset Foot
6820    status open
6821    
6822    \begin_layout Standard
6823    
6824    \family sans
6825    CONDITIONAL
6826    \family default
6827     is really just a shorthand for setting the
6828    \family typewriter
6829    $boundary
6830    \family default
6831     flag on a whole batch of relations, since
6832    \family typewriter
6833    $boundary
6834    \family default
6835     is a write-once attribute invisible through the user interface and methods
6836     at this time.
6837    \end_layout
6838    
6839    \end_inset
6840    
6841    
6842  \end_layout  \end_layout
6843    
6844  \end_deeper  \end_deeper
6845  \begin_layout List  \begin_layout List
6846  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
6847    
6848    \family sans
6849  WHEN/CASE  WHEN/CASE
6850    \family default
6851    
6852  \begin_inset LatexCommand \index{WHEN/CASE}  \begin_inset LatexCommand \index{WHEN/CASE}
6853    
6854  \end_inset  \end_inset
6855    
6856  \InsetSpace ~   Inside each
6857  (*\InsetSpace ~  \family sans
6858  4\InsetSpace ~  CASE
6859  *) Inside each CASE, relations or model parts to be used are specified  \family default
6860   by writing, for example, USE mass_balance_1;.  , relations or model parts to be used are specified by writing, for example,
6861    
6862    \family typewriter
6863    USE mass_balance_1;
6864    \family default
6865    .
6866   The method of dealing with the combined logical/nonlinear model is left   The method of dealing with the combined logical/nonlinear model is left
6867   to the solver.   to the solver.
6868   All matching CASEs are included in the problem to be solved.   All matching
6869    \family sans
6870    CASE
6871    \family default
6872    s are included in the problem to be solved.
6873    
6874  \end_layout  \end_layout
6875    
6876  \begin_deeper  \begin_deeper
6877  \begin_layout Section  \begin_layout Chapter
6878  Procedural statements  Procedural statements
6879  \begin_inset LatexCommand \index{statements, procedural}  \begin_inset LatexCommand \index{statements, procedural}
6880    
# Line 5805  Procedural statements Line 6896  Procedural statements
6896  \end_deeper  \end_deeper
6897  \begin_layout List  \begin_layout List
6898  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
6899    
6900    \family sans
6901  METHODS  METHODS
6902    \family default
6903    
6904  \begin_inset LatexCommand \index{METHODS}  \begin_inset LatexCommand \index{METHODS}
6905    
6906  \end_inset  \end_inset
# Line 5824  METHODS Line 6919  METHODS
6919    
6920  \begin_layout Standard  \begin_layout Standard
6921  with no punctuation.  with no punctuation.
6922   The next code must be a METHOD or the END of the type being defined.   The next code must be a
6923    \family sans
6924    METHOD
6925    \family default
6926     or the
6927    \family sans
6928    END
6929    \family default
6930     of the type being defined.
6931   If there are no method definitions, this statement may be omitted.   If there are no method definitions, this statement may be omitted.
6932  \end_layout  \end_layout
6933    
6934  \begin_layout Standard  \begin_layout Standard
6935  METHOD definitions for a type can also be added or replaced after the type  
6936   has been defined.  \family sans
6937    METHOD
6938    \family default
6939     definitions for a type can also be added or replaced after the type has
6940     been defined.
6941   This is to make creating and debugging of methods as interactive as possible.   This is to make creating and debugging of methods as interactive as possible.
6942   In ASCEND III an instance must be destroyed and recreated each time a new   In ASCEND an instance must be destroyed and recreated each time a new or
6943   or revised method is added to the type definition.   revised method is added to the type definition.
6944   This is a very expensive process when working with models of significant   This is a very expensive process when working with models of significant
6945   size.   size.
6946  \end_layout  \end_layout
# Line 5846  The detailed semantics of method inherit Line 6953  The detailed semantics of method inherit
6953  \end_deeper  \end_deeper
6954  \begin_layout List  \begin_layout List
6955  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
6956    
6957    \family sans
6958  ADD\InsetSpace ~  ADD\InsetSpace ~
6959  METHODS\InsetSpace ~  METHODS\InsetSpace ~
6960  IN  IN
6961    \family default
6962    
6963  \begin_inset LatexCommand \index{ADD METHODS IN}  \begin_inset LatexCommand \index{ADD METHODS IN}
6964    
6965  \end_inset  \end_inset
6966    
6967    
6968    \family typewriter
6969  \InsetSpace ~  \InsetSpace ~
6970  type_name;\InsetSpace ~  type_name;
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
6971  \end_layout  \end_layout
6972    
6973  \begin_deeper  \begin_deeper
# Line 5878  e rules. Line 6988  e rules.
6988  \end_deeper  \end_deeper
6989  \begin_layout List  \begin_layout List
6990  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
6991    
6992    \family sans
6993  REPLACE\InsetSpace ~  REPLACE\InsetSpace ~
6994  METHODS\InsetSpace ~  METHODS\InsetSpace ~
6995  IN  IN
6996    \family default
6997    
6998  \begin_inset LatexCommand \index{REPLACE METHODS IN}  \begin_inset LatexCommand \index{REPLACE METHODS IN}
6999    
7000  \end_inset  \end_inset
7001    
7002    
7003    \family typewriter
7004  \InsetSpace ~  \InsetSpace ~
7005  type_name;\InsetSpace ~  type_name;
 (*\InsetSpace ~  
 4\InsetSpace ~  
 *)  
7006  \end_layout  \end_layout
7007    
7008  \begin_deeper  \begin_deeper
7009  \begin_layout Standard  \begin_layout Standard
7010  This statement allows existing methods to be replaced in an already loaded  This statement allows existing methods to be replaced in an already loaded
7011   type definition.   type definition.
7012   The next code must be a METHOD or the END METHODS; statement.   The next code must be a
7013   If a method of the same name does not exist in type_name, the statement  \family sans
7014   is in error.  METHOD
7015   If other types refine type_name then the replacement follows the method  \family default
7016   inheritance rules.   or the
7017    \family sans
7018    END METHODS
7019    \family default
7020     statement.
7021     If a method of the same name does not exist in
7022    \family typewriter
7023    type_name
7024    \family default
7025    , the statement is in error.
7026     If other types refine
7027    \family typewriter
7028    type_name
7029    \family default
7030     then the replacement follows the method inheritance rules.
7031   Any type which inherited the old method now inherits the replacment method   Any type which inherited the old method now inherits the replacment method
7032   instead.   instead.
7033  \end_layout  \end_layout
# Line 5908  This statement allows existing methods t Line 7035  This statement allows existing methods t
7035  \end_deeper  \end_deeper
7036  \begin_layout List  \begin_layout List
7037  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
7038    
7039    \family sans
7040  ADD\InsetSpace ~  ADD\InsetSpace ~
7041  METHODS\InsetSpace ~  METHODS\InsetSpace ~
7042  IN\InsetSpace ~  IN\InsetSpace ~
7043  DEFINITION\InsetSpace ~  DEFINITION\InsetSpace ~
7044  MODEL;  MODEL
7045    \family typewriter
7046    ;
7047  \end_layout  \end_layout
7048    
7049  \begin_deeper  \begin_deeper
7050  \begin_layout Standard  \begin_layout Standard
7051  This statement allows methods to be added globally.  This statement allows methods to be added globally.
7052   It should be used very sparingly.   It should be used very sparingly.
7053   Library basemodel.a4l contains the example of this statement.   Library
7054    \family typewriter
7055    basemodel.a4l
7056    \family default
7057     contains the example of this statement.
7058   Methods in the global model definition are inherited by all models.   Methods in the global model definition are inherited by all models.
7059   There is no actual global model definition, but it has a method list for   There is no actual global model definition, but it has a method list for
7060   practical purposes.   practical purposes.
# Line 5964  METHOD Line 7099  METHOD
7099  At present, there are no local variables or other structures in methods  At present, there are no local variables or other structures in methods
7100   except loop indices.   except loop indices.
7101   A method may be written recursively, but there is an arbitrary stack depth   A method may be written recursively, but there is an arbitrary stack depth
7102   limit (currently set to 20 in compiler/initialize.h) to prevent the system   limit
7103   from crashing on infinite recursions.  \begin_inset Foot
7104    status open
7105    
7106    \begin_layout Standard
7107    currently set to 20 in
7108    \family typewriter
7109    compiler/initialize.h
7110    \end_layout
7111    
7112    \end_inset
7113    
7114     to prevent the system from crashing on infinite recursions.
7115    
7116  \end_layout  \end_layout
7117    
7118  \begin_layout Standard  \begin_layout Standard
7119  Specifically disallowed in ASCEND III methods are IS_A, ALIASES, WILL_BE,  Specifically disallowed in ASCEND methods are
7120   IS, IS_REFINED_TO, ARE_THE_SAME and ARE_ALIKE statements as these declare  \family sans
7121   the structure of the model and belong only in the declarative section.  IS_A
7122    \family default
7123    ,
7124    \family sans
7125    ALIASES
7126    \family default
7127    ,
7128    \family sans
7129    WILL_BE
7130    \family default
7131    ,
7132    \family sans
7133    IS
7134    \family default
7135    ,
7136    \family sans
7137    IS_REFINED_TO
7138    \family default
7139    ,
7140    \family sans
7141    ARE_THE_SAME
7142    \family default
7143     and
7144    \family sans
7145    ARE_ALIKE
7146    \family default
7147     statements as these declare the structure of the model and belong only
7148     in the declarative section.
7149  \end_layout  \end_layout
7150    
7151  \begin_layout Standard  \begin_layout Standard
7152    \begin_inset Note Note
7153    status open
7154    
7155    \begin_layout Standard
7156  (* 4+ *) In the near future, declarations of local instances (which are  (* 4+ *) In the near future, declarations of local instances (which are
7157   automatically destroyed when the method exits) will be allowed.   automatically destroyed when the method exits) will be allowed.
7158   Since methods are imperative, these local structure definitions are processed   Since methods are imperative, these local structure definitions are processed
# Line 5988  Specifically disallowed in ASCEND III me Line 7165  Specifically disallowed in ASCEND III me
7165   to use as the declarative ASCEND language.   to use as the declarative ASCEND language.
7166  \end_layout  \end_layout
7167    
7168    \end_inset
7169    
7170    
7171    \end_layout
7172    
7173  \begin_layout Standard  \begin_layout Standard
7174  The syntax for a method declaration is  The syntax for a method declaration is
7175  \end_layout  \end_layout
# Line 6085  Its meaning is that the value for the va Line 7267  Its meaning is that the value for the va
7267  \end_layout  \end_layout
7268    
7269  \begin_layout Standard  \begin_layout Standard
7270  DATA (* 4+ *) statements can (should, rather) also appear in methods.  
7271    \family sans
7272    DATA
7273    \family default
7274     statements can (should, rather) also appear in methods.
7275    
7276  \end_layout  \end_layout
7277    
# Line 6102  FOR/DO Line 7288  FOR/DO
7288    
7289  \begin_deeper  \begin_deeper
7290  \begin_layout Standard  \begin_layout Standard
7291  This statement is similar to the FOR/CREATE statement except it can only  This statement is similar to the
7292   appear in a method definition.  \family sans
7293    FOR/CREATE
7294    \family default
7295     statement except it can only appear in a method definition.
7296   An example would be   An example would be
7297  \end_layout  \end_layout
7298    
# Line 6124  END FOR; Line 7313  END FOR;
7313  \end_layout  \end_layout
7314    
7315  \begin_layout Standard  \begin_layout Standard
7316  Here we actually execute using the values of i in the sequence given.  Here we actually execute using the values of
7317    \family typewriter
7318    i
7319    \family default
7320     in the sequence given.
7321   So,   So,
7322  \end_layout  \end_layout
7323    
# Line 6157  is a backward loop. Line 7350  is a backward loop.
7350  \end_deeper  \end_deeper
7351  \begin_layout List  \begin_layout List
7352  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
7353    
7354    \family sans
7355  IF  IF
7356    \family default
7357    
7358  \begin_inset LatexCommand \index{IF}  \begin_inset LatexCommand \index{IF}
7359    
7360  \end_inset  \end_inset
# Line 6167  IF Line 7364  IF
7364    
7365  \begin_deeper  \begin_deeper
7366  \begin_layout Standard  \begin_layout Standard
7367  The IF statement can only appear in a method definition.  The
7368    \family sans
7369    IF
7370    \family default
7371    statement can only appear in a method definition.
7372   Its syntax is   Its syntax is
7373  \end_layout  \end_layout
7374    
# Line 6222  END IF; Line 7423  END IF;
7423  \end_layout  \end_layout
7424    
7425  \begin_layout Standard  \begin_layout Standard
7426  If the logical expression has a value of TRUE, ASCEND will execute the statement  If the logical expression has a value of
7427  s in the THEN part.  \family sans
7428   If the value is FALSE, ASCEND executes the statements in the optional ELSE  TRUE
7429    \family default
7430    , ASCEND will execute the statements in the
7431    \family sans
7432    THEN
7433    \family default
7434   part.   part.
7435   Please use () to make the precedence of AND, OR, NOT, ==, and != clear   If the value is
7436   to both the user and the system.  \family sans
7437    FALSE
7438    \family default
7439    , ASCEND executes the statements in the optional
7440    \family sans
7441    ELSE
7442    \family default
7443     part.
7444     Please use
7445    \family typewriter
7446    ()
7447    \family default
7448     to make the precedence of
7449    \family sans
7450    AND
7451    \family default
7452    ,
7453    \family sans
7454    OR
7455    \family default
7456    ,
7457    \family sans
7458    NOT
7459    \family default
7460    ,
7461    \family typewriter
7462    ==
7463    \family default
7464    , and
7465    \family typewriter
7466    !=
7467    \family default
7468     clear to both the user and the system.
7469  \end_layout  \end_layout
7470    
7471  \end_deeper  \end_deeper
7472  \begin_layout List  \begin_layout List
7473  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
7474    
7475    \family sans
7476  SWITCH  SWITCH
7477    \family default
7478    
7479  \begin_inset LatexCommand \index{SWITCH}  \begin_inset LatexCommand \index{SWITCH}
7480    
7481  \end_inset  \end_inset
7482    
7483  \InsetSpace ~   Essentially roughly equivalent to the C
7484  (*\InsetSpace ~  \family typewriter
7485  4\InsetSpace ~  switch
7486  *) Essentially roughly equivalent to the C switch statement, except that  \family default
7487   ASCEND allows wildcard matches, allows any number of controlling variables   statement, except that ASCEND allows wildcard matches, allows any number
7488   to be given in a list, and assumes BREAK at the end of each CASE.   of controlling variables to be given in a list, and assumes
7489    \family sans
7490    BREAK
7491    \family default
7492     at the end of each
7493    \family sans
7494    CASE
7495    \family default
7496    .
7497    
7498  \end_layout  \end_layout
7499    
7500    \begin_deeper
7501    \begin_layout List
7502    \labelwidthstring 00000.00000.00000.000
7503    \begin_inset Note Note
7504    status open
7505    
7506    \begin_layout Standard
7507    EXAMPLE of SWITCH required here
7508    \end_layout
7509    
7510    \end_inset
7511    
7512    
7513    \end_layout
7514    
7515    \end_deeper
7516  \begin_layout List  \begin_layout List
7517  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
7518    
7519    \family sans
7520  CALL  CALL
7521    \family default
7522    
7523  \begin_inset LatexCommand \index{CALL}  \begin_inset LatexCommand \index{CALL}
7524    
7525  \end_inset  \end_inset
7526    
7527   External calls are not presently well defined, pending debugging of the   External calls are not presently well defined, pending debugging of the
7528   EXTERNAL  
7529    \family sans
7530    EXTERNAL
7531    \family default
7532    
7533  \begin_inset LatexCommand \index{EXTERNAL}  \begin_inset LatexCommand \index{EXTERNAL}
7534    
7535  \end_inset  \end_inset
# Line 6265  CALL Line 7539  CALL
7539    
7540  \begin_layout List  \begin_layout List
7541  \labelwidthstring 00000.00000.00000.000  \labelwidthstring 00000.00000.00000.000
7542    
7543    \family sans
7544  RUN  RUN
7545    \family default
7546    
7547  \begin_inset LatexCommand \index{RUN}  \begin_inset LatexCommand \index{RUN}
7548    
7549  \end_inset  \end_inset
# Line 6311  model_type::name_of_method Line 7589  model_type::name_of_method
7589  The named method can be defined in the current model (the first syntax),  The named method can be defined in the current model (the first syntax),
7590   or in any of its parts (the second syntax).   or in any of its parts (the second syntax).
7591   Methods defined in a part will be run in the scope of that part, not at   Methods defined in a part will be run in the scope of that part, not at
7592   the scope of the RUN statement.   the scope of the
7593    \family sans
7594    RUN
7595    \family default
7596     statement.
7597  \end_layout  \end_layout
7598    
7599  \end_deeper  \end_deeper
# Line 6325  methods: Line 7607  methods:
7607    
7608  \begin_deeper  \begin_deeper
7609  \begin_layout Standard  \begin_layout Standard
7610  When model_type::  When
7611    \family typewriter
7612    model_type::
7613    \family default
7614    
7615  \begin_inset LatexCommand \index{::}  \begin_inset LatexCommand \index{::}
7616    
7617  \end_inset  \end_inset
# Line 6396  END specify; Line 7682  END specify;
7682  END bar;  END bar;
7683  \end_layout  \end_layout
7684    
7685  \begin_layout Section  \begin_layout Chapter
7686  Parameterized models  Parameterized models
7687  \begin_inset LatexCommand \index{models, parameterized}  \begin_inset LatexCommand \index{models, parameterized}
7688    
# Line 6416  Parameterized models Line 7702  Parameterized models
7702  \end_layout  \end_layout
7703    
7704  \begin_layout Standard  \begin_layout Standard
7705  Parameterized model definitions have the following general form.  Parameterized model definitions have the following general form
7706    \begin_inset Foot
7707    status collapsed
7708    
7709    \begin_layout Standard
7710     signify optional parts
7711    \end_layout
7712    
7713    \end_inset
7714    
7715    :
7716  \end_layout  \end_layout
7717    
7718  \begin_layout LyX-Code  \begin_layout LyX-Code
# Line 6444  where_list Line 7740  where_list
7740  \emph on  \emph on
7741  existing_type  existing_type
7742  \emph default  \emph default
7743   (  (
7744  \emph on  \emph on
7745  assignment_list  assignment_list
7746  \emph default  \emph default
7747  ;);  ;);
7748  \end_layout  \end_layout
7749    
7750  \begin_layout Subsection  \begin_layout Section
7751  The parameter list  The parameter list
7752  \begin_inset LatexCommand \label{sub:x.5.1The-parameter-list}  \begin_inset LatexCommand \label{sub:x.5.1The-parameter-list}
7753    
# Line 6463  The parameter list Line 7759  The parameter list
7759  \begin_layout Standard  \begin_layout Standard
7760  A parameter list is a list of statements about the objects that will be  A parameter list is a list of statements about the objects that will be
7761   passed into the model being defined when an instance of that model is created   passed into the model being defined when an instance of that model is created
7762   by IS_A or IS_REFINED_TO.   by
7763    \family sans
7764    IS_A
7765    \family default
7766     or
7767    \family sans
7768    IS_REFINED_TO
7769    \family default
7770    .
7771   The parameter list is designed to allow a complete statement of the necessary   The parameter list is designed to allow a complete statement of the necessary
7772   and sufficient conditions to construct the parameterized model.   and sufficient conditions to construct the parameterized model.
7773   The mechanism implemented is general, however, so it is possible to put   The mechanism implemented is general, however, so it is possible to put
# Line 6473  A parameter list is a list of statements Line 7777  A parameter list is a list of statements
7777   computer languages (and to make the implementation much simpler), we define   computer languages (and to make the implementation much simpler), we define
7778   the parameter list as ordered.   the parameter list as ordered.
7779   All the statements in a parameter list, including the last one, must end   All the statements in a parameter list, including the last one, must end
7780   with a ";".   with a `
7781    \family typewriter
7782    ;
7783    \family default
7784    '.
7785   A parameter list looks like:   A parameter list looks like:
7786  \end_layout  \end_layout
7787    
# Line 6502  MODEL test ( Line 7810  MODEL test (
7810  \end_layout  \end_layout
7811    
7812  \begin_layout Standard  \begin_layout Standard
7813  Each WILL_BE statement corresponds to a single object that the user must  Each
7814   create and pass into the definition of test.  \family sans
7815   We will establish the local name x for the first object passed to the definitio  WILL_BE
7816  n of test.  \family default
7817   n is handled similarly, and it must preceed the definition of p[1..n], because   statement corresponds to a single object that the user must create and
7818   it defines the set for the array p.   pass into the definition of test.
7819   Constant types can also be defined with WILL_BE, though we have used IS_A   We will establish the local name
7820    \family typewriter
7821    x
7822    \family default
7823     for the first object passed to the definition of test.
7824    
7825    \family typewriter
7826    n