CoolFace
Apppublic

s123hree/green-code-optimizer-a100

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
openenv.yaml64 linesDownload Raw Back to root
1name: green-code-optimizer2version: "1.0.0"3description: >-4  OpenEnv RL environment that trains a code agent to refactor Python for energy5  efficiency. The agent is rewarded for reducing CPU cycles and peak memory6  while preserving program logic. A graphlet analyzer represents control-flow7  patterns (nested loops, expensive calls, deep branching) so the agent learns8  which structures are "expensive" and swaps them for "cheap" alternatives. A9  CO2-savings dashboard converts the reduction into real-world impact (kg CO210  saved per year, tree-equivalents, car-km equivalents).11endpoints:12  reset: POST /reset13  step: POST /step14  state: GET /state/{episode_id}15  rubric: GET /rubric16  health: GET /health17observation_space:18  files: dict19  violation_report: dict20  steps_remaining: int21  curriculum_level: int22action_space:23  tools: [read_file, edit_file, run_tests, check_compliance]24 25# Reward is implemented as a composable Rubric (RFC 004).26# Source: environment/rubrics.py — extends openenv.core.rubrics.Rubric when27# openenv-core is installed; falls back to an API-compatible local shim otherwise.28rubric:29  type: openenv.core.rubrics.containers.Sequential30  formula: "R = (syntax_gate ∧ hack_gate) × (0.70·green + 0.30·compliance)"31  children:32    syntax_gate:33      type: leaf34      range: [0.0, 1.0]35      gate: true36      description: "Binary gate — 1.0 iff all refactored files parse"37    hack_gate:38      type: leaf39      range: [-1.0, 1.0]40      gate: true41      description: "Binary gate — penalises tampering with test/conftest files"42    green:43      type: openenv.core.rubrics.containers.WeightedSum44      weight: 0.7045      children:46        graphlet:47          weight: 0.4048          description: "Avoidance of costly control-flow graphlets"49        cpu:50          weight: 0.3551          description: "Relative CPU-time reduction vs. original code"52        memory:53          weight: 0.2554          description: "Relative peak-memory reduction vs. original code"55    compliance:56      type: leaf57      weight: 0.3058      description: "Fraction of active engineering rules satisfied"59  efficiency_penalty:60    per_edit: 0.0161    note: "Held outside the rubric — training-time minimal-edits nudge"62reward_range: [-1.0, 1.0]63max_steps: 7064