DHDRL commited on
Commit
eea3056
·
verified ·
1 Parent(s): 3c5962c

Update evaluate_checkpoint_real.py

Browse files
Files changed (1) hide show
  1. evaluate_checkpoint_real.py +42 -4
evaluate_checkpoint_real.py CHANGED
@@ -102,9 +102,13 @@ def _path_check_report() -> None:
102
  n_ok = _PATH_CHECK_N - _PATH_CHECK_DIVERGE
103
  print(
104
  f"PATH_CHECK summary: n={_PATH_CHECK_N} ok={n_ok} "
105
- f"diverge={_PATH_CHECK_DIVERGE} "
106
  f"rate={_PATH_CHECK_DIVERGE / _PATH_CHECK_N:.3f} "
107
- f"(loop product is authoritative; rs is display-only)",
 
 
 
 
108
  flush=True,
109
  )
110
 
@@ -403,6 +407,13 @@ def _multi_zone_risk_score(ctx: EpisodeContext) -> RiskScore:
403
  ctx.resolved_zone_obs()/ctx.resolved_zone_forecasts() the same way the
404
  env does, or "rs" silently stops representing the same decision as the
405
  env's actual per-step product_actionable flag.
 
 
 
 
 
 
 
406
  """
407
  zone_obs = ctx.resolved_zone_obs()
408
  zone_fc = ctx.resolved_zone_forecasts()
@@ -416,6 +427,30 @@ def _multi_zone_risk_score(ctx: EpisodeContext) -> RiskScore:
416
  )
417
 
418
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
  def decide_scorer_oracle(
420
  obs: ZoneObs,
421
  fc: ForecastResult,
@@ -491,9 +526,12 @@ def decide_checkpoint(
491
  rs = None
492
  try:
493
  rs = _multi_zone_risk_score(ctx)
494
- rs_product = is_product_actionable(rs, gate)
 
 
 
495
  _PATH_CHECK_N += 1
496
- if rs_product != loop_product:
497
  _PATH_CHECK_DIVERGE += 1
498
  except Exception:
499
  pass
 
102
  n_ok = _PATH_CHECK_N - _PATH_CHECK_DIVERGE
103
  print(
104
  f"PATH_CHECK summary: n={_PATH_CHECK_N} ok={n_ok} "
105
+ f"argmax_miss_or_hit={_PATH_CHECK_DIVERGE} "
106
  f"rate={_PATH_CHECK_DIVERGE / _PATH_CHECK_N:.3f} "
107
+ f"(pack-level argmax [Option A, decision-locked 2026-08-15] is "
108
+ f"authoritative for product_actionable; this counts days where "
109
+ f"OR-across-zones [Option B] would have differed -- i.e. some "
110
+ f"zone's own drought/flood channel independently cleared the gate "
111
+ f"while the argmax-selected zone did not. Not a display bug.)",
112
  flush=True,
113
  )
114
 
 
407
  ctx.resolved_zone_obs()/ctx.resolved_zone_forecasts() the same way the
408
  env does, or "rs" silently stops representing the same decision as the
409
  env's actual per-step product_actionable flag.
410
+
411
+ This is Option A (argmax by supply_shortfall_prob) -- the documented,
412
+ decision-locked (2026-08-15) rule for the authoritative pack-level
413
+ product decision. Used here only to make displayed per-day fields
414
+ (alert_level/drought_risk/flood_risk) consistent with whichever zone
415
+ actually drove that decision. Do NOT use this for the PATH_CHECK
416
+ divergence comparison -- see _or_across_zones_product below for why.
417
  """
418
  zone_obs = ctx.resolved_zone_obs()
419
  zone_fc = ctx.resolved_zone_forecasts()
 
427
  )
428
 
429
 
430
+ def _or_across_zones_product(ctx: EpisodeContext, gate: ProductGateConfig) -> bool:
431
+ """Option B from the documented multi-zone product selection decision:
432
+ any(is_product_actionable(zone) for zone in zones), independent of
433
+ which zone owns the highest supply_shortfall_prob.
434
+
435
+ Proven property: argmax_product (Option A / loop_product) implies
436
+ or_product always, so the only possible divergence is
437
+ loop_product=False, or_product=True -- an "argmax miss" where some
438
+ zone's own drought/flood channel independently crosses the gate while
439
+ the argmax-selected zone (chosen by a supply_shortfall_prob blend that
440
+ also includes harvest pressure) does not. This is the real, still-open
441
+ signature PATH_CHECK exists to surface (decision recorded 2026-08-15:
442
+ keep argmax as the product rule; the divergence itself stays worth
443
+ tracking, not silently eliminated).
444
+ """
445
+ zone_obs = ctx.resolved_zone_obs()
446
+ zone_fc = ctx.resolved_zone_forecasts()
447
+ for zo, zf in zip(zone_obs, zone_fc):
448
+ score = compute_risk_score(zo, zf, ctx.config)
449
+ if is_product_actionable(score, gate):
450
+ return True
451
+ return False
452
+
453
+
454
  def decide_scorer_oracle(
455
  obs: ZoneObs,
456
  fc: ForecastResult,
 
526
  rs = None
527
  try:
528
  rs = _multi_zone_risk_score(ctx)
529
+ except Exception:
530
+ pass
531
+ try:
532
+ or_product = _or_across_zones_product(ctx, gate)
533
  _PATH_CHECK_N += 1
534
+ if or_product != loop_product:
535
  _PATH_CHECK_DIVERGE += 1
536
  except Exception:
537
  pass