Spaces:
Sleeping
Sleeping
sync: push from tools/sync_space_to_hub.py (no artifacts/)
Browse files- ev_grid_oracle/scenarios.py +61 -0
ev_grid_oracle/scenarios.py
CHANGED
|
@@ -11,6 +11,11 @@ ScenarioName = Literal[
|
|
| 11 |
"transformer_derate",
|
| 12 |
"station_outage",
|
| 13 |
"tariff_shock",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
]
|
| 15 |
|
| 16 |
|
|
@@ -89,10 +94,66 @@ def scenario_schedule(name: ScenarioName) -> list[ScenarioEvent]:
|
|
| 89 |
{"tick": 24, "type": "tariff_shock_2", "meta": {"price_mult": 1.55}},
|
| 90 |
]
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
# Exhaustive check
|
| 93 |
raise ValueError(f"Unknown scenario: {name}")
|
| 94 |
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
def apply_scenario_events(
|
| 97 |
*,
|
| 98 |
name: ScenarioName,
|
|
|
|
| 11 |
"transformer_derate",
|
| 12 |
"station_outage",
|
| 13 |
"tariff_shock",
|
| 14 |
+
"MonsoonStorm",
|
| 15 |
+
"CricketFinal",
|
| 16 |
+
"AirportRush",
|
| 17 |
+
"SilkBoardJam",
|
| 18 |
+
"WhitefieldNight",
|
| 19 |
]
|
| 20 |
|
| 21 |
|
|
|
|
| 94 |
{"tick": 24, "type": "tariff_shock_2", "meta": {"price_mult": 1.55}},
|
| 95 |
]
|
| 96 |
|
| 97 |
+
if name == "MonsoonStorm":
|
| 98 |
+
# Solar drops + random outages + demand surge (city floods).
|
| 99 |
+
return [
|
| 100 |
+
{"tick": 6, "type": "monsoon_start", "meta": {"grid_load_delta": 0.06, "arrivals_mult": 1.35}},
|
| 101 |
+
{"tick": 14, "type": "station_outage", "meta": {"station_id": "BLR-14", "new_total_slots": 2}},
|
| 102 |
+
{"tick": 22, "type": "station_outage", "meta": {"station_id": "BLR-07", "new_total_slots": 1}},
|
| 103 |
+
{"tick": 28, "type": "monsoon_worst", "meta": {"grid_load_delta": 0.14, "arrivals_mult": 1.6}},
|
| 104 |
+
]
|
| 105 |
+
|
| 106 |
+
if name == "CricketFinal":
|
| 107 |
+
# Evening mega-spike and queues explode unless fleet adapts.
|
| 108 |
+
return [
|
| 109 |
+
{"tick": 10, "type": "pre_game", "meta": {"arrivals_mult": 1.4}},
|
| 110 |
+
{"tick": 18, "type": "stadium_peak", "meta": {"arrivals_mult": 2.2, "grid_load_delta": 0.08}},
|
| 111 |
+
{"tick": 26, "type": "post_game_exit", "meta": {"arrivals_mult": 2.5, "grid_load_delta": 0.12}},
|
| 112 |
+
]
|
| 113 |
+
|
| 114 |
+
if name == "AirportRush":
|
| 115 |
+
# Sustained demand + price spike (taxis), plus grid headroom tightens.
|
| 116 |
+
return [
|
| 117 |
+
{"tick": 8, "type": "airport_rush", "meta": {"arrivals_mult": 1.7}},
|
| 118 |
+
{"tick": 16, "type": "tariff_shock", "meta": {"price_mult": 1.45}},
|
| 119 |
+
{"tick": 24, "type": "transformer_derate", "meta": {"grid_load_delta": 0.12}},
|
| 120 |
+
]
|
| 121 |
+
|
| 122 |
+
if name == "SilkBoardJam":
|
| 123 |
+
# Congestion-like effect simulated via increased arrivals + localized outage.
|
| 124 |
+
return [
|
| 125 |
+
{"tick": 6, "type": "jam_start", "meta": {"arrivals_mult": 1.5}},
|
| 126 |
+
{"tick": 12, "type": "station_outage", "meta": {"station_id": "BLR-11", "new_total_slots": 2}},
|
| 127 |
+
{"tick": 20, "type": "spillover", "meta": {"arrivals_mult": 1.8}},
|
| 128 |
+
]
|
| 129 |
+
|
| 130 |
+
if name == "WhitefieldNight":
|
| 131 |
+
# Late-night shift: lower renewables, high commercial load, tariff pressure.
|
| 132 |
+
return [
|
| 133 |
+
{"tick": 10, "type": "night_commercial", "meta": {"grid_load_delta": 0.10}},
|
| 134 |
+
{"tick": 18, "type": "tariff_shock", "meta": {"price_mult": 1.50}},
|
| 135 |
+
{"tick": 26, "type": "night_second_wave", "meta": {"arrivals_mult": 1.6}},
|
| 136 |
+
]
|
| 137 |
+
|
| 138 |
# Exhaustive check
|
| 139 |
raise ValueError(f"Unknown scenario: {name}")
|
| 140 |
|
| 141 |
|
| 142 |
+
# Judge-friendly deterministic story seeds (replayable).
|
| 143 |
+
STORY_SEEDS: dict[str, int] = {
|
| 144 |
+
"MonsoonStorm": 1107,
|
| 145 |
+
"CricketFinal": 1804,
|
| 146 |
+
"AirportRush": 2409,
|
| 147 |
+
"SilkBoardJam": 1212,
|
| 148 |
+
"WhitefieldNight": 2217,
|
| 149 |
+
"heatwave_peak": 1618,
|
| 150 |
+
"festival_surge": 2026,
|
| 151 |
+
"transformer_derate": 2828,
|
| 152 |
+
"station_outage": 1414,
|
| 153 |
+
"tariff_shock": 2424,
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
def apply_scenario_events(
|
| 158 |
*,
|
| 159 |
name: ScenarioName,
|