Table of contents

Generating multiple scenarios

Takes you through the staff planning example.

About this task

This topic presents an example that generates 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. The files used in this example are in the DO-samples project. The model concerned is StaffPlanning and the Notebook is CopyAndSolveScenarios.

Procedure

  1. In the navigation pane, select Projects>View all Projects, then click DO-samples.
  2. On the DO-samples project page, click Models in the Assets tab. Locate and open the StaffPlanning model.
    Six scenarios are available with the model, and two data assets are attached to each scenario.
  3. Working in Scenario 1 of the StaffPlanning model, click Run Model in the sidebar, then click Run to solve the model.
    The solution contains four tables to identify which resources work which days to meet expected demand.

Using random generator to create new scenarios

Procedure

  1. On the DO-samples project page, click Assets and locate and open the CopyAndSolveScenarios notebook in the Notebooks section.
  2. The notebook opens in your project.
  3. 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.
  4. 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.
  5. Open the StaffPlanning model to compare the solutions of the different scenarios. Click the Scenario icon Scenarios icon to open the Scenario panel and quickly move between scenarios.
    Scenario panel
  6. Click Dashboard 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.