Update graders/grader3.py
Browse files- graders/grader3.py +9 -3
graders/grader3.py
CHANGED
|
@@ -10,13 +10,17 @@ def grade(episode_log: Dict[str, Any]) -> float:
|
|
| 10 |
- 25% no fuel exhaustions (proportional, not binary)
|
| 11 |
- 25% queue never exceeds 12 aircraft (queue = INBOUND+HOLDING only)
|
| 12 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
if not episode_log:
|
| 14 |
-
return
|
| 15 |
|
| 16 |
aircraft = episode_log.get("aircraft", [])
|
| 17 |
total_aircraft = len(aircraft)
|
| 18 |
if total_aircraft == 0:
|
| 19 |
-
return
|
| 20 |
|
| 21 |
# 25%: Landings completed
|
| 22 |
landed = sum(1 for ac in aircraft if ac.get("status") == "LANDED")
|
|
@@ -41,4 +45,6 @@ def grade(episode_log: Dict[str, Any]) -> float:
|
|
| 41 |
queue_score = 1.0 if max_queue <= 12 else max(0.0, 1.0 - (max_queue - 12) / 20)
|
| 42 |
|
| 43 |
final_score = 0.25 * landing_score + 0.25 * emergency_score + 0.25 * fuel_score + 0.25 * queue_score
|
| 44 |
-
|
|
|
|
|
|
|
|
|
| 10 |
- 25% no fuel exhaustions (proportional, not binary)
|
| 11 |
- 25% queue never exceeds 12 aircraft (queue = INBOUND+HOLDING only)
|
| 12 |
"""
|
| 13 |
+
# Updated bounds to guarantee scores are strictly between (0, 1) at 4 decimal places
|
| 14 |
+
MIN_SCORE = 0.001
|
| 15 |
+
MAX_SCORE = 0.999
|
| 16 |
+
|
| 17 |
if not episode_log:
|
| 18 |
+
return MIN_SCORE
|
| 19 |
|
| 20 |
aircraft = episode_log.get("aircraft", [])
|
| 21 |
total_aircraft = len(aircraft)
|
| 22 |
if total_aircraft == 0:
|
| 23 |
+
return MIN_SCORE
|
| 24 |
|
| 25 |
# 25%: Landings completed
|
| 26 |
landed = sum(1 for ac in aircraft if ac.get("status") == "LANDED")
|
|
|
|
| 45 |
queue_score = 1.0 if max_queue <= 12 else max(0.0, 1.0 - (max_queue - 12) / 20)
|
| 46 |
|
| 47 |
final_score = 0.25 * landing_score + 0.25 * emergency_score + 0.25 * fuel_score + 0.25 * queue_score
|
| 48 |
+
|
| 49 |
+
# Enforce safe boundaries on the final returned score
|
| 50 |
+
return max(MIN_SCORE, min(MAX_SCORE, final_score))
|