Language Reference 3: Difference between revisions
| Line 278: | Line 278: | ||
==ROUND== | ==ROUND== | ||
(Expr) expression value rounded to the nearest integer[[Model Builder's Guide Chapter 9#Continuous Functions (Arithmetic Functions)]] | (Expr) expression value rounded to the nearest integer[[Model Builder's Guide Chapter 9#Continuous Functions (Arithmetic Functions)]] | ||
Fei: | |||
fei feifeifei | |||
==SEED()== | ==SEED()== | ||
Revision as of 22:01, 11 October 2006
ONE
return 1.0
- Number return value of the number specified
<Constant> return value of a named constant <Constant>[Expr] return value of a named vector constant <Constant>[Expr, Expr] return value of a named array constant <Macro>[Expr] return value of expression at specified index in macro
(Expr, Expr) draw a value from a normal distribution, where the first expression specifies the mean and the second specifies the standard deviation
(Expr, Expr, Expr) draw a value from a skewed normal distribution, where the first expression specifies the mode and the second and third specify the standard deviations to the left and right of the mode (Expr, Expr) draw a value from a log normal distribution, where the first expression specifies the mean and the second specifies the standard deviation of the underlying normal distribution
(Expr, Expr) draw a value from a Weibull distribution, where the first expression specifies the beta and the second specifies alpha (Note:terminology varies between sources. The version here is equivalent to that in Excel, with reversal of parameters).
OR
DESCRIPTION: A Boolean function operator that returns TRUE(1) if value of at least one expression is TRUE(1) and FALSE(0) otherwise.
USAGE:
x=Expr OR Expr
REQUIRED ARGUMENTS: Expr is any expression that evaluates to single numeric value
VALUE: Either TRUE(1) or FALSE(0)
SEE ALSO: Model Builder's Guide Chapter 9#Composite Functions
Example 1:
x=(2*8==16) OR (2>5)(TRUE) =1
Example 2:
x=(2*8!=4*4) OR (2>5) (FALSE) =0
<figure out an end example indicator. For example, ***>
SAMPLE MODELS: <links to sample models where this function is used>
OVER INDEX SEQUENCE
(Expr, Expr) defines linear sequence of location indices. DECISION Expr If there is a decision expression, then only those cells for which this expression returns TRUE will be included. The system variable Index holds the value of the index at each value in the sequence
Over region expressions are very frequently used to visit all cells in a landscape that meet some condition (e.g. to compute the size of the forest at initiation). Model Builder's Guide Chapter 9#Region Functions OVER RegionFunction Apply a set of sub-expressions at all spatial
Expression locations specified by a region function
: ENDFN Model Builder's Guide Chapter 9#Region Functions AT LOCATION #Expr Apply a set of state-changes at a specified
Expression location
: ENDFN Model Builder's Guide Chapter 9#Region Functions
Matrix assignment is indicated using “[=]” instead of “=”. The proper dimensions of the component arrays must be met.
Variable [=] Variable assign variable of same dimension, or a single value to all entries Variable [=] Variable + Variable sum variables of same dimension (or with a constant) Variable [=] Variable - Variable subtract variables of same dimension (or with a constant) Variable [=] Variable * Variable matrix or scalar multiplication.
Variable [=] TRANSPOSE(Variable) matrix transposition Variable [=] Variable^-1 invert a matrix Variable = SUM(Variable) sum all entries in a matrix Variable [=] SUM ROWS (Variable) sum all rows of a matrix (result has one value per column) Variable [=] SUM COLS(Variable) sum all columns of a matrix
Variables [=] SORT(Variable, Expr) sort rows of an input matrix where rank is given by Expr. The system variable “Index” can appear in the expression and will take on the range of indices in the input array. The resulting sorted matrix will be assigned.
Variable [=] MPM_MULT(Variable, Variable) Performs a “matrix population model” (MPM) integer-based multiplication. Assumes that first matrix is two-dimensional and that second is a vector. The result is two-dimensional, where entries above diagonal represent "offspring", entries on the diagonal represent "survivors" and entries below the diagonal represent "succeeders"
Variable [=] CONTAG(Variable, Variable) Creates a “temporal contagion” matrix. Given probabilities (first parameter) for a set of states and a two-dimensional contagion array (values –1 to 1 indicating affinity), generates a matrix where each row is a prob. dist. For transitions given the row value, and the overall target dist. will be met. Model Builder's Guide Chapter 9#Matrix Functions
PAUSE
Halts the simulation and displays a dialog box to which the user must respond to continueModel Builder's Guide Chapter 9#Control Expressions
PAUSE IF
Expr If the expression evaluates to TRUE, halts the simulation and displays a dialog box to which the user must respond to continueModel Builder's Guide Chapter 9#Control Expressions
PAUSE
(#Value) Pauses the simulation for the specified number of milliseconds and then continuesModel Builder's Guide Chapter 9#Control Expressions
PAUSE (#Value)IF
Expr If the expression evaluates to TRUE, Pauses the simulation for the specified number of milliseconds and then continuesModel Builder's Guide Chapter 9#Control Expressions
SKEWED NORMAL CDF
(Expr, Expr, Expr, Expr) skewed normal cumulative density function, where the first expression specifies the value, the second is the mode, and the third and fourth are the left and right standard deviations Model Builder's Guide Chapter 9#Probability Density and Cumulative Density Functions
SKEWED NORMAL PDF
(Expr, Expr, Expr, Expr) skewed normal probability density function, where the first expression specifies the value, the second is the mode and the third and fourth are the standard deviations to the left and right of the mode. Model Builder's Guide Chapter 9#Probability Density and Cumulative Density Functions
SKEWED NORMAL TEMPORAL PDF
(Expr, Expr, Expr, Expr) temporal skewed normal probability density function Model Builder's Guide Chapter 9#Probability Density and Cumulative Density Functions
RECOMPUTE
Only valid in consequent expressions of ProbInit and also when ProbInit recompute flag has been set. Causes prob. surface to be recomputed before next selection Model Builder's Guide Chapter 9#Control Expressions
REGION CENTRED
(Expr, Expr [,DistanceType][,WRAPPED]) DECISION Expr defines a region centred on the current cell. If there is a decision expression, then only those cells for which this expression returns TRUE will be included.
REGION COST SURFACE
(EndLocation, MaxCost, CostSurface) DECISION Expr COST ExprModel Builder's Guide Chapter 9#Region Functions
REGION COST SURFACE
(EndLocation, MaxCost, CostSurface, LeastCostNeighbs, AnchorLoc)
DECISION Expr
COST Expr
Defines a region surrounding a cell with cumulative costs less than MaxCost. Stops growing when EndLocation is reached or all costs are greater than MaxCost. Second form also records gradient and anchor location layers. The CostSurface layer records the cumulative cost from the cost function Model Builder's Guide Chapter 9#Region Functions
REGION COST SURFACE
(EndLocation, MaxCost, CostSurface) DECISION Expr COST ExprModel Builder's Guide Chapter 9#Region Functions
REGION COST SURFACE
(EndLocation, MaxCost, CostSurface, LeastCostNeighbs, AnchorLoc)
DECISION Expr
COST Expr
Defines a region surrounding a cell with cumulative costs less than MaxCost. Stops growing when EndLocation is reached or all costs are greater than MaxCost. Second form also records gradient and anchor location layers. The CostSurface layer records the cumulative cost from the cost function Model Builder's Guide Chapter 9#Region Functions
REGION LEAST COST PATH
(StartLocation, EndLocation) DECISION Expr COST ExprModel Builder's Guide Chapter 9#Region Functions ==REGION LEAST COST PATH==(StartLocation, EndLocation, LeastCostNeighbs) DECISION ExprModel Builder's Guide Chapter 9#Region Functions ==REGION LEAST COST PATH==(StartLocation, EndLocation, LeastCostNeighbs, AnchorLoc) DECISION Expr Defines a region with cells that approximate the least-cost path between two cells. The first generates the cost function internally. The latter two use input information from a pre-computed cost surface region. Providing both the gradient and anchor location layers provides the most accurate approximation.
Iteration is a common aspect of models (even if it is very procedural). Most programming languages offer a “for-loop” of some kind. SELES presently provides “over index sequence” expressions as a slightly more declarative (although also more cumbersome) expression for iterating. While-loops can also be used. Model Builder's Guide Chapter 9#Region Functions
REGION LOCATION
(Expr) DECISION Expr
defines the region consisting of a of a single
location index. If there is a decision
expression, then only those cells for which
this expression returns TRUE will be
included.
REGION LOCATION LIST
(Number+) DECISION Expr
defines the region consisting of a set of a set
of known location indices. If there is a
decision expression, then only those cells for
which this expression returns TRUE will be
included.
REGION LOCATION LIST
(X,n) defines the region consisting of a set of n location indices stored in one-dimensional X.
REGION RECT
(Expr, Expr, Expr, Expr) defines a rectangular region. If there is a DECISION Expr decision expression defined, then only those cells for which this expression returns TRUE will be included Model Builder's Guide Chapter 9#Region Functions
==REGION VECTOR== (StartLocation, EndLocation) defines region consisting of cells along an
REGION WHOLE MAP
DECISION Expr
defines the region consisting of the entire
landscape. If there is a decision expression,
then only those cells for which this expression returns TRUE will be included. Model Builder's Guide Chapter 9#Region Functions
RESIZE
(Variable, Expr) Changes size (number of entries) in a global variable. Values are not maintained. Useful for when size is not known prior to simulation. Model Builder's Guide Chapter 9#Control Expressions
RESPONSE
(Expr, #A, #B, #C) two-sided version of a standard response function for the value X of the first expression: if (X < A) return e^(-(X-A)^2/(2*(C^2)) else if (X > B) return e^(-(X-B)^2/(2*(C^2)) else return 1 Model Builder's Guide Chapter 9#Continuous Functions (Miscellaneous)
ROUND
(Expr) expression value rounded to the nearest integerModel Builder's Guide Chapter 9#Continuous Functions (Arithmetic Functions)
Fei:
fei feifeifei
SEED()
Gets the random number seedModel Builder's Guide Chapter 9#Control Expressions
SEED
(Expr) Sets the random number seed. Value returned is next seed.Model Builder's Guide Chapter 9#Control Expressions
SETAT
DESCRIPTION: A Bit-Vector function that sets the value specified by the expression, at the positions in PositionList to: FALSE(0) if Type is 0, TRUE(1) if Type is 1, and flip the bits if Type=2.
USAGE:
(Expr, PositionList, #Type)
REQUIRED ARGUMENTS: Expr is any expression that evaluates to single numeric value PositionList is a semi-colon separated sequence of integer or ranges (lower-upper) indicating positions in the integer (0-31).
VALUE: Negates the expression Boolean value
SEE ALSO: Model Builder's Guide Chapter 9#Bit-Vector Functions
Example 1:
The PositionList 1;4-6;27 indicates bits at positions 1,4,5,6 and 27.
<figure out an end example indicator. For example, ***>
SAMPLE MODELS: <links to sample models where this function is used>
SETAT
(Expr, PositionList,#Type,#Prob) Same as above, except each position is set with probability #Prob Model Builder's Guide Chapter 9#Bit-Vector Functions
SELECTAT
(Expr, PositionList) FALSE(0) if none of the bits in PositionList are set in the specified expression value and TRUE(1) otherwise Model Builder's Guide Chapter 9#Bit-Vector Functions
SHIFT LEFT
(Expr, Expr) Shifts value of first expression to the left by number of bits specified by second expressionModel Builder's Guide Chapter 9#Bit-Vector Functions
SHIFT RIGHT
(Expr, Expr) Shifts value of first expression to the right by number of bits specified by second expressionModel Builder's Guide Chapter 9#Bit-Vector Functions
SIN
(Expr) interpret the value of the expression as an angle theta in degrees, and return sin(theta) Model Builder's Guide Chapter 9#Continuous Functions (Trigonometric Functions)
SUM
DESCRIPTION: Returns the number that is the sum of all the expressions.
USAGE:
x=SUM
Expr
...
ENDFN
REQUIRED ARGUMENTS: Expr is any expression that evaluates to single numeric value.
VALUE: the sum of all the arguments.
SEE ALSO: <a link to the composite functions section of seles modellers guide>
EXAMPLES: <add carriage return here> Example 1:
y = 3
x = SUM
y
y+2
5
ENDFN
<figure out an end example indicator. For example, ***>
SAMPLE MODELS: <links to sample models where this function is used> Model Builder's Guide Chapter 9#Composite Functions
DIVIDE successive division of the sub-expressions
Model Builder's Guide Chapter 9#Composite Functions
STRICT ORDERED
same as LESS THAN Model Builder's Guide Chapter 9#Composite Functions
TAN
DESCRIPTION: The tan function operator
USAGE:
x=TAN(Expr)
REQUIRED ARGUMENTS: Expr is any expression that evaluates to single numeric value.
VALUE: Interpret the value of the expression as an angle theta in degrees, and return cos(theta)
SEE ALSO: <a link to the composite functions section of seles modellers guide>
Example 1:
x=TAN(90) =-286411217403671.25
<figure out an end example indicator. For example, ***>
SAMPLE MODELS: <links to sample models where this function is used> Model Builder's Guide Chapter 9#Composite Functions
UNIFORM
(Expr, Expr) draw a value from a uniform distribution, where the first expression determines the minimum value and the second determines the maximum
UNIFORM TEMPORAL PDF
(Expr, Expr, Expr) temporal uniform probability density expression Model Builder's Guide Chapter 9#Probability Density and Cumulative Density Functions
<Variable> value of an independent variable <Variable>[Expr] value of a vector global variable <Variable>[Expr, Expr] value of an array global variable Model Builder's Guide Chapter 9#Continuous Functions (Arithmetic Functions)
(Expr) value of the expression Expr + Expr sum of two expressions Expr - Expr value of the first expression minus the value of the second expression Expr * Expr product of two expressions Expr / Expr value of the first expression divided by value of the second expression Expr ^ Expr value of the first expression to the power of the value of the second expression. An nth root can be computed with1/n as the power. | Expr | absolute value of the expression
WAIT UNTIL
Expr Suspend execution until the expression returns TRUE (1). This is intended for controlling communication and synchronization with an external application. Model Builder's Guide Chapter 9#Control Expressions
WHILE
Expr While loop: process sub-expressions denoted by
… “…” while the expression evaluates to TRUE
ENDFN Model Builder's Guide Chapter 9#Control Expressions
ZERO
return 0.0