77ethers commited on
Commit
40a8adc
·
verified ·
1 Parent(s): d446b52

Upload folder using huggingface_hub

Browse files
gridops/models.py CHANGED
@@ -37,7 +37,7 @@ class GridOpsAction(Action):
37
  default=0.0,
38
  ge=0.0,
39
  le=1.0,
40
- description="Demand response: 0 (none) to 1 (shed 20%). 50% rebounds next hour.",
41
  )
42
 
43
 
 
37
  default=0.0,
38
  ge=0.0,
39
  le=1.0,
40
+ description="Demand response: 0 (none) to 1 (shed 20%). 100% rebounds next hour. Rs 40/kWh penalty.",
41
  )
42
 
43
 
gridops/server/static/index.html CHANGED
@@ -409,7 +409,7 @@
409
  <p style="margin-left:8px; line-height: 2.0;">
410
  &#128267; <strong>Battery</strong> &mdash; charge it (store cheap energy) or discharge it (cover peaks)<br>
411
  &#9981; <strong>Diesel</strong> &mdash; turn it on for emergency power (expensive!)<br>
412
- &#127968; <strong>Demand shed</strong> &mdash; ask residents to use less (but 50% rebounds next hour)
413
  </p>
414
  </div>
415
 
@@ -438,7 +438,7 @@
438
  <div class="cp-item">
439
  <span class="cp-icon">&#127968;</span>
440
  <div class="cp-name">Demand Shed</div>
441
- <div class="cp-desc">Ask residents to cut usage. Up to 20%. 50% rebounds next hour.</div>
442
  </div>
443
  </div>
444
 
 
409
  <p style="margin-left:8px; line-height: 2.0;">
410
  &#128267; <strong>Battery</strong> &mdash; charge it (store cheap energy) or discharge it (cover peaks)<br>
411
  &#9981; <strong>Diesel</strong> &mdash; turn it on for emergency power (expensive!)<br>
412
+ &#127968; <strong>Demand shed</strong> &mdash; ask residents to use less (but 100% rebounds next hour)
413
  </p>
414
  </div>
415
 
 
438
  <div class="cp-item">
439
  <span class="cp-icon">&#127968;</span>
440
  <div class="cp-name">Demand Shed</div>
441
+ <div class="cp-desc">Ask residents to cut usage. Up to 20%. 100% rebounds next hour! Rs 40/kWh.</div>
442
  </div>
443
  </div>
444
 
gridops/simulation/physics.py CHANGED
@@ -7,7 +7,7 @@ KEY DESIGN (per Gemini review):
7
  - VoLL penalty (Rs 150/kWh) replaces hard reliability gate
8
  - Battery degradation cost (Rs 2.5/kWh throughput)
9
  - Diesel startup cost (Rs 100 if was off last step)
10
- - Demand shedding rebound (50% of shed kWh added to next hour)
11
  """
12
 
13
  from __future__ import annotations
@@ -123,7 +123,7 @@ def step(
123
  actual_demand = demand_kw + state.shed_rebound_kwh / DT # rebound is kWh, convert to kW
124
  effective_demand = actual_demand * (1.0 - shed_frac)
125
  shed_kwh = actual_demand * shed_frac * DT
126
- state.shed_rebound_kwh = shed_kwh * SHED_REBOUND_FRAC # 50% rebounds next hour
127
 
128
  # ── Diesel fuel constraint ───────────────────────────────────────
129
  available_diesel_kwh = state.diesel_fuel_kwh
@@ -227,9 +227,13 @@ def step(
227
  state.last_cost = step_cost
228
  state.last_grid_kw = grid_kw
229
 
230
- # ── Per-step reward (negative cost, normalized) ──────────────────
231
- # Simple: reward = -cost / normalization. Agent minimizes total cost.
232
- reward = -step_cost / 500.0 # normalize to roughly [-2, 0] range
 
 
 
 
233
  state.last_reward = reward
234
 
235
  # ── Advance clock ────────────────────────────────────────────────
 
7
  - VoLL penalty (Rs 150/kWh) replaces hard reliability gate
8
  - Battery degradation cost (Rs 2.5/kWh throughput)
9
  - Diesel startup cost (Rs 100 if was off last step)
10
+ - Demand shedding rebound (100% of shed kWh deferred to next hour)
11
  """
12
 
13
  from __future__ import annotations
 
123
  actual_demand = demand_kw + state.shed_rebound_kwh / DT # rebound is kWh, convert to kW
124
  effective_demand = actual_demand * (1.0 - shed_frac)
125
  shed_kwh = actual_demand * shed_frac * DT
126
+ state.shed_rebound_kwh = shed_kwh * SHED_REBOUND_FRAC # 100% rebounds next hour
127
 
128
  # ── Diesel fuel constraint ───────────────────────────────────────
129
  available_diesel_kwh = state.diesel_fuel_kwh
 
227
  state.last_cost = step_cost
228
  state.last_grid_kw = grid_kw
229
 
230
+ # ── Per-step reward (aligned with episode grader weights) ────────
231
+ # Grader = 50% cost_efficiency + 25% reliability + 25% green_score
232
+ # Step reward mirrors these proportions for consistent learning signal.
233
+ cost_signal = -step_cost / 500.0
234
+ reliability_signal = -2.0 * (blackout_kwh / max(effective_demand * DT, 1.0))
235
+ green_signal = -0.5 * (diesel_kw / DIESEL_MAX_KW) if diesel_kw > 0 else 0.0
236
+ reward = 0.50 * cost_signal + 0.25 * reliability_signal + 0.25 * green_signal
237
  state.last_reward = reward
238
 
239
  # ── Advance clock ────────────────────────────────────────────────
inference.py CHANGED
@@ -38,7 +38,7 @@ You are an expert microgrid operator managing a 100-home community in India duri
38
  You control three actions each hour:
39
  - battery_dispatch: -1 (charge 100 kW from grid) to +1 (discharge 100 kW to community)
40
  - diesel_dispatch: 0 (off) to 1 (100 kW). Costs Rs 25/kWh + Rs 100 startup if was off.
41
- - demand_shedding: 0 (none) to 1 (shed 20% of demand). WARNING: 50% rebounds next hour.
42
 
43
  The GRID automatically absorbs the residual (capped at ±200 kW).
44
  If demand exceeds grid + solar + battery + diesel → BLACKOUT (Rs 150/kWh penalty!).
 
38
  You control three actions each hour:
39
  - battery_dispatch: -1 (charge 100 kW from grid) to +1 (discharge 100 kW to community)
40
  - diesel_dispatch: 0 (off) to 1 (100 kW). Costs Rs 25/kWh + Rs 100 startup if was off.
41
+ - demand_shedding: 0 (none) to 1 (shed 20% of demand). WARNING: 100% rebounds next hour! Rs 40/kWh penalty.
42
 
43
  The GRID automatically absorbs the residual (capped at ±200 kW).
44
  If demand exceeds grid + solar + battery + diesel → BLACKOUT (Rs 150/kWh penalty!).
openenv.yaml CHANGED
@@ -32,7 +32,7 @@ tasks:
32
  description: "Full 3-day heatwave, -30% solar, Rs 8-20 prices, limited diesel fuel."
33
 
34
  metadata:
35
- action_space: "3D continuous: grid_trade [-1,1], diesel_dispatch [0,1], demand_shedding [0,1]"
36
  observation_space: "12 fields: hour, demand, solar, battery_soc, price, fuel, 3×4h forecasts, cumulative metrics"
37
  episode_length: 72
38
  step_duration: "1 hour"
 
32
  description: "Full 3-day heatwave, -30% solar, Rs 8-20 prices, limited diesel fuel."
33
 
34
  metadata:
35
+ action_space: "3D continuous: battery_dispatch [-1,1], diesel_dispatch [0,1], demand_shedding [0,1]"
36
  observation_space: "12 fields: hour, demand, solar, battery_soc, price, fuel, 3×4h forecasts, cumulative metrics"
37
  episode_length: 72
38
  step_duration: "1 hour"