Conditional Execution

This tutorial allows you to create a conditional execution switch between two models.

Task Description

This tutorial demonstrates how to do the following:

  • Create two simple modules using the calculator node

  • Create a conditional execution to switch between the two models depending on a given condition

  • Perform a sensitivity analysis with the conditional solver chain.

Tutorial Steps

Creating a New Project

  1. Start optiSLang.

  2. Create a new empty project.

Completing Process Integration

  1. Under Modules, expand Systems and Plain systems.

  2. Drag a Parametric System node onto the Scenery pane.

  3. Under Modules, expand Analysis.

  4. Drag a Calculator node onto the Parametric System.

  5. Select the Receive design from parent system and Send design back to parent system check boxes.

  6. Click OK.

  7. Repeat steps 4-6 to add a second calculator to the Parametric System.

  8. Right-click the Calculator node and select Rename from the context menu.

  9. Type Model1 and press Enter.

  10. Right-click the Calculator (1) node and select Rename from the context menu.

  11. Type Model2 and press Enter.

Adding Parameters

  1. Double-click the Parametric System.

  2. On the Parameter tab, right-click the empty pane and select Add parameter from the context menu.

  3. In the number box, enter 3.

  4. Click Add.

  5. In row 1, double-click the Name cell and enter x1.

  6. Double-click the Parameter type cell and select Optimization from the list.

  7. Repeat steps 5 and 6 for the next two parameters, naming them x2 and x3.

  8. Click OK.

Updating Project Settings

  1. From the menu bar, select Project > Settings.

  2. Switch to the Advanced tab.

  3. From the Conditional execution tab visibility list, select show.

  4. Click OK.

Configuring the First Model

  1. Double-click the Model1 node.

  2. Click Add variable.

  3. Double-click the ID cell for the new variable, type y, and press Enter.

  4. Double-click the Expression cell, type x2+0.5*x3, and press Enter.

  5. Click Add variable.

  6. Double-click the ID cell for the new variable, type model, and press Enter.

  7. Double-click the Expression cell, type 1, and press Enter.

  8. Select both variables and drag them to the Responses pane.

  9. Switch to the Conditional Execution tab.

  10. Click Add expression.

  11. Type x1>x2 and press Enter.

  12. To close the dialog box, click OK.

Configuring the Second Model

  1. Double-click the Model2 node.

  2. Click Add variable.

  3. Double-click the ID cell for the new variable, type y, and press Enter.

  4. Double-click the Expression cell, type x1+0.5*x3, and press Enter.

  5. Click Add variable.

  6. Double-click the ID cell for the new variable, type model, and press Enter.

  7. Double-click the Expression cell, type 2, and press Enter.

  8. Select both variables and drag them to the Responses pane.

  9. In the warning dialog box, ensure that Add response with this name is selected and click Continue.

    Both conditional nodes write their results to the same response objects.

  10. Switch to the Conditional Execution tab.

  11. Click Add expression.

  12. Type x1<=x2 and press Enter.

  13. To close the dialog box, click OK.

Now the solver chain consists of two parallel models which will be executed depending on the values of x1 and x2. If a registered response is written by only one node for one design, the design succeeded, but if a response is written by two nodes for the same design, the design will fail.

In this example, the conditions have been chosen so that only one can be true at one time.

Completing the Sensitivity Analysis

  1. From the Wizards pane, drag the Sensitivity wizard to the Parametric System and let it drop.

  2. Run through the wizard, accepting all of the default values.

  3. To close the dialog box, click Finish.

Saving and Running the Project

  1. To save the project, click  .

  2. Browse to the location to save the project and type a project name in the File name field.

  3. Click Save.

  4. To run the project, click  .

    Hovering the mouse over each conditional node shows how many designs have been executed. The skipped designs occur due to the conditions being false.

    In this example, the model response displays which model is used to calculate y for each design.