The official documentation for the Nextmv Python SDKs has been moved to this site. This page is not being updated anymore.
Scenario tests are used to compare the output from one or more scenarios. A scenario is composed of:
- An instance, to reference the underlying executable code.
- Input data, to provide the scenario with the necessary information to execute. Data can be obtained from input sets, managed inputs, or new data.
- Configurations, to define a variation of options/parameters to be used in the scenario.
You can use the cloud.Scenario
class to set up a scenario. Consider the following examples for setting up a scenario:
scenario_1
. Demonstrates how to set up a scenario using an input set. The scenario input type isINPUT_SET
, and the input set ID isinput-set-1
. An example instance with IDv0.0.1
is used.scenario_2
. Demonstrates how to set up a scenario using managed inputs. The scenario input type isINPUT
, and the input IDs areinput-1
andinput-2
. An example instance with IDv0.0.2
is used.scenario_3
. Demonstrates how to set up a scenario using new data. The scenario input type isNEW
, and the input data is a list of dictionaries containing the new data. An example instance with IDv0.0.3
is used.
Note that for the three scenarios, the configuration is the same. The configuration is a list of ScenarioConfiguration
objects. A different set of runs will be created from the cross-product of the configuration values. In the examples, a total of 4 runs will be created for each scenario, with the following options:
solve.duration="1s"
andsolve.iterations="10"
solve.duration="1s"
andsolve.iterations="20"
solve.duration="2s"
andsolve.iterations="10"
solve.duration="2s"
andsolve.iterations="20"
Create a scenario test
You can create a scenario test using the Application.create_scenario_test
method.
Please note the following from the example above:
- The
id
,name
andscenarios
parameters are required. - The
description
is optional. - The
repetitions
parameter is optional and defaults to 0. It defines how many times should the scenario test be repeated. A value of 0 means that the scenario test will not be repeated, thus, the scenario test will be executed once. A value of 1 means that the scenario test will be repeated once, thus, the scenario test will be executed twice. A value of 2 means that 3 scenario tests will be executed, and so on. - You can define an optional
scenario_id
for each scenario. In the example, the ID is not defined for any of the scenarios, so the ID will be generated automatically by enumerating the scenarios (scenario-1
,scenario-2
,scenario-3
). Note that every scenario must have a unique ID.
Get a scenario test
Scenario tests are designed to be visualized from the Console web interface. Go to the app, Experiments
> Scenario
tab.
We highly recommend using the Console for creating and managing scenario tests. However, you can also use the Python SDK to get the results of a scenario test with the Application.scenario_test
method.
To list all scenario tests in the application, you can use the Application.list_scenario_tests
method.
Manage a scenario test
You can update a scenario test using the Application.update_scenario_test
method.
You may also delete a scenario test using the Application.delete_scenario_test
method.