Subiterations
Subiterations provide a way of performing iterations for a group of nodes and then to return the output of those iterations.
They are structured similarly to components in that they have clearly defined boundaries using subiterationstart
and subiterationend
nodes.
The only difference with components is that it is not necessary to pass in nodegroups.
Function | Notes |
---|---|
subiterationstart(iterations) |
Defines the starting point of the sub iteration. The iterations variable is the number of iterations to run the group of nodes within the start and end boundaries |
subiterationinput([subiteration_start_node], "input_node") |
Gets the input node that has been fed into the subiterationstart() node for use within the subiteration loop. |
subiterationend([subiteration_start_node], [exit condition]) |
Defines the end point of the subiteration. The exit condition is optional and provides the ability to exit the subiteration early (e.g. if an iteration converges to a result). This can be used with the new isclose() function rather than == as an exit condition may be close enough to exit (i.e. the 40th decimal point might be different.) |
subiterationresult([subiteration_end_node], node_index_or_name) |
Gets the result feeding into the subiterationend() node. This can be by index (ordered by x and y coordinates) or by name. |
subiterationarrayresult([subiteration_end_node], node_index_or_name) |
This is the same as subiterationresult() , however rather than returning the last iterated value, this will return an array of the iterated values. |
subiterationcurrent() |
Returns the current iteration within an iteration loop |
The user interface in Akumen cannot display iterations as node values.
Therefore, it only displays the values as if there were no iterations (similar to components that display only the first nodegroup).
Stepping through time using the time slider DOES NOT step through the iterations, it steps through the time periods as if there were no iterations at all.
The iterations occur under the hood and are only exposed by the suberationeresult()
calculation.
PriorValue nodes are used widely in Akumen to be able to fetch the value of a calculation from the previous time period.
The priovalue calculation has been improved to detect when it is within an iteration, and can be used to fetch the results of a calculation from a previous iteration.
Used in combination with isclose()
, you can effectively check the last value compared to the current value to find convergence based on a boolean condition you define within the subiterationend()
node.
The above diagram is a simple example of a subiteration, with two inputs going into the subiteration. The start node shows that 20 iterations have been defined. The end node shows that there was an exit condition defined, and that it exited after 3 iterations. The two result nodes fetch the same calculated value, one returns the last value, the second returns an array of the 3 iteration values for the same result node.