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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Task Graders Documentation
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
|
| 5 |
+
The Energy & Memory RAM Optimization Environment includes **3 task graders** (meeting the minimum requirement of >= 3) that evaluate agent performance on a continuous 0.0-1.0 scale. Each grader represents a real-world optimization scenario with increasing difficulty.
|
| 6 |
+
|
| 7 |
+
## ✅ Validation Summary
|
| 8 |
+
|
| 9 |
+
| Requirement | Status | Details |
|
| 10 |
+
|-------------|--------|---------|
|
| 11 |
+
| Minimum 3 graders | ✅ PASS | 3 graders implemented |
|
| 12 |
+
| Different scores | ✅ PASS | Each grader returns varied scores 0.0-1.0 based on performance |
|
| 13 |
+
| Real-world relevance | ✅ PASS | Each grader models actual data center/edge computing scenarios |
|
| 14 |
+
| Metadata & discovery | ✅ PASS | Graders exposed via API endpoints and manifest files |
|
| 15 |
+
|
| 16 |
+
## Grader Details
|
| 17 |
+
|
| 18 |
+
### Task 1: Basic RAM Reduction (Easy - Difficulty 1)
|
| 19 |
+
|
| 20 |
+
**Location**: `task_graders.py::task_1_basic_ram_reduction_grader()`
|
| 21 |
+
|
| 22 |
+
**Real-World Application**:
|
| 23 |
+
- Memory optimization for IoT devices, mobile systems, and edge computing
|
| 24 |
+
- Preventing out-of-memory errors on resource-constrained devices
|
| 25 |
+
- Improving system responsiveness during high loads
|
| 26 |
+
|
| 27 |
+
**Target**: RAM < 70%, Energy < 7.5 kWh, within 10 steps
|
| 28 |
+
|
| 29 |
+
**Scoring Formula**:
|
| 30 |
+
```
|
| 31 |
+
Score = (RAM_Score × 0.4) + (Energy_Score × 0.4) + (Step_Efficiency × 0.2)
|
| 32 |
+
|
| 33 |
+
Where:
|
| 34 |
+
RAM_Score = (100 - RAM_usage) / (100 - 70) clamped to [0, 1]
|
| 35 |
+
Energy_Score = (10 - Energy_consumption) / (10 - 7.5) clamped to [0, 1]
|
| 36 |
+
Step_Efficiency = 1.0 if steps ≤ 10, else max(0, 1 - (steps-10) × 0.1)
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
**Score Examples**:
|
| 40 |
+
| Performance Level | RAM | Energy | Steps | Score |
|
| 41 |
+
|------------------|-----|--------|-------|-------|
|
| 42 |
+
| Worst | 100.0% | 10.0 kWh | 50 | 0.000 |
|
| 43 |
+
| Poor | 90.0% | 9.0 kWh | 20 | 0.293 |
|
| 44 |
+
| Medium | 75.0% | 8.0 kWh | 8 | 0.853 |
|
| 45 |
+
| Good | 70.0% | 7.5 kWh | 5 | **1.000** |
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
### Task 2: Energy Optimization (Medium - Difficulty 2)
|
| 50 |
+
|
| 51 |
+
**Location**: `task_graders.py::task_2_energy_optimization_grader()`
|
| 52 |
+
|
| 53 |
+
**Real-World Application**:
|
| 54 |
+
- Energy efficiency optimization for large-scale data centers
|
| 55 |
+
- Reducing operational costs (1% energy = millions in savings)
|
| 56 |
+
- Meeting sustainability and carbon footprint goals for cloud providers
|
| 57 |
+
|
| 58 |
+
**Target**: RAM < 75%, Energy < 6 kWh, within 15 steps
|
| 59 |
+
|
| 60 |
+
**Scoring Formula**:
|
| 61 |
+
```
|
| 62 |
+
Score = (Energy_Score × 0.5) + (RAM_Constraint × 0.25) + (Step_Efficiency × 0.25)
|
| 63 |
+
|
| 64 |
+
Where:
|
| 65 |
+
Energy_Score = (10 - Energy_consumption) / (10 - 6) clamped to [0, 1] (Primary objective)
|
| 66 |
+
RAM_Constraint = 1.0 if RAM ≤ 75, else max(0, 1 - overage/5) (Hard constraint)
|
| 67 |
+
Step_Efficiency = 1.0 if steps ≤ 15, else max(0, 1 - (steps-15) × 0.08)
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
**Score Examples**:
|
| 71 |
+
| Performance Level | RAM | Energy | Steps | Score |
|
| 72 |
+
|------------------|-----|--------|-------|-------|
|
| 73 |
+
| Worst | 100.0% | 10.0 kWh | 50 | 0.000 |
|
| 74 |
+
| Fair | 85.0% | 7.0 kWh | 20 | 0.525 |
|
| 75 |
+
| Good | 75.0% | 6.0 kWh | 10 | **1.000** |
|
| 76 |
+
| Excellent | 65.0% | 5.0 kWh | 8 | **1.000** |
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
### Task 3: Balanced Optimization (Hard - Difficulty 3)
|
| 81 |
+
|
| 82 |
+
**Location**: `task_graders.py::task_3_balanced_optimization_grader()`
|
| 83 |
+
|
| 84 |
+
**Real-World Application**:
|
| 85 |
+
- Production system optimization with dual resource constraints
|
| 86 |
+
- Cloud infrastructure managing multi-tenant workloads
|
| 87 |
+
- Edge computing with simultaneous memory and energy limitations
|
| 88 |
+
|
| 89 |
+
**Target**: RAM < 60%, Energy < 5 kWh, within 20 steps
|
| 90 |
+
|
| 91 |
+
**Scoring Formula**:
|
| 92 |
+
```
|
| 93 |
+
Score = (Balance_Score × 0.9) + Step_Bonus
|
| 94 |
+
|
| 95 |
+
Balance_Score = ((RAM_Score × 0.5) + (Energy_Score × 0.5)) [Both must be optimized equally]
|
| 96 |
+
|
| 97 |
+
Where:
|
| 98 |
+
RAM_Score = (100 - RAM_usage) / (100 - 60) clamped to [0, 1]
|
| 99 |
+
Energy_Score = (10 - Energy_consumption) / (10 - 5) clamped to [0, 1]
|
| 100 |
+
Step_Bonus = min(0.1, (20 - steps)/20 × 0.1) if steps ≤ 20, else -(steps-20) × 0.05
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
**Score Examples**:
|
| 104 |
+
| Performance Level | RAM | Energy | Steps | Score |
|
| 105 |
+
|------------------|-----|--------|-------|-------|
|
| 106 |
+
| Worst | 100.0% | 10.0 kWh | 50 | 0.000 |
|
| 107 |
+
| Fair | 70.0% | 6.0 kWh | 25 | 0.497 |
|
| 108 |
+
| Good | 60.0% | 5.0 kWh | 20 | 0.900 |
|
| 109 |
+
| Excellent | 50.0% | 4.0 kWh | 15 | **0.925** |
|
| 110 |
+
|
| 111 |
+
---
|
| 112 |
+
|
| 113 |
+
## How Graders Are Discoverable
|
| 114 |
+
|
| 115 |
+
### 1. **Direct Python Import**
|
| 116 |
+
```python
|
| 117 |
+
from he_demo.task_graders import TASK_GRADERS, get_grader, get_grader_metadata
|
| 118 |
+
|
| 119 |
+
# Get all graders
|
| 120 |
+
all_graders = TASK_GRADERS # 3 graders available
|
| 121 |
+
print(len(all_graders)) # Output: 3
|
| 122 |
+
|
| 123 |
+
# Get specific grader metadata
|
| 124 |
+
metadata = get_grader_metadata("basic_ram_reduction")
|
| 125 |
+
print(metadata["real_world_application"])
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
### 2. **Manifest Files**
|
| 129 |
+
- **`graders.json`**: JSON manifest with all grader metadata and examples
|
| 130 |
+
- **`graders_manifest.py`**: Python validation module with discovery functions
|
| 131 |
+
|
| 132 |
+
### 3. **API Endpoints** (when server is running)
|
| 133 |
+
```bash
|
| 134 |
+
# List all graders
|
| 135 |
+
GET http://localhost:8000/graders
|
| 136 |
+
|
| 137 |
+
# Get specific grader info
|
| 138 |
+
GET http://localhost:8000/graders/basic_ram_reduction
|
| 139 |
+
|
| 140 |
+
# Comprehensive grader information
|
| 141 |
+
GET http://localhost:8000/graders/info
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
### 4. **Environment Properties**
|
| 145 |
+
```python
|
| 146 |
+
from server.he_demo_environment import EnergyOptimizationEnvironment
|
| 147 |
+
|
| 148 |
+
env = EnergyOptimizationEnvironment()
|
| 149 |
+
|
| 150 |
+
# Access graders through environment
|
| 151 |
+
graders = env.graders # Dictionary of all graders
|
| 152 |
+
metadata = env.grader_metadata # All metadata
|
| 153 |
+
score = env.grade_task("basic_ram_reduction", observation) # Grade an observation
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
---
|
| 157 |
+
|
| 158 |
+
## Validation Features
|
| 159 |
+
|
| 160 |
+
All 3 graders demonstrate:
|
| 161 |
+
|
| 162 |
+
✅ **Different Scores**: Each grader returns varied scores (0.0 to 1.0) for different performance levels
|
| 163 |
+
|
| 164 |
+
✅ **Real-World Context**:
|
| 165 |
+
- Task 1: Edge computing & IoT memory constraints
|
| 166 |
+
- Task 2: Data center energy efficiency & cost reduction
|
| 167 |
+
- Task 3: Production dual-constraint optimization
|
| 168 |
+
|
| 169 |
+
✅ **Continuous Scoring**: Scores smoothly transition from 0.0 (worst) to 1.0 (best) based on actual metrics
|
| 170 |
+
|
| 171 |
+
✅ **Detailed Methodology**: Each grader includes:
|
| 172 |
+
- Explicit scoring formula
|
| 173 |
+
- Performance examples with actual scores
|
| 174 |
+
- Real-world application explanation
|
| 175 |
+
- Target thresholds and constraints
|
| 176 |
+
|
| 177 |
+
✅ **Easy Discovery**: Graders accessible via:
|
| 178 |
+
- Python imports (`from task_graders import ...`)
|
| 179 |
+
- JSON manifest (`graders.json`)
|
| 180 |
+
- API endpoints (`/graders/*`)
|
| 181 |
+
- Validation manifest (`graders_manifest.py`)
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
+
## Testing & Validation
|
| 186 |
+
|
| 187 |
+
Run the comprehensive validation script:
|
| 188 |
+
```bash
|
| 189 |
+
python validate_comprehensive.py
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
This tests:
|
| 193 |
+
1. All 3 graders are present
|
| 194 |
+
2. Each grader returns different scores
|
| 195 |
+
3. Scores match expected ranges
|
| 196 |
+
4. Metadata is accessible
|
| 197 |
+
5. Environment integration works
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
## Example: Getting Grader Scores
|
| 202 |
+
|
| 203 |
+
```python
|
| 204 |
+
from task_graders import get_grader
|
| 205 |
+
from models import EnergyOptimizationObservation
|
| 206 |
+
|
| 207 |
+
# Create observation for a specific performance level
|
| 208 |
+
obs = EnergyOptimizationObservation(
|
| 209 |
+
ram_usage=75.0,
|
| 210 |
+
energy_consumption=8.0,
|
| 211 |
+
system_load=0.5,
|
| 212 |
+
current_task=None,
|
| 213 |
+
tasks_completed=[],
|
| 214 |
+
steps_taken=8,
|
| 215 |
+
task_progress=0.0,
|
| 216 |
+
efficiency_score=0.0,
|
| 217 |
+
done=False,
|
| 218 |
+
reward=0.0
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
# Get grader for Task 1
|
| 222 |
+
grader = get_grader("basic_ram_reduction")
|
| 223 |
+
|
| 224 |
+
# Calculate score
|
| 225 |
+
score = grader(obs)
|
| 226 |
+
print(f"Performance Score: {score:.3f}") # Output: 0.853
|
| 227 |
+
```
|
| 228 |
+
|
| 229 |
+
---
|
| 230 |
+
|
| 231 |
+
## Summary
|
| 232 |
+
|
| 233 |
+
The Energy & Memory RAM Optimization Environment includes **3 explicit, discoverable task graders** that:
|
| 234 |
+
- Meet the minimum requirement (>= 3)
|
| 235 |
+
- Return different scores (0.0-1.0) for different performance
|
| 236 |
+
- Model real-world resource optimization scenarios
|
| 237 |
+
- Are easily discoverable via multiple methods
|
| 238 |
+
- Provide continuous performance feedback to agents
|