Iterate
Iterate( x0, xi, until, maxIter, warn )
Suppose the definition of Variable X contains a call to Iterate: Iterate initializes X to the value of x0. While stopping condition bstop is False (zero), it evaluates expression xi, and assigns the result to X. Given the optional parameter maxIter, it will stop after maxIter iterations and, if warn is True, issues a warning—unless it has already been stopped by bstop becoming True. If bstop is an array, it only stops when all elements of bstop are true.
Iterate is designed for convergence algorithms where an expression must be recomputed an unknown number of iterations. Iterate (like Dynamic) must be the main expression in a definition— it cannot be nested within another expression. But it may, and usually will, contain nested expressions as some of its parameters. Iterate (again like Dynamic and unlike other functions) may, and usually will, mention the Variable X that it defines within the expressions for x0 and bstop. These expressions may also refer to Variables that depend on X.
If you use Iterate in more than one node in your model, you should be careful that the two functions don't interact adversely. In general, two nodes containing Iterate should never be mutual ancestors of each other. Doing so makes the nesting order ambiguous and can result in inconsistent computations. Likewise, care must be taken to avoid similar ambiguities when using interacting Iterate and Dynamic loops.
Enable comment auto-refresher