Angshuman28 commited on
Commit
f6ae66b
Β·
verified Β·
1 Parent(s): 16e3f36

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +7 -0
  2. README.md +1 -1
  3. mm.md +112 -0
  4. server/Dockerfile +7 -0
Dockerfile CHANGED
@@ -11,6 +11,7 @@
11
  # - CMD (`cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000`)
12
  # - HEALTHCHECK on /health
13
  # - PYTHONPATH=/app/env:$PYTHONPATH (so the dual-import fallback resolves)
 
14
  # Drift will cause the hackathon validator (which builds this root file) and
15
  # `openenv build` (which builds server/Dockerfile) to produce different images.
16
  # Update both together. Run `diff Dockerfile server/Dockerfile` after any
@@ -76,6 +77,12 @@ FROM ${BASE_IMAGE:-ghcr.io/meta-pytorch/openenv-base:latest}
76
 
77
  WORKDIR /app
78
 
 
 
 
 
 
 
79
  # Copy the virtual environment from builder
80
  COPY --from=builder /app/env/.venv /app/.venv
81
 
 
11
  # - CMD (`cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000`)
12
  # - HEALTHCHECK on /health
13
  # - PYTHONPATH=/app/env:$PYTHONPATH (so the dual-import fallback resolves)
14
+ # - git installed in both builder and runtime stages for HF Spaces dev-mode
15
  # Drift will cause the hackathon validator (which builds this root file) and
16
  # `openenv build` (which builds server/Dockerfile) to produce different images.
17
  # Update both together. Run `diff Dockerfile server/Dockerfile` after any
 
77
 
78
  WORKDIR /app
79
 
80
+ # HF Spaces dev-mode runs git config in the final stage after this image is
81
+ # assembled; keep git available outside the builder stage.
82
+ RUN apt-get update && \
83
+ apt-get install -y --no-install-recommends git && \
84
+ rm -rf /var/lib/apt/lists/*
85
+
86
  # Copy the virtual environment from builder
87
  COPY --from=builder /app/env/.venv /app/.venv
88
 
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: CrisisWorldCortex Environment Server
3
- emoji: 🌍
4
  colorFrom: yellow
5
  colorTo: pink
6
  sdk: docker
 
1
  ---
2
  title: CrisisWorldCortex Environment Server
3
+ emoji: 🧠
4
  colorFrom: yellow
5
  colorTo: pink
6
  sdk: docker
mm.md ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mm.md β€” 6-step walkthrough on `outbreak_easy`
2
+
3
+ Run: `uv run python mm.py`
4
+
5
+ ## Setup
6
+
7
+ - **Task:** `outbreak_easy`, **seed=0**, `max_ticks=12`.
8
+ - **Initial latent state** (per `server/simulator/tasks.py`): R1 hot
9
+ with `Iβ‰ˆ0.03` (~30 cases / 1000 pop); R2 / R3 / R4 quiet with
10
+ `Iβ‰ˆ0.001` (~1 case / 1000 pop).
11
+ - **Initial resources:** 1000 test_kits, 500 hospital_beds, 20 mobile_units,
12
+ 2000 vaccine_doses.
13
+ - **Telemetry:** delay = 1 tick, Οƒ_cases = 0.02 (β‰ˆ Β±20 cases of noise),
14
+ Οƒ_compliance = 0.05.
15
+
16
+ The `cases` field printed each tick is **delayed and noisy** β€” it's
17
+ `reported_cases_d_ago`. The reward is computed on the latent ground
18
+ truth, not the telemetry, so reward dynamics may not visibly match
19
+ the printed cases.
20
+
21
+ ## Step-by-step intent
22
+
23
+ ### Step 1 β€” `NoOp` baseline
24
+
25
+ - **Intent:** see how the env evolves with no intervention.
26
+ - **Expected:** R1 grows slowly under R0=1.5 (within-region Ξ² β‰ˆ 0.3);
27
+ R2-R4 stay near zero. Reward should be high (most population still
28
+ susceptible, low total infection).
29
+
30
+ ### Step 2 β€” `DeployResource(R1, test_kits, 200)`
31
+
32
+ - **Intent:** test_kits efficacy is `0.00002 / unit / tick`; 200 units
33
+ contribute `-0.004` to R1's I per tick over 2 ticks.
34
+ - **Expected:** kits inventory drops 1000 β†’ 800. Reward changes are
35
+ too small to read off β€” this is mostly to demonstrate the deployment
36
+ flow (`accepted=True`, inventory delta).
37
+
38
+ ### Step 3 β€” `RestrictMovement(R1, moderate)`
39
+
40
+ - **Intent:** severity multiplier = 0.25 β†’ R0_eff on R1 drops 25%.
41
+ Slows transmission inside R1.
42
+ - **Expected:** `active_restrictions` shows `R1=moderate(4)` (4-tick
43
+ duration, decremented each tick). R1 case-growth slows. Compliance
44
+ starts gentle decay under restriction.
45
+
46
+ ### Step 4 β€” `DeployResource(R1, vaccine_doses, 500)`
47
+
48
+ - **Intent:** vaccine efficacy `0.0001 / unit`; 500 units β†’ `-0.05` Ξ”I
49
+ on R1 plus equivalent S β†’ R conversion.
50
+ - **Expected:** vax inventory 2000 β†’ 1500. R1's hospital_load eases
51
+ over the next 2 ticks; R1 compliance_proxy holds steady.
52
+
53
+ ### Step 5 β€” `Escalate(national)`
54
+
55
+ - **Intent:** unlocks the `restrict_movement.strict` rule via the L1
56
+ legal_constraints entry. SEIR is a no-op for this tick.
57
+ - **Expected:** `accepted=True`. Internally
58
+ `escalation_unlocked_strict=True`. The `legal_constraints` list
59
+ still contains L1 in the observation (it's the rule, not the lock
60
+ state); only the lock has flipped.
61
+
62
+ ### Step 6 β€” `RestrictMovement(R1, strict)`
63
+
64
+ - **Intent:** severity multiplier = 0.5 β†’ R0_eff on R1 drops 50%.
65
+ Pre-step-5 this would have been `accepted=False` (legal-violation).
66
+ - **Expected:** `accepted=True`. R1's restriction flips
67
+ `moderate β†’ strict`. Compliance starts faster decay
68
+ (-0.03 / tick under strict).
69
+
70
+ ## Reading the output
71
+
72
+ Each step prints:
73
+
74
+ | Field | Meaning |
75
+ |---|---|
76
+ | `action` | `kind` of payload submitted |
77
+ | `accepted` | env's verdict (False = V2-illegal **or** legal-violation **or** insufficient resource) |
78
+ | `reward` | per-tick `outer_reward` ∈ [0, 1] (design §15 weighted sum) |
79
+ | `regions` | `cases` (delayed + noisy), `hosp` (current), `comp` (noisy) |
80
+ | `resources` | global inventory (test_kits / hospital_beds_free / mobile_units / vaccine_doses) |
81
+ | `restricts` | active restrictions per region with `(ticks_remaining)` |
82
+ | `tick` | `current / max_ticks`; `done` is True only at terminal |
83
+
84
+ The reward has **6 components** weighted (per design Β§15):
85
+
86
+ | Component | Weight | What it measures |
87
+ |---|---|---|
88
+ | `r_infect` | 0.35 | `1 - mean(I)` β€” average infection across regions |
89
+ | `r_time` | 0.18 | `1 - tick / max_ticks` β€” early-tick bias |
90
+ | `r_hosp` | 0.17 | `1 - mean(hospital_load)` |
91
+ | `r_casc` | 0.15 | binary: 1 if no region exceeds I=0.30, else 0 |
92
+ | `r_policy` | 0.12 | binary: 1 if last action accepted, else 0 |
93
+ | `r_fair` | 0.03 | `1 - pstdev(I)` β€” equality across regions |
94
+
95
+ Because `outbreak_easy` starts low-infection and the 3-consecutive-
96
+ safe-ticks rule fires quickly, **the env may report `done=True`
97
+ before all 6 steps are exhausted**. The script keeps stepping
98
+ regardless so you see the full intended sequence; in production the
99
+ agent would break on `done`.
100
+
101
+ ## Caveats
102
+
103
+ - **Telemetry noise on tick 0:** the printed `R1: cases=48` at the
104
+ initial state can exceed the true 30 cases per 1000 because of the
105
+ Gaussian noise draw. Different seeds will print different numbers
106
+ for the same latent state.
107
+ - **Compliance proxy** is similarly noised β€” small fluctuations don't
108
+ reflect real compliance changes.
109
+ - **Reward stays high throughout** even though `done=True` flips
110
+ early; the success-terminal +0.20 bonus is **not** included in
111
+ `obs.reward` (per the env-step separation pin from Session 7d) β€”
112
+ it's composed downstream by the trainer in `reward_shaping.py`.
server/Dockerfile CHANGED
@@ -11,6 +11,7 @@
11
  # - CMD (`cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000`)
12
  # - HEALTHCHECK on /health
13
  # - PYTHONPATH=/app/env:$PYTHONPATH (so the dual-import fallback resolves)
 
14
  # Drift will cause the hackathon validator (which builds the root file) and
15
  # `openenv build` (which builds this file) to produce different images.
16
  # Update both together. Run `diff Dockerfile server/Dockerfile` after any
@@ -76,6 +77,12 @@ FROM ${BASE_IMAGE:-ghcr.io/meta-pytorch/openenv-base:latest}
76
 
77
  WORKDIR /app
78
 
 
 
 
 
 
 
79
  # Copy the virtual environment from builder
80
  COPY --from=builder /app/env/.venv /app/.venv
81
 
 
11
  # - CMD (`cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000`)
12
  # - HEALTHCHECK on /health
13
  # - PYTHONPATH=/app/env:$PYTHONPATH (so the dual-import fallback resolves)
14
+ # - git installed in both builder and runtime stages for HF Spaces dev-mode
15
  # Drift will cause the hackathon validator (which builds the root file) and
16
  # `openenv build` (which builds this file) to produce different images.
17
  # Update both together. Run `diff Dockerfile server/Dockerfile` after any
 
77
 
78
  WORKDIR /app
79
 
80
+ # HF Spaces dev-mode runs git config in the final stage after this image is
81
+ # assembled; keep git available outside the builder stage.
82
+ RUN apt-get update && \
83
+ apt-get install -y --no-install-recommends git && \
84
+ rm -rf /var/lib/apt/lists/*
85
+
86
  # Copy the virtual environment from builder
87
  COPY --from=builder /app/env/.venv /app/.venv
88