This section gives simple examples of how to use the different, mathematical and logical, functions when formulating objectives, custom outpus, constraints or settings of the Property Panel. The image to the right lists all functions that can be used. All functions require at least one argument. An argument is a real value represented by an input or an output from the optimization problem or just a real number. However the real value of the argument could also be the result of a function or a mathematical expression, see the table in the next section for examples or the documentation in the used library here.
Examples
The table below shows examples of how the different functions should be used in formulas representing objectives or constraints. The table contains examples of all the functions listed in the image above and each cell contains three rows;
- The name of the function.
- An example of how to write the function (in blue) and possibly some note about the function.
- Note describing the function or specifying allowed values of the argument(-s) of the function.
The sine function. sin(4.2) |
The hyperbolic sine function. sinh(3*3.1) |
The log2 function. log2(30+5) The logarithm to the base 2, with arg ∈ (0,∞). |
The sign function. sign(8.2-9) -1 ∀ arg ∈ (-∞,0) and 1 ∀ arg ∈ [0,∞) |
The sum function. sum(3*5,15.1,9.9,0) Sums all arguments. |
The cos function. cos(3.14159) |
The hyperbolic cos function. cosh(3.1/3) |
The log10 function. log10(300/5) The logarithm to the base 10, with arg ∈ (0,∞). |
The rint function. rint(5.5) Rounds to nearest integer. |
The avg function. avg(3*5,15.1,9.9,0) Calculates the mean of all arguments. |
The tan function. tan(56) |
The hyperbolic tan function. tanh(13.1) |
The log function. log(300*5) The logarithm to the base 10, with arg ∈ (0,∞). |
The abs function. abs(-5.3) Returns the absolute value. |
The index function index("variable_name",variable_name) Returns the index of the current value of the MCS-variable named 'variable_name'. |
The arcos sine function. asin(0.5) arg ∈ [-π/2,π/2] |
The hyperbolic arcos sine function. asinh(4.1) |
The ln function. ln(30*5) The logarithm to the base e (2.71828...), with arg ∈ (0,∞). |
The if function (?:), by c++-style syntax 'condition ? value_if_true : value_if_false'. Throughput>250 ? 10000 * Throughput : 0 Note: First argument is a logical expression whereas the following two are reals. |
The num_values function num_values("variable_name") Returns the number of values in the MCS-variable named 'variable_name'. |
The arcos cosine function. acos(0.6) arg ∈ [0,π] |
The hyperbolic arcos cosine function. acosh(3.1/3) arg ∈ [1,∞) |
The exp function. exp(3/5) e raised to the power of the argument. |
The min function. min(-5,-2*4,3,9.9,20.1) Returns the argument with the smallest value. |
|
The arcos tangens function. atan(3.4) |
The hyperbolic arcos tangens function. atanh(2.9/3) arg ∈ (-1,1) |
The sqrt function. sqrt(500/5) Returns the square root of the argument, with arg ∈ [0,∞). |
The max function. max(-5,-2*4,3,9.9,20.1) Returns the argument with the largest value. |