Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse filesFiles changed (2)
318 unmodified lines319320321322323324325326327328329318 unmodified linesfinally:score = grade(task_name, cumulative)ws.close()print(f"[END] {json.dumps({'task': task_name, 'cumulative_profit': round(cumulative, 4), 'score': round(score, 4), 'profit_target': task.profit_target})}",flush=True,)# ββ Main βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ318 unmodified lines319320321322323324325326327328329330331332318 unmodified linesfinally:score = grade(task_name, cumulative)print(f"[END] {json.dumps({'task': task_name, 'cumulative_profit': round(cumulative, 4), 'score': round(score, 4), 'profit_target': task.profit_target})}",flush=True,)try:ws.close()except Exception:pass# ββ Main βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
487 unmodified lines4884894904914924934944954964974984992 unmodified lines502503504505506507508509510511512513514487 unmodified linesdef _normalize_reward(self, step_profit: float) -> float:"""Map raw step profit to a meaningful reward in (0.0, 1.0) using asigmoid centered at break-even (step_profit = 0).Formula:x = step_profit / per_step_target (normalise by average needed per step)reward = sigmoid(k * x) = 1 / (1 + exp(-k * x))Where k=2 gives a useful spread:step_profit = 0 -> 0.50 (neutral, broke even)2 unmodified linesstep_profit = -per_step_tgt -> 0.12 (below break-even)step_profit = -2*per_step_tgt -> 0.02 (large penalty step)This gives the model a continuous, differentiable gradient signalacross the full [0, 1] range β much more informative than a hard clamp.Raw dollar profit is preserved in last_step_profit and metadata."""per_step_target = self._profit_target / self._max_stepsx = step_profit / per_step_target if per_step_target != 0 else 0.0return round(1.0 / (1.0 + math.exp(-2.0 * x)), 6)def _zone_occupancy(self) -> Dict[int, int]:"""Count active products in each zone."""487 unmodified lines4884894904914924934944954964974984992 unmodified lines502503504505506507508509510511512513514515516487 unmodified linesdef _normalize_reward(self, step_profit: float) -> float:"""Map raw step profit to a meaningful reward strictly in (0.001, 0.999) using asigmoid centered at break-even (step_profit = 0).Formula:x = step_profit / per_step_target (normalise by average needed per step)reward = clamp(sigmoid(k * x), 0.001, 0.999)Where k=2 gives a useful spread:step_profit = 0 -> 0.50 (neutral, broke even)2 unmodified linesstep_profit = -per_step_tgt -> 0.12 (below break-even)step_profit = -2*per_step_tgt -> 0.02 (large penalty step)x is clamped to [-7, 7] to prevent math.exp() OverflowError on extremeprofits, and the result is clamped to (0.001, 0.999) to ensure the rewardis never exactly 0.0 or 1.0."""per_step_target = self._profit_target / self._max_stepsx = step_profit / per_step_target if per_step_target != 0 else 0.0x = max(-7.0, min(7.0, x))raw = 1.0 / (1.0 + math.exp(-2.0 * x))return round(max(0.001, min(0.999, raw)), 6)def _zone_occupancy(self) -> Dict[int, int]:"""Count active products in each zone."""
inference.py+4-1
server/StoreManager_environment.py+8-6