Spaces:
Sleeping
Sleeping
File size: 1,952 Bytes
c30c6ee 85ea5e3 c30c6ee 85ea5e3 c30c6ee 85ea5e3 c30c6ee a91b545 c30c6ee 85ea5e3 c30c6ee 85ea5e3 c30c6ee | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | """
Task 1 (Easy): Basic Appointment Booking Grader.
Evaluates the agent's ability to successfully book appointments
for waiting patients into available slots.
Scoring breakdown:
- 50%: Booking success rate (patients booked / total patients)
- 25%: Action efficiency (successful actions / total actions taken)
- 25%: Error avoidance (1 - error_rate)
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def _clamp(score: float) -> float:
"""Clamp score to [0.1, 0.9] for validator compliance."""
if score != score: # NaN check
return 0.5
return min(max(float(score), 0.1), 0.9)
def grade(env=None) -> float:
"""Grade task 1: basic appointment booking."""
if env is None:
from env import HealthcareEnvironment
env = HealthcareEnvironment(seed=42)
if not env.patients:
return 0.5
total_patients = len(env.patients)
booked_count = sum(
1 for p in env.patients.values()
if p.get("status") == "booked"
)
# ββ Metric 1 (50%): Booking success rate ββ
booking_rate = booked_count / total_patients if total_patients > 0 else 0.0
# ββ Metric 2 (25%): Action efficiency ββ
history = getattr(env, "_action_history", [])
total_actions = len(history)
successful_actions = sum(
1 for a in history
if a.get("info", {}).get("status") == "success"
)
efficiency = successful_actions / total_actions if total_actions > 0 else 0.0
# ββ Metric 3 (25%): Error avoidance ββ
error_actions = sum(
1 for a in history
if a.get("info", {}).get("error") is not None
)
error_rate = error_actions / total_actions if total_actions > 0 else 0.0
error_avoidance = 1.0 - error_rate
raw_score = (
0.50 * booking_rate
+ 0.25 * efficiency
+ 0.25 * error_avoidance
)
return _clamp(raw_score)
|