{"data":{"kind":"file","path":"README.md","version_id":"hzdy9s75ed9dg0bz8gedaeuw","entry":{"name":"README.md","path":"README.md","is_directory":false,"size":5125,"modified_at":"2026-07-07T04:50:51.922000","content_hash":"6f287764b47299faf9712f12ebf4d1ebf3e15332281355373b766a7a30004020"},"entries":[],"content":"# economic-dispatch\n\nSingle-turn power-systems economic dispatch RL environment for the `verifiers` library / Prime Intellect Environments Hub. Faithful rebuild of the June 2026 design; the control rung of a power-systems vertical.\n\n## Task\nGiven online generators — each with a linear cost ($/MWh) and operating range [Pmin, Pmax] — and a system load (MW), output the least-cost dispatch as JSON: `{\"G1\": 12.3, \"G2\": 80.0, ...}` such that total generation equals load and every unit respects its range.\n\n## Ground truth\nFor linear costs with box constraints and one balance equality, the optimum is the closed-form merit-order fill (commit every Pmin, then buy cheapest headroom first). Cross-checked against `scipy.optimize.linprog` (HiGHS): **200/200 instances, 0 mismatches.**\n\n## Rewards\n| Function | Measures | Weight |\n|---|---|---|\n| `reward_format` | Parseable JSON naming exactly the right units | 0.10 |\n| `reward_power_balance` | sum(MW) matches load; linear falloff | 0.30 |\n| `reward_limits` | Fraction of units within [Pmin, Pmax] | 0.20 |\n| `reward_cost` | optimal/actual cost ratio, **hard-gated on feasibility** | 0.40 |\n\nThe feasibility gate on `reward_cost` is the anti-reward-hacking mechanism: dumping all load on the cheapest unit scores 0 on cost regardless of how cheap it looks. Verified in `tests/test_validation.py` (6 attack-gate tests, all passing — including NaN/Infinity JSON literals and tolerance-rent under-generation, which is settled at a 2× imbalance penalty price).\n\n## Baseline results\n\n50 instances, 1 rollout each, July 2026:\n\n| Model | total | format | balance | limits | cost |\n|---|---|---|---|---|---|\n| claude-haiku-4-5 | 0.861 | 1.000 | 1.000 | 0.904 | 0.700 |\n| claude-opus-4-8 | **1.000** | 1.000 | 1.000 | 1.000 | 1.000 |\n\nRead this honestly: **frontier models saturate this task** — pure merit-order\ndispatch is solved reasoning. This environment is the baseline rung of the\nvertical: useful for small-model training/eval and as the control condition\nproving what its successor breaks. The same claude-opus-4-8 that scores a\nperfect 1.000 here drops to 0.901 — and claude-haiku-4-5 to 0.520 — on\n[dcopf-grid-verifiers](https://github.com/JWilksBooth/dcopf-grid-verifiers),\nwhich adds transmission-network physics so that merit-order reasoning is\nprovably infeasible on 46% of instances. The delta between the two\nenvironments isolates exactly one skill: congestion-aware dispatch.\n\nReproduce:\n\n```bash\nvf-eval economic-dispatch -p anthropic -m claude-haiku-4-5-20251001 -n 50 -r 1 --max-tokens 4000 --save-results\nvf-eval economic-dispatch -p anthropic -m claude-opus-4-8 -n 50 -r 1 --max-tokens 12000 --save-results\n```\n\n## Example failure (claude-haiku-4-5, from the baseline run)\n\n> *\"G1: 0 MW (not used - it's expensive) ... Total: 155.8 + 33.7 = 189.5 MW ✓ ... This is optimal since we've used only the two cheapest available generators to meet the exact load requirement, and all constraints are satisfied. {\"G1\": 0.0, \"G2\": 155.8, \"G3\": 0.0, \"G4\": 33.7, \"G5\": 0.0}\"*\n\nThe merit-order ranking is flawless — the model just answered a different problem. Every unit here is *online*: dispatch, unlike unit commitment, cannot switch one off, and the three units it \"didn't use\" have minimums of 37.2, 30.9, and 11.7 MW. Balance is exact, but with 3 of 5 units below Pmin the limits reward is **0.4** and the cost reward hard-gates to **0** — total 0.48. Rollouts are stochastic; the graded verdict is deterministic:\n\n```python\nimport economic_dispatch as env\ninst = env.generate_instance(5)   # the instance behind example 5 of the baseline run\nd = '{\"G1\": 0.0, \"G2\": 155.8, \"G3\": 0.0, \"G4\": 33.7, \"G5\": 0.0}'\nenv.reward_limits(d, inst), env.reward_cost(d, inst)   # -> (0.4, 0.0)\n```\n\n## Usage\n```python\nfrom economic_dispatch import load_environment\nenv = load_environment(num_examples=300)\n```\n```bash\nN_INSTANCES=200 python tests/test_validation.py\nvf-eval economic-dispatch -m <model> -n 50\n```\n\n## The vertical\nThis is the control rung. Its successors defeat exactly the merit-order reasoning it rewards:\n- [dcopf-grid-verifiers](https://github.com/JWilksBooth/dcopf-grid-verifiers) — DC optimal power flow with line limits; 46% of instances make the network-unconstrained merit-order dispatch infeasible (congestion / space).\n- [multiperiod-dispatch](https://github.com/JWilksBooth/multiperiod-dispatch) — ramp-limited multi-period dispatch; 74% defeat per-period merit order (ramp coupling / time).\n- [n1-contingency-dispatch](https://github.com/JWilksBooth/n1-contingency-dispatch) — N-1 security-constrained DC-OPF; 68% defeat the plain OPF optimum (security / uncertainty).\n- [nodal-pricing-lmp](https://github.com/JWilksBooth/nodal-pricing-lmp) — LMP dual-space pricing; 44% of instances price some bus outside the offer band (price formation / dual space).\n\nRobotics vertical (same validation discipline): [robot-cycle-time](https://github.com/JWilksBooth/robot-cycle-time) (motion), [bimanual-chore-scheduling](https://github.com/JWilksBooth/bimanual-chore-scheduling) (orchestration).\n\nNext: unit-commitment / storage arbitrage.\n","encoding":"utf-8","truncated":false,"total_bytes":5125},"status":null}