Spaces:
Sleeping
Sleeping
Subhash Vadaparthi commited on
Commit Β·
a5934b3
1
Parent(s): 2e8afb0
CRITICAL: auto-reset in __init__, clamp ALL rewards to (0.01, 0.99) - framework was creating env without reset, causing empty state and out-of-range values
Browse files44 unmodified lines454647484950512 unmodified lines54555657585937 unmodified lines9798991001011021039 unmodified lines11311411511611711811975 unmodified lines1951961971981992001 unmodified line20220320420520620720844 unmodified linesself._seed = seedself._state = HealthcareState(episode_id=str(uuid4()), step_count=0)# Internal state (populated by reset)self.doctor_slots: Dict[int, List[bool]] = {}self.patients: Dict[int, Dict[str, Any]] = {}self.waiting_queue: List[int] = []2 unmodified linesself.done: bool = Falseself._action_history: List[Dict[str, Any]] = []# ββ OpenEnv Interface βββββββββββββββββββββββββββββββββββββββββββββdef reset(self, seed=None, episode_id=None, **kwargs) -> HealthcareObservation:37 unmodified linescurrent_step=self.current_step,info={},done=False,reward=0.0,score=0.01,)9 unmodified linescurrent_step=self.current_step,info={"error": "Environment done"},done=True,reward=0.0,score=self._state.score,)75 unmodified lines# ββ Internal helpers βββββββββββββββββββββββββββββββββββββββββββββdef _make_obs(self, reward: float, info: Dict[str, Any]) -> HealthcareObservation: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()},1 unmodified linecurrent_step=self.current_step,info=info,done=self.done,reward=reward,score=self._state.score,)44 unmodified lines454647484950512 unmodified lines5455565758596061626337 unmodified lines1011021031041051061079 unmodified lines11711811912012112212375 unmodified lines1992002012022032042052061 unmodified line20820921021121221321444 unmodified linesself._seed = seedself._state = HealthcareState(episode_id=str(uuid4()), step_count=0)# Internal stateself.doctor_slots: Dict[int, List[bool]] = {}self.patients: Dict[int, Dict[str, Any]] = {}self.waiting_queue: List[int] = []2 unmodified linesself.done: bool = Falseself._action_history: List[Dict[str, Any]] = []# Auto-reset so the env is usable immediately after __init__self.reset()# ββ OpenEnv Interface βββββββββββββββββββββββββββββββββββββββββββββdef reset(self, seed=None, episode_id=None, **kwargs) -> HealthcareObservation:37 unmodified linescurrent_step=self.current_step,info={},done=False,reward=0.01,score=0.01,)9 unmodified linescurrent_step=self.current_step,info={"error": "Environment done"},done=True,reward=0.01,score=self._state.score,)75 unmodified lines# ββ Internal helpers βββββββββββββββββββββββββββββββββββββββββββββdef _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()},1 unmodified linecurrent_step=self.current_step,info=info,done=self.done,reward=clamped_reward,score=self._state.score,)
env.py+10-4