Defining Scenarios
Scenarios are situations where your agent needs to behave differently to succeed.
Here are some examples of scenarios:
Agent | Scenarios |
---|---|
Drone Control | windy, long distance from charger, low battery level |
Autonomous Driving | city, highway, high traffic |
Cybersecurity Network Optimization | normal traffic, usage spike from promotion, cyber attack |
Process Control | process startup, steady-state, process shutdown |
Machine Control | break in period, normal, end of machine life |
Scenario Parameters
Scenarios are like sections of the space your agent will explore for decisions (actions) that bring it closer to the goals of successfully completing the task. These sections can be defined by groups of variables and variable ranges.
Discrete Variables
Discrete variables are categories that describe a particular scenario. For each scenario, there is likely a perceptor in the agent (a machine learning model for example) that inputs the sensors, processes the sensor values, and outputs the discrete variable category.
Continuous Variables
Continuous variables are numbers. When they are used to define a scenario that one number value defines the section of the space that your agent will explore for decisions.
Sometimes a scenario is better defined by a range of continuous values than by a single continuous value. In that case, the scenario would be defined by a continouous variable range.
Examples
Here are some examples of how scenarios can be defined in different ways:
Agent | Discrete Variables | Continuous Variable Values | Continuous Variable Ranges |
---|---|---|---|
Drone Control | windy, far_from_charger, low_battery | windspeed=20 (knots) | windspeed between 20-40 (knots) |
Autonomous Driving | city, highway, high_traffic | vehicle_speed=65 (miles per hour) | vehicle_speed between 65-85 (miles per hour) |
Cybersecurity Network Optimization | normal, high_traffic, cyberattack | site_traffic=0 (clicks per second) | site_traffic between 100-150 (clicks per second) |
Process Control | startup, steady_state, shutdown | product_thickness=50 (milimeters) | product_thickness between 49.94-50.06 (milimeters) |
Machine Control | break-in, normal, wearing_out | rpm=280 (revolutions per minute) | rpm between 250-295 (revolutions per minute) |
Coding Scenarios
Code each scenario as a Python dictionary with each variable (discrete, continuous, or continuous range) as a key, value pair. Discrete variables should look like this: "state1": "category"
, continuous variables should look like this: "state1": 0
, and continuous ranges should look like this: "state1": [0,5]
.
Here are two of several scenarios in the agent that controls the demo-sim:
increment_scenarios = [
{
"state1": 0,
},
{
"state1": -25,
},
{
"state1": 25,
},
]
decrement_scenarios = [
{
"state1": 0,
},
{
"state1": -25,
},
{
"state1": 25,
},
]
target_scenarios = [
{
"state1": 0,
},
{
"state1": -25,
},
{
"state1": 25,
},
]
Creating a Scenario Definition File (Optional)
A cleaner agent.py
file helps keep your agent organized. So, we recommend creating a separate file (e.g. scenarios.py
) to contain the scenario definitions. Alternatively, you can include the scenario definitions in the agent Python file.
from composabl import Scenario
increment_scenarios = [
{
"state1": 0,
},
{
"state1": -25,
},
{
"state1": 25,
},
]
decrement_scenarios = [
{
"state1": 0,
},
{
"state1": -25,
},
{
"state1": 25,
},
]
target_scenarios = [
{
"state1": 0,
},
{
"state1": -25,
},
{
"state1": 25,
},
]
Unlike with sensors and perceptors, we don't add scenarios to the agent at this stage. That's because scenarios are added to specific skills rather than the agent as a whole. The reason for this is that not all skills need to perform in all scenarios. For example, a drone may need to fly and land in extremely windy conditions. But it may not need to learn the takeoff skill in this scenario, because it would not be cleared for takeoff under these conditions.
You'll learn how to add scenarios to skills in the next section.