Scenario Example

This tutorial is a step-by-step guide for building a two-input, scenario addition model. The goal of the tutorial is to use an example to setup a workflow that allows you to save groups of inputs as "scenarios" that can be accessed over and over.

There are three steps to creating a scenario model:

  1. Create the base model you need, without scenario capabilities
  2. Create a workflow for creating and removing scenarios
  3. Assign the input parameters to specific scenarios

Part 1: Create the base model

Step 1.1

Create a New Dashboard.

Step 1.2

Create a New Project. Navigate to your Project Editor.

Step 1.3

Add all of the widgets needed for the model to perform the function you would like it to, independent of scenario saving. For the purposes of this tutorial, we will be creating an addition model that accepts two numerical inputs and generates the sum for users. To do this, search for, then drag-and-drop:

  1. Input widgets: 2 “textinput”, 2 “string to float”
  2. Data processing widget: 1 “addition”
  3. Output widgets: 1 “float to string”, 1 “textoutput”

Step 1.4

Create the data and execution workflow for your addition model by connecting each of the widgets, using the (black) data workflow lines and (green) execution workflow lines at the top and bottom of the widgets.

  1. Use the "next" and "prev" handles to connect each textinput widget to a string to float widget, each string to float widget to the addition widget, addition to float to string, float to string to textoutput.
  2. Connect each of the textinput widget “value” handles to each of the string to float widget “x” handles.
  3. Connect each string to float widget “x float” handles to the addition widget “addend” handles.
  4. Connect the addition widget “sum” handle to the float to string widget “x” handle.
  5. Connect the float to string widget “x_string” handle to the textoutput “value” handle.

Step 1.5

Add each of the yellow widgets (the textinput, button, and textoutput widgets) to the Dashboard you created earlier. To do this:

  1. Right click on each of the widgets.
  2. Select a dashboard under the “Add to Dashboard” dropdown.
  3. Click “Apply Selection.”

Step 1.6

Navigate to your Dashboard. Right-click, enter setup mode and move each of the model components to make the model usable, following the image provided. You should have the two textinput boxes on the left and the box that displays the sum on the right. At this time, you may test the model to make sure that it adds inputs correctly.

Part 2: Create a workflow for creating and removing scenarios

Step 2.1

Return to the Editor and search for the widgets needed on the dashboard for a scenario model. Drag-and-drop to add the button to your Editor.

  1. Dropdown: Stores a list of all the stored scenarios
  2. Text input: Inputs the scenario name
  3. (2) Buttons: Directs the workflow

Rename the scenario model widgets as follows. Place them on the editor the way they are displayed in the picture provided.

  1. Dropdown: "Scenario List"
  2. Text input: "Scenario Name"
  3. (2) Buttons: "Save Scenario" and "Remove Scenario"

Change the values of the Buttons by right clicking on the "value" handle of the buttons, editing the text, and hitting "Enter" Change:

  1. Save Scenario: enter "Add Scenario"
  2. Remove Scenario: enter "Remove Scenario"


Step 2.2

Add the following widgets that are needed to save new scenarios:

  1. (2) Get Value: Gets the scenario names from the scenario data store
  2. Add Element: Appends the new scenario name value to the value obtained by ‘Get Value’ module
  3. Set Value: Stores the comma separated value into the scenario data store
  4. String trim: Trims the scenario name in case there are empty white spaces at the start or the end of the scenario name

Rename the widgets you just added as follows:

  1. Add Element: "Add Scenario to List"
  2. Set Value: "Save Scenario List"

Create the data workflow for saving scenarios by connecting each of the widgets, using the (green) execution workflow lines at the top of the widgets.

  1. Connect "Save Scenario" to "Get Value" to "string trim" to "Add Scenario to List" to "Save Scenario List" to "Get Value" to "Scenario List"

Create the data workflow for saving scenarios by connecting each of the widgets, using the (black) data workflow lines at the bottom of the widgets.

  1. Connect "Scenario Name, value" to "string trim, value"
  2. Connect "Scenario Name, value" to to "Scenario List, value"
  3. Connect "Get Value, value" to "Scenario List, list"
  4. Connect "string trim, trim" to "Add Scenario to List, element"
  5. Connect "Add Scenario to List, element" to "Get Value, value"
  6. Connect "Add Scenario to List, value" to "Save Scenario List, value"

Step 2.3

Add the following widgets that are needed to remove scenarios:

  1. Get Value: Gets the scenario names from the scenario data store
  2. Remove Element: Removes the current element i.e., scenario from the value obtained by ‘Get Value’ module
  3. Set Value: Updates the scenario data store

Rename the widgets you just added as follows:

  1. Set Value: "Save Scenario List"

Create the data workflow for saving scenarios by connecting each of the widgets, using the (green) execution workflow lines at the top of the widgets.

  1. Connect "Save Scenario" to "Get Value" to "Remove Element" to "Save Scenario List" to "Get Value" to "Scenario List"

Create the data workflow for saving scenarios by connecting each of the widgets, using the (black) data workflow lines at the bottom of the widgets.

  1. Connect "Get Value, value" to "Scenario List, list"
  2. Connect "Add Scenario to List, element" to "Get Value, value"
  3. Connect "Add Scenario to List, value" to "Save Scenario List, value"

Step 2.4

Enter an argument for the "user" and "id" parameters of each of the three
"Get Value" widgets. This is done by right-clicking the parameter and then entering a string. For the purposes of this demo, use these arguments:

  1. user: demo
  2. id: scenario_demo

Part 3: Assign the input parameters to specific scenarios

Step 3.1

Return to the Editor and search for the widgets needed to assign input parameters. Drag-and-drop to add the button to your Editor.

  1. (2) add scenario value: Takes in the parameter value for a particular scenario and stores it in the data store
  2. (2) get scenario value: Used to load the parameter values after the scenario is selected from the scenario list dropdown

Step 3.2

Enter an argument for the "key" and "parameter" parameters of each of the two "get scenario value" widgets AND each of the two "add scenario value" widgets. This is done by right-clicking the parameter and then entering a string. For the purposes of this demo, use these arguments:

  1. key: add_demo
  2. parameter: addend_1 OR addend_2 (determine which textinput widget is addend 1 and which textinput is addend 2, and then connect the appropriate "get scenario value" and "add scenario value" widgets with the correct parameters)

Step 3.3

Connect the "get scenario value" widgets to the addition model, save scenario mode, and remove scenario model using the handles on the tops and bottoms of the widgets. You may need to remove the widgets from the "Scenario Model" dashboard to access the bottom handles and then readd them to the dashboard once you have made your connections.

  1. Connect the green data handles on the top of the widgets as follows:
    • Connect each "get scenario value" to the the "Scenario List" widget
    • Connect each "textinput" widget to a seperate "get scenario value" widget
  2. Connect the black data handles on the bottom of the widgets as follows:
    • Connect each "scenario" handle on the "get scenario value" widget to the to the "value" handle on the "Scenario List" widget
    • Connect each "value" handle on the "get scenario value" widget to a left-hand "value" handle on the corresponding "textinput" widget using the same pairings you used in the earlier step

Step 3.4

Connect the "add scenario value" widgets to the addition model, save scenario mode, and remove scenario model using the handles on the tops and bottoms of the widgets. You may need to remove the widgets from the "Scenario Model" dashboard to access the bottom handles and then readd them to the dashboard once you have made your connections.

  1. Connect the green data handles on the top of the widgets as follows:
    • Connect each "add scenario value" to the "string trim" widget
  2. Connect the black data handles on the bottom of the widgets as follows:
    • Connect each "scenario" handle on each "add scenario value" widget to the "trim" handle on the "string trim" widget
    • Connect each "value" handle on each "add scenario value" widget to a right-hand "value" handle on the corresponding "textinput" widget using the same pairings you used earlier

Step 3.4

Navigate to your Dashboard. Right-click, enter setup mode and move each of the model components to make the model usable, following the image provided. You should have the a new textinput box that allows you to enter a name for any new scenarios you create, a dropdown where the list of scenarios will be stored, a "add scenario" button, a "remove scenario" button. At this time, you may test the model to make sure that it adds inputs correctly.

The Final Result:

You now have an scenario model where you can save input groups. To use the scenario model, simply follow the steps below:

To Create New Scenarios

  1. Enter your desired values into the addition model (addend 1 and addend 2), and allow the model to run.
  2. Enter your desired scenario name into the text box for scenario names.
  3. Press the "Add Scenario" button.

To Access Scenarios

  1. Select your desired scenario from the scenario dropdown list. The values attributed to the scenario should populate in the addition model.

To Delete Scenarios

  1. Select the desired scenario from the scenario dropdown list.
  2. Press the "Remove Scenario" button.

The Final Dashboard:

The Final Editor: