This section describes the medini expression language (MEL) used for mathematical formulas in medini analyze. The language is the basis of the failure rate catalogs, scaling expression, and custom probability distributions in fault tree analysis of the tool.
Any expression consists of variables, functions, operators, and/or numeric literals. An expression returns always a numeric result and can be build upon the following syntax:
Numbers are written in scientific format with optional exponent:
[-]<digits>.<digits> [e<exponent>]
Variable names must start with an alphabetic character, underscore '_' or '$' symbol and follow the format:
('A'..'Z' | 'a'..'z' | '_' | '$')('A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '$')*
Arithmetic operators are supported with the usual precedence rules and bracketing, i.e.:
+,-,*, /, and % (for modulo)
Predefined functions are supported: exp (exponential), pow (power), sqrt (square root), ln (natural logarithm), log10 (logarithm to base 10), sin (sinus), cos (cosinus), tan (tangens), asin (arcus sinus), acos (arcus cosinus), atan (arcus tangens), sinh (sinus hyperbolicus), cosh (cosinus hyperbolicus), tanh (sinus hyperbolicus), and abs (absolute value).
Summation is supported as function with three arguments:
sum( <lower>, <upper>, <expr> )
where <lower>/<upper> are expressions for the lower and upper bounds of the iteration and <expr> is the summation expression (result is summed). A variable with name i is provided during summation to access the current index, i.e. lower/upper terms must evaluate to positive integer values so that i ranges in the interval [<lower>,<upper>]), similar to a looping variable in a programming language.
Conditional expressions are support by means of if-then-else as function with three arguments:
ifThenElse( <condition>, <if-expr>, <else-expr>)
where <condition> is evaluated first. If the value is not equal zero, then the <if-expr> will be evaluated and returned, otherwise the <else-expr>. The condition can be build with the relational operators available as functions: less, lessEq, eq, greaterEq, and greater (all having two parameters).
Complex expressions can be split into separate equations using the ";" (semi-colon) symbol. For example:
p = 1.0 * exp(-1 * lambda);
lambda = 1e-9;
Note that the order of equations does not matter or imply any sequential dependencies. That means, all equations can be arbitrarily listed in any order since they are referring to each other via variable names only. It is important that there are no cyclic references of the form "A = B; B = A" - these will lead to errors in the evaluation.
Functions can be defined and called as required with the following syntax:
<name> (<parameter list>) = <expr>;
So for example a definition and a function call would look like:
square(a, x) = a * x*x;
y = square(4, 5);
In this example y will evaluate to 100.
Array variables are supported (i.e. vectors). They can be defined and accessed using the typical squared bracket notation:
<variable> = [ <expression list> ];
Arrays are accessed with an index which starts at 1. Hence, a simple example of an array would look like:
fibo = [1, 1, 2, 3, fibo[3]+fibo[4], fibo[4]+fibo[5]];
x = fibo[2*3];
In this example the first six Fibonacci numbers are recursively defined and stored in array fibo, thus x evaluates to 8. If an array is accessed at an invalid index (e.g. zero), the evaluation fails.
Note that since V4.0 the former iterate statement is no longer supported. See also Migration from v3.4 to v4.0 for details.