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 lines45464748484950512 unmodified lines5455565758596061626337 unmodified lines1011021031001041051061079 unmodified lines11711811911612012112212375 unmodified lines1992002012022032042052061 unmodified line20820921020521121221321444 unmodified lines self._seed = seed self._state = HealthcareState(episode_id=str(uuid4()), step_count=0)
# Internal state (populated by reset) # Internal state self.doctor_slots: Dict[int, List[bool]] = {} self.patients: Dict[int, Dict[str, Any]] = {} self.waiting_queue: List[int] = []2 unmodified lines self.done: bool = False self._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 lines current_step=self.current_step, info={}, done=False, reward=0.0, reward=0.01, score=0.01, )
9 unmodified lines current_step=self.current_step, info={"error": "Environment done"}, done=True, reward=0.0, 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 level clamped_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 line current_step=self.current_step, info=info, done=self.done, reward=reward, reward=clamped_reward, score=self._state.score, )
env.py+10-4