Spaces:
Sleeping
Sleeping
Subhash Vadaparthi commited on
Commit Β·
a91b545
1
Parent(s): a3c97ed
fix: widen all score/reward clamp bounds to [0.1, 0.9] to avoid validator edge cases
Browse filesFiles changed (5)
78 unmodified lines798081828384853 unmodified lines89909192939495968 unmodified lines10510610710810911011136 unmodified lines14814915015115215315433 unmodified lines18818919019119219319478 unmodified linesself._state = HealthcareState(episode_id=episode_id or str(uuid4()),step_count=0,score=0.01,)return HealthcareObservation(3 unmodified linescurrent_step=self.current_step,info={},done=False,reward=0.01,score=0.01,)def step(self, action: HealthcareAction, **kwargs) -> HealthcareObservation:8 unmodified linescurrent_step=self.current_step,info={"error": "Environment done"},done=True,reward=0.01,score=self._state.score,)36 unmodified lines# Update score based on booking success - strictly between 0 and 1booked = sum(1 for p in self.patients.values() if p["status"] == "booked")self._state.score = min(max(booked / self.num_patients, 0.01), 0.99)return self._make_obs(reward, info)33 unmodified linesdef _make_obs(self, reward: float, info: Dict[str, Any]) -> HealthcareObservation:# Clamp reward to strictly (0, 1) β framework exposes this at top levelclamped_reward = min(max(float(reward), 0.01), 0.99)return HealthcareObservation(doctor_slots={str(k): v for k, v in self.doctor_slots.items()},patients={str(k): v for k, v in self.patients.items()},78 unmodified lines798081828384853 unmodified lines89909192939495968 unmodified lines10510610710810911011136 unmodified lines14814915015115215315433 unmodified lines18818919019119219319478 unmodified linesself._state = HealthcareState(episode_id=episode_id or str(uuid4()),step_count=0,score=0.1,)return HealthcareObservation(3 unmodified linescurrent_step=self.current_step,info={},done=False,reward=0.1,score=0.1,)def step(self, action: HealthcareAction, **kwargs) -> HealthcareObservation:8 unmodified linescurrent_step=self.current_step,info={"error": "Environment done"},done=True,reward=0.1,score=self._state.score,)36 unmodified lines# Update score based on booking success - strictly between 0 and 1booked = sum(1 for p in self.patients.values() if p["status"] == "booked")self._state.score = min(max(booked / self.num_patients, 0.1), 0.9)return self._make_obs(reward, info)33 unmodified linesdef _make_obs(self, reward: float, info: Dict[str, Any]) -> HealthcareObservation:# Clamp reward to strictly (0, 1) β framework exposes this at top levelclamped_reward = min(max(float(reward), 0.1), 0.9)return HealthcareObservation(doctor_slots={str(k): v for k, v in self.doctor_slots.items()},patients={str(k): v for k, v in self.patients.items()},
269 unmodified lines270271272273274275276277278279280281282283284285286269 unmodified lines# Clamp score strictly to (0, 1)if score <= 0.0:score = 0.01elif score >= 1.0:score = 0.99success = score > 0.5log_end(success=success, steps=steps_taken, rewards=rewards)return steps_taken, rewards, scoreexcept Exception:log_end(success=False, steps=steps_taken, rewards=rewards if rewards else [0.0])return steps_taken, rewards if rewards else [0.0], 0.01# ββ Main inference loop βββββββββββββββββββββββββββββββββββββββββββββ269 unmodified lines270271272273274275276277278279280281282283284285286269 unmodified lines# Clamp score strictly to (0, 1)if score <= 0.0:score = 0.1elif score >= 1.0:score = 0.9success = score > 0.5log_end(success=success, steps=steps_taken, rewards=rewards)return steps_taken, rewards, scoreexcept Exception:log_end(success=False, steps=steps_taken, rewards=rewards if rewards else [0.1])return steps_taken, rewards if rewards else [0.1], 0.1# ββ Main inference loop βββββββββββββββββββββββββββββββββββββββββββββ
6 unmodified lines789101112131415166 unmodified linesdef _clamp(score: float) -> float:"""Clamp score to strictly (0, 1)."""if score != score:return 0.5return min(max(float(score), 0.01), 0.99)def grade(env=None) -> float:6 unmodified lines789101112131415166 unmodified linesdef _clamp(score: float) -> float:"""Clamp score to strictly (0, 1) with safe margins."""if score != score:return 0.5return min(max(float(score), 0.1), 0.9)def grade(env=None) -> float:
6 unmodified lines789101112131415166 unmodified linesdef _clamp(score: float) -> float:"""Clamp score to strictly (0, 1)."""if score != score:return 0.5return min(max(float(score), 0.01), 0.99)def grade(env=None) -> float:6 unmodified lines789101112131415166 unmodified linesdef _clamp(score: float) -> float:"""Clamp score to strictly (0, 1) with safe margins."""if score != score:return 0.5return min(max(float(score), 0.1), 0.9)def grade(env=None) -> float:
6 unmodified lines789101112131415166 unmodified linesdef _clamp(score: float) -> float:"""Clamp score to strictly (0, 1)."""if score != score:return 0.5return min(max(float(score), 0.01), 0.99)def grade(env=None) -> float:6 unmodified lines789101112131415166 unmodified linesdef _clamp(score: float) -> float:"""Clamp score to strictly (0, 1) with safe margins."""if score != score:return 0.5return min(max(float(score), 0.1), 0.9)def grade(env=None) -> float:
env.py+6-6
inference.py+4-4
tasks/book_appointment.py+2-2
tasks/priority_scheduling.py+2-2
tasks/scheduling_conflicts.py+2-2