Go to the first, previous, next, last section, table of contents.
And expression is a mathematical, logical or relational formula that can be evaluated at run time. More formally :-
And expressions is a either a term
, or term + term
or term
- term
or a logical expression or a relational expression.
A term is either :-
term * term
term / term
term DIV term
term MOD term
- term
( expression )
Numbers are standard C double precision numbers :-
1 -1 1e300 // Very big number -1.23e-300 // A Number very near zero
Logical expressions are either :-
A relational expression is either an adjacency expression or one of :-
An adjacency expression allows one to query the state of variables in neighbouring cells.
An adjacency expression is one of the following :-
A cellBasedId is a cell based specie name, or a local variable of a cell based specie or a cell based data stream. See See section References for details.
For example, if the beastie stick_bait
started to grow in this cell if any
adjacent cell had stick bait growing, then one might express this as :-
if any adjacent stick_bait > 2 then stick_bait += 0.5; endif;
Range expressions allow
one to query data streams. It is not meaningful to sample a data stream at one point,
rather we need to know the state of the variable over a period of time. The langauge makes
available two special constructs to query data streams. For example :- If we wish to know
whether the concentration was in the range 25 to 40 for most of the time in the last time
step we can simple say :- concentration in [25, 40]
. By most of the time we
by default mean 90% of the time, or whatever the current value of the variable
"most_times" is. ("most_times" is a predefined system variable that is
by default set to 0.9)
qualIdent in [lower, upper];
If the data stream qualIdent
is greater than lower
and less
than upper
for most_times
* step_size
seconds in
the last time step, then the expression evaluates as true otherwise as false. (See section
The Boolean convention)
qualIdent in [lower, upper, most_times, period];
If the data stream qualIdent
is greater than lower
and less
than upper
for most_times
* period
* step_size
seconds in the preceding period
steps, then the expression evaluates as true
otherwise as false. (See section The Boolean convention)
rules : cells links io_statements setup_statements species THE_END ; setup_statements : /* Nothing */ | statements; cells : CELLS cellList ';' ; cellList : IDENTIFIER | cellList ',' IDENTIFIER ; links : link | links link; link : LINK IDENTIFIER ',' IDENTIFIER ';' ; io_statements : input output | output input; input : INPUT FROM STRING ';' ; output : OUTPUT TO STRING ';' ; species : specie | species specie; specie : specie_header specie_body end_specie ; end_specie : END SPECIE ';' | END SPECIE IDENTIFIER ';' ; specie_header : /* Default is cell based. */ SPECIE IDENTIFIER ';' | CELL BASED SPECIE IDENTIFIER ';' | ECOSYSTEM WIDE SPECIE IDENTIFIER ';' ; specie_body : declarations start_statements running_rules; declarations : /* Nothing */ | DECLARE decl_list ';' ; decl_list : IDENTIFIER | decl_list ',' IDENTIFIER ; start_statements : statements RUNNING RULES ';' | /* Nothing */ RUNNING RULES ';' ; running_rules : statements ; statements : statement | statements statement; statement : /* Empty statement */ ';' | assignment_statement | if_then_endif | trace_statement | print_statement | if_then_else_endif ; trace_statement : TRACE expression ';' print_statement : one_arg_print | two_arg_print | show_statement; one_arg_print : PRINT expression ';' two_arg_print : PRINT STRING expression ';' show_statement : SHOW qualIdent ';' if_then_endif : if_then statements ENDIF ';' ; if_then : IF expression THEN ; if_then_else_endif : if_then statements else statements ENDIF ';'; else : ELSE; unqualifiedIdent : IDENTIFIER; qualifiedIdent : IDENTIFIER '.' IDENTIFIER; qualifiedAt : IDENTIFIER '.' IDENTIFIER '@' IDENTIFIER; unqualifiedAt : IDENTIFIER '@' IDENTIFIER; notAtted : unqualifiedIdent | qualifiedIdent ; atted : unqualifiedAt | qualifiedAt ; qualIdent : atted | notAtted; assignment_statement : assignment | increment | decrement; assignment : qualIdent BECOMES expression ';'; increment : qualIdent INCREMENT expression ';'; decrement : qualIdent DECREMENT expression ';'; expression : term | expression '+' term | expression '-' term | logical_expression | relational_expression ; term : REAL | range | qualIdent | term '*' term | term '/' term | term DIV term | term MOD term | '-' term %prec UMINUS | '(' expression ')' ; range : mono_stream_range | ecowide_range ; mono_stream_range : two_arg_plain | four_arg_plain; two_arg_plain : qualIdent IN two_arg_range; four_arg_plain : qualIdent IN four_arg_range; ecowide_range : two_arg_any | four_arg_any | two_arg_all | four_arg_all ; two_arg_any : qualIdent IN ANY CELL two_arg_range; two_arg_all : qualIdent IN ALL CELLS two_arg_range; four_arg_any : qualIdent IN ANY CELL four_arg_range; four_arg_all : qualIdent IN ALL CELLS four_arg_range; two_arg_range : '[' expression ',' expression ']' ; four_arg_range : '[' expression ',' expression ',' expression ',' expression ']'; logical_expression : expression AND expression | expression OR expression | NOT term | expression XOR expression ; relational_expression : adjacency_expression | rel_exp; rel_exp : expression '>' expression | expression '<' expression | expression '=' expression | expression NE expression | expression LE expression | expression GE expression ; cellBasedId : notAtted; adjacency_expression : ALL ADJACENT cellBasedId '>' expression | ALL ADJACENT cellBasedId '<' expression | ALL ADJACENT cellBasedId '=' expression | ALL ADJACENT cellBasedId NE expression | ALL ADJACENT cellBasedId GE expression | ALL ADJACENT cellBasedId LE expression | ANY ADJACENT cellBasedId '>' expression | ANY ADJACENT cellBasedId '<' expression | ANY ADJACENT cellBasedId '=' expression | ANY ADJACENT cellBasedId NE expression | ANY ADJACENT cellBasedId GE expression | ANY ADJACENT cellBasedId LE expression ;
Go to the first, previous, next, last section, table of contents.