Creating formulas

In Vissim, in the following use cases, use the integrated formula editor to create a formula:

The formula editor provides the following functions:
Button Description

Add operand (e.g. attribute) button: Open a window with the attributes of the network object type selected in the Object type box and select an attribute as term. The term is added in blue.

 

Symbol Description

Add operator (e.g. +, -, *, /): Select an operator that combines the term with another term. The operator is added in black.

 

Symbol Description

Insert function (e.g. min, max, exp): Open Insert function and select a function for teh formula. The function is added in turquoise.

Possible functions:

Floor (x)

Specifies the greatest integer that is less than or equal to x. At the cursor position FLOOR() is inserted.

Abs (x)

Absolute value of x

Truncate (x)

Truncates the decimal places of x. At the cursor position TRUNCATE() is inserted.

ArcSin (x)

Arc sine of x

ArcCos (x)

Arc cosine of x

ArcTan (x)

Arc tangent of x

Ceil (x)

Specifies the smallest integer that is greater than or equal to x. At the cursor position CEIL() is inserted.

Cosine (x)

Cosine of x

Div (x; y)

Forms the integer quotient of x and y.

Color (a; r; g; b;)

Defines color value. a: Alpha transparency, r: Red, g: Green, b: Blue

Exp (x)

Forms the exponential of x. At the cursor position, EXP() is inserted.

GEH Statistic (x; y)

Calculates the GEH statistics for x and y. At the cursor position, GEH(;) is inserted. The GEH Statistic is a empirical formula widely used in traffic modeling for the analysis of values. The formula is as follows:

where:

M: modeled values

C: counted values

Reciprocal (x)

Corresponds to 1/x. At the cursor position RECIPROCAL() is inserted.

Ln (x)

Forms the natural logarithm of x. At the cursor position, LN() is inserted.

Max (x; y)

Forms the maximum of x and y

Min (x; y)

Forms the minimum of x and y

Modulo (x; y)

x modulo y

Power (x; y)

Corresponds to x^y. At the cursor position, POW(;) is inserted.

Percent (x; y)

Corresponds to 100*x/y. At the cursor position PERCENT() is inserted.

Round (x; p)

Rounds x to p decimal places. p is optional. At the cursor position ROUND(;) is inserted.

Sin (x)

Sine of x

Text to number ("x")

Converts a string into a floating-point number. Enter a period as the decimal separator. The following characters are not valid in the string: spaces at the beginning and end and non-numeric characters, except +, -, e/E. At the cursor position TEXTTONUM() is inserted.

Tan (x)

Tangent of x

If (b; w; f)

Conditional branching. Outputs w if b is true. Outputs f if b is false. At the cursor position IF(;;) is inserted.

Root (x)

Forms the square root of x. At the cursor position, SQRT() is inserted.

Number to text (x)

Converts a floating-point number into a string. At the cursor position NUMTOTEXT() is inserted.

Extract substring ("x", "s", n)

Extracts the "n"th substring from a string "x" using the separator "s". For example, you can extract the number of the second link of a vehicle route link sequence.

 

Symbol Description

Insert TableLookup:Open the Insert TableLookup window to insert a function of the type TableLookup into the formula. Select an attribute value of a network object type and continue to edit it in the formula. The TableLookup function is added in turquoise.

  • Network object type: In the list, click the object type you want to use as the basis of the function. All conditions of the function that follow refer to the object type selected.

In addition to the network object types, you can select other object types, for instance Network settings (NETPARA) that contains a user-defined value. To select another object type, as condition of the TableLookup command, e.g. use the value 1 for TRUE.

  • Variable name: Enter a variable name that starts with a letter. This name is a so-called loop variable. In each loop, it represents another network object of the type iterated over.
  • Insert explaining comments: Inserts an example of a condition and result into the input field that you can overwrite.
 

The TableLookup function entry box must correspond to the following scheme:

TableLookup(<object type> <variable name>;(<condition>);(<result>)

The elements consist of:

TableLookup(<object type: English Name in capital letters> <entered variable name>; (<condition, for example <entered variable name>[<English attribute short name>]=<property>>);(<result, for example <identifier>[<attribute short name>]>))

See (Example of a user-defined attribute)

 

Symbol Description

Insert brackets: Insert opening and closing brackets:

  • Insert around selected part of formula
  • None of the formula is selected: Insert at the position of the cursor
Simulation run can influence formula-based data

If the attributes selected for the formula are based on dynamic data that can change during a simulation run, the values of the user-defined attribute displayed in a results or attribute list can also change during the simulation run.

Editing formulas in fields marked as irrelevant

Irrelevant attributes can, for example, become relevant through COM functions during a simulation run. This is why you may also edit formulas in irrelevant fields.

Insert line break
  • ►  Within a string, insert \\n at the desired position.
  • ►  Outside a character string, press the Enter key at the desired position.
Syntax errors are highlighted in red

Vissim highlights formula syntax errors in red. Below the entry box for the formula, a message is displayed with information on the possible cause of the syntax error.

Behavior regarding successive comparisons in formulas

When you create a formula that is to contain successive comparisons, take into account that in Boolean algebra, they are not associative, but are summarized and evaluated in groups of two:

Example:

1 < 4 < 2 is summarized and evaluated as (1 < 4) < 2:

Where (1 < 4) = true

true = 1

The following applies in the formula:

1 < 2

Different data type in formula and attribute

If the formula results in a number but the target attribute is a string, Vissim will convert the number to a string.