While Loop

The while loop control flow statement is widely known in computer programming languages. The while loop system in optiSLang allows for a controlled and iterative execution of the sub-workflow, until a defined Boolean condition is met. The system generates one design per iteration and stops if either of the defined conditions is reached:

  • Maximum number of iterations

  • User defined Stopping criterion

Setup

Start Designs

By default, the While Loop system starts from the reference design. You can define starting designs manually in the Start designs tab. When using manually defined starting designs, they are updated one by one. The while loop can stop before all starting designs are updated, when one of the starting design reaches the stopping criterion.

Next Design Values

The generation of designs is user-defined. At the N-th iteration, you must provide the input parameter values to use at the (N+1)-th iteration. For a given input parameter Xi, define the associated variable Xi_next in the Criteria table located on the Criteria tab. At the (N+1)-th iteration, Xi will take the value of Xi_next at the N-th iteration. For any input parameter, the next design value must respect the definition of the input parameter. If it does not, the algorithm uses the closest allowed value, and returns a warning message.

Stopping Criterion

You can define a stopping criterion to reach. This criterion can be an objective, a constraint, or a variable (numerical or Boolean) defined in the Criteria table located on the Criteria tab. You can only specify one stopping criterion. If you need to specify several conditions, you can combine them into one by using Boolean operators: && (=and), || (=or).


Note:  You can use the calculator to define the criteria expression.


Examples

An example of defining variables:

A first simple example where While Loop can be used to run a script with different reference designs and can be stopped when a user defined stopping criterion is reached.

An advanced example where While Loop runs a NLPQL optimizations with a different reference design at every iteration. NLPQL returns the objective value of its best design as the stopping criterion. While Loop stops when the maximum number of iterations is reached or when the stopping criterion is reached.

Node Settings

To access the options shown in the following table, double-click the While Loop system on the Scenery pane and switch to the Settings tab.

OptionDescriptionDefault
Suffix of next iteration parameterThe suffix string used for the input parameters mapping (Xi will take the Xi_next value for the next design)_next
Maximum number of iterationsMaximum number of iterations to compute before stopping.150
Stopping criterionStopping condition to reach. Defined by a criterion, an operator (<,>,= ), and a threshold or a target value.None
Additional Options

To access the options shown in the following table, in any tab, click Show additional options.

OptionDescription
Designs in parallel

When selected, allows you to set how many designs are processed in parallel.

Auto-save behavior

Select one of the following options:

  • No auto-save

  • Actor execution finished

  • Every n-th finished design (then select the number of designs from the text field)

The project, including the database, is auto-saved (depending on defined interval) after calculating this node/system (either when the calculation succeeds or fails).

By default, all parametric and algorithm systems have Every nth finished design 1 design(s) selected, all other nodes have No auto-save selected.