Commit ·
7f110fa
1
Parent(s): 6856bd4
Fix memory threshold, pre-compute lag estimates in hard prompt
Browse files- baseline/policy.py +19 -6
- core/trajectory.py +1 -1
baseline/policy.py
CHANGED
|
@@ -36,7 +36,6 @@ def build_prompt(obs: CityObservation) -> str:
|
|
| 36 |
if d.reported_infection_rate > 0.4:
|
| 37 |
status = "🔴 CRITICAL"
|
| 38 |
elif d.reported_infection_rate > 0.2:
|
| 39 |
-
# Add escalation warning based on growth hint
|
| 40 |
if d.growth_rate_hint > 0.06:
|
| 41 |
status = "🟡 WARNING→CRITICAL SOON"
|
| 42 |
else:
|
|
@@ -51,11 +50,25 @@ def build_prompt(obs: CityObservation) -> str:
|
|
| 51 |
else:
|
| 52 |
hosp_status = "hospital OK"
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
lines += [""]
|
| 61 |
|
|
|
|
| 36 |
if d.reported_infection_rate > 0.4:
|
| 37 |
status = "🔴 CRITICAL"
|
| 38 |
elif d.reported_infection_rate > 0.2:
|
|
|
|
| 39 |
if d.growth_rate_hint > 0.06:
|
| 40 |
status = "🟡 WARNING→CRITICAL SOON"
|
| 41 |
else:
|
|
|
|
| 50 |
else:
|
| 51 |
hosp_status = "hospital OK"
|
| 52 |
|
| 53 |
+
if has_data_lag:
|
| 54 |
+
# Pre-compute estimated current infection — don't ask LLM to do math
|
| 55 |
+
estimated = round(min(1.0, d.reported_infection_rate + 3 * d.growth_rate_hint), 2)
|
| 56 |
+
if estimated > 0.4:
|
| 57 |
+
est_status = "🔴 EST.CRITICAL"
|
| 58 |
+
elif estimated > 0.2:
|
| 59 |
+
est_status = "🟡 EST.WARNING"
|
| 60 |
+
else:
|
| 61 |
+
est_status = "🟢 EST.SAFE"
|
| 62 |
+
lines.append(
|
| 63 |
+
f" D{d.district_id}: reported={d.reported_infection_rate:.2f} [3 days old] "
|
| 64 |
+
f"growth={d.growth_rate_hint:.2f} → ESTIMATED NOW={estimated:.2f} {est_status} "
|
| 65 |
+
f"{hosp_status}({d.hospital_capacity_remaining:.2f})"
|
| 66 |
+
)
|
| 67 |
+
else:
|
| 68 |
+
lines.append(
|
| 69 |
+
f" D{d.district_id}: {status} infection={d.reported_infection_rate:.2f} "
|
| 70 |
+
f"growth={d.growth_rate_hint:.2f} {hosp_status}({d.hospital_capacity_remaining:.2f})"
|
| 71 |
+
)
|
| 72 |
|
| 73 |
lines += [""]
|
| 74 |
|
core/trajectory.py
CHANGED
|
@@ -20,7 +20,7 @@ class EpisodicMemory:
|
|
| 20 |
|
| 21 |
def store(self, obs: CityObservation, action: ContainmentAction, reward: float):
|
| 22 |
"""Store a step only if it earned meaningful positive reward."""
|
| 23 |
-
if reward < 0.
|
| 24 |
return
|
| 25 |
|
| 26 |
# Phase: early/mid/late episode
|
|
|
|
| 20 |
|
| 21 |
def store(self, obs: CityObservation, action: ContainmentAction, reward: float):
|
| 22 |
"""Store a step only if it earned meaningful positive reward."""
|
| 23 |
+
if reward < -0.3: # stricter threshold — only store clearly positive steps
|
| 24 |
return
|
| 25 |
|
| 26 |
# Phase: early/mid/late episode
|