Standard Mangrove operators
map
Use map as a lookup node in nexus_nodes_attributes: the child gives the lookup key, and the map node resolves that key through a resource parameter table.
Complex expressions
Mangrove uses the Keisan expression language to evaluate mathematical and logical expressions within model nodes. This allows you to write complex formulas directly in theoperator field of a node.
Basic Syntax
Expressions are written as strings in theoperator field of a calculated node. Child node values are referenced by their slugified names (lowercase, underscores instead of spaces).
Notable Operators
Standard operators supported in the equations are listed here. These include:- Arithmetic operators
- Comparison operators
- Logical operators (e.g.
&&) - Built-in mathematical functions (e.g. the below list)
abs(x): Absolute value
Example:abs(-5)→5sqrt(x): Square root
Example:sqrt(16)→4exp(x): Exponential (e^x)
Example:exp(1)→2.718...log(x): Natural logarithm
Example:log(10)→2.302...sin(x),cos(x),tan(x): Trigonometric functions
Example:sin(0)→0round(x): Rounds a value. Useround(x)for nearest integer orround(x, n)for n decimal places.
Example:round(10/2, 2)→5.00
- Conditional logic
Example:
if(condition, value_if_true, value_if_false) - List functions that work with arrays of values
max(list)— Maximum value in a listmin(list)— Minimum value in a listrange(n)— Generate list[0, 1, ..., n-1]range(start, end)— Generate list from start to end-1round— Rounds a value. Useround(x)for nearest integer orround(x, n)for n decimal places.map— Maps a value from a linked libraryduration— Converts the time range of the incoming datapoint into a durationdata_point_proportion— Extracts the allocation proportion from an allocated node
When to Use Mangrove Operators vs Keisan Expressions
| Use Mangrove operators when… | Use Keisan expressions when… |
|---|---|
| Simple arithmetic on all children | Complex multi-step formulas |
| Standard aggregations (sum, avg, max) | Conditional logic (if/else) |
| Clearer, more readable models | Custom rounding or transformations |
Best Practices
- Keep expressions simple — Break complex calculations into multiple nodes rather than one long expression. This improves readability and makes debugging easier.
- Use explicit unit conversions — Create separate nodes for unit conversions rather than embedding them in expressions.
- Name child nodes clearly — Since expressions reference child nodes by slugified name, use descriptive names that make the expression readable.
- Test your expressions — Use the Model Editor’s test functionality to verify calculations with sample inputs before saving.
Further Reading
- Keisan Documentation — Complete reference for the Keisan expression language