Scenarios
Scenarios enable what-if analysis and sensitivity studies by allowing you to create alternative versions of your network without duplicating the entire model. Using a sparse override architecture, scenarios only store attribute values that differ from the base network, making them highly efficient.
Overview
Every Convexity model has a base network that defines the default network configuration. Scenarios let you create variations by overriding specific attribute values while inheriting everything else from the base network.
Key benefits:
- Memory efficient: Only differences are stored, not entire networks
- Easy comparison: All scenarios share the same network topology
- Flexible analysis: Test multiple what-if cases without model duplication
- Stochastic optimization: Assign probabilities to scenarios for uncertainty modeling
Sparse Override Architecture
The sparse override system works as follows:
- Base network: All attributes with
scenario_id = NULLrepresent the default network - Scenario overrides: Attributes with a specific
scenario_idoverride the base value for that scenario only - Inheritance: If a scenario doesn't override an attribute, it uses the base network value
- Efficiency: A scenario with 10 overrides on a 1000-component network only stores 10 values. This makes the setup highly efficient (do not hestitate to add many scenarios)
Example:
Base network: Generator "Coal Plant" has marginal_cost = 50 EUR/MWh
Scenario "High Fuel Costs": Override marginal_cost = 80 EUR/MWh
Scenario "Low Demand": No override → uses base value 50 EUR/MWhScenarios Table Properties
| Property | Data Type | Default | Required | Description |
|---|---|---|---|---|
id | INTEGER | (auto) | - | Primary key (auto-increment) |
name | TEXT | - | Yes | Scenario name (unique) |
description | TEXT | - | No | Scenario description |
probability | REAL | NULL | No | Probability for stochastic optimization (0-1, NULL for deterministic what-if scenarios) |
is_system_scenario | BOOLEAN | FALSE | No | True for system-reserved scenarios (cannot be deleted) |
system_purpose | TEXT | NULL | No | Purpose of system scenario (e.g., "actual" for measured values) |
created_at | DATETIME | (auto) | No | Timestamp when scenario was created |
Scenario Types
1. Deterministic What-If Scenarios
Standard scenarios for sensitivity analysis and alternative cases.
Characteristics:
probability = NULL- Used for comparing discrete alternatives
- Each scenario solved independently
Examples:
- "High Fuel Costs" - Test impact of 50% higher gas prices
- "Delayed Transmission" - Model postponed infrastructure investments
- "Accelerated Renewables" - Explore faster clean energy deployment
2. Stochastic Scenarios
Scenarios with probabilities for uncertainty modeling.
Characteristics:
probabilityset between 0 and 1- Probabilities across scenarios should sum to 1
- Solved together in stochastic optimization
Examples:
- "Low Demand" (probability = 0.3) - Mild winter scenario
- "Medium Demand" (probability = 0.5) - Normal winter
- "High Demand" (probability = 0.2) - Severe winter
3. System Scenarios
Special reserved scenarios that cannot be deleted.
"Actual" Scenario:
- Automatically created for every network
- Purpose: Store measured/actual values for validation
is_system_scenario = TRUE,system_purpose = 'actual'- Not included in optimization solves
- Used for comparing model results against real-world data
Database Storage
Scenarios are stored efficiently in the database:
scenarios table:
id=1, name="Base Network", (implicit, no row)
id=2, name="High Fuel Costs", probability=NULL
id=3, name="Low Demand", probability=0.3
component_attributes table:
component_id=5, attribute="marginal_cost", scenario_id=NULL, value=50 (base)
component_id=5, attribute="marginal_cost", scenario_id=2, value=80 (override)
component_id=7, attribute="p_set", scenario_id=3, value=[...] (override)Learn More
- PyConvexity Examples - Programmatic scenario creation
- Component Attributes - How attributes work with scenarios

