Generating multiple scenarios (Decision Optimization)

This tutorial shows you how to generate multiple scenarios from a notebook using randomized data. Generating multiple scenarios lets you test a model by exposing it to a wide range of data.

About this task

The files used in this example are in the DO-samples project. The model concerned is StaffPlanning and the notebook is CopyAndSolveScenarios.

Note: To create and run Optimization models you must associate a deployment space with your experiment. This can be created or selected when you first create a new Decision Optimization experiment: click Create a deployment space, enter a name for your deployment space and click Create. For existing models, you can also create or select a space in the Overview information pane.

Procedure

  1. Download and extract all the DO-samples on to your machine. You can also download just the StaffPlanning.zip file from the Model_Builder subfolder for your product and version, but in this case do not extract it.
  2. Create a project in IBM Cloud Pak for Data. Select Create an empty project, enter a project name and click Create.
  3. In the Overview tab of your project, click Associate a new or existing deployment space. Enter a name for your deployment space and click Associate. A deployment space can only be associated with one project. If you do not associate a deployment space with your project, when you create a model, you are prompted to create a new space or choose an existing space.
  4. On the Assets tab of your project, click New asset.
  5. Select Decision Optimization experiment in the Graphical builders section.
  6. Click Local file in the Create a Decision Optimization experiment window that opens.
  7. Click Add fileDrag and drop files or upload and browse to choose the StaffPlanning.zip file in the Model_Builder folder. Select the relevant product and version subfolder in your downloaded DO-samples.
  8. Choose a deployment space from the drop-down menu (or create one) and click Create.
  9. Click Create.
    A Decision Optimization model is created with the same name as the sample.
  10. Working in Scenario 1 of the StaffPlanning model, you can see that the solution contains tables to identify which resources work which days to meet expected demand.
    If there is no solution displayed, or to rerun the model, click Build model in the sidebar, then click Run to solve the model.

Using random generator to create new scenarios

Procedure

  1. On the Assets tab of your project, click New asset.
  2. Select Jupyter notebook editor in the Code editors section.
  3. Select the From file tab in the New notebook pane that opens.
  4. Click Drag and drop files or upload and browse to choose the CopyAndSolveScenarios notebook from the jupyter folder. Select the relevant product and version subfolder in your downloaded DO-samples.
  5. Click Create Notebook.
    The notebook opens in your project.
  6. Locate the cell containing decision = client.get_model_builder(name="StaffPlanning").
    This cell instructs the notebook to copy Scenario 1 from the StaffPlanning model and use it to generate additional scenarios based on randomized data. If you’ve used another name for your model, replace Staffplanning with the name you chose.
  7. Run the notebook using Cell>Run All.
    The notebook uses the Python random module to generate data for five additional scenarios in the model named StaffPlanning. The new scenarios are named Copy 01 ... Copy 05. The number of scenarios to generate is specified in cell 9, N_SCENARIOS = 5.
  8. Open the StaffPlanning model to compare the solutions of the different scenarios. Click the Scenarios icon to open the Scenario pane and quickly move between scenarios. You can also see all your scenarios at a glance in the Overview pane.
  9. Click Visualization in the navigation pane to compare the different scenarios on the Multi Scenario tab.
    The Demand chart plots the demand for the different periods in the randomly generated scenarios. The KPIs chart plots the total cost across the randomly generated scenarios. The My KPIs chart provides a heat map of costs for the different scenarios along with the mix of temporary and fixed resources for each.

Results

This example shows how easily you can test your model by generating additional scenarios based upon randomized data. Such testing makes it possible to assess whether the model is robust enough to perform effectively in an environment with variable data.