feat: Add TrialManager and DashboardDB for unified trial management
- Add TrialManager (trial_manager.py) for consistent trial_NNNN naming - Add DashboardDB (dashboard_db.py) for Optuna-compatible database schema - Update CLAUDE.md with trial management documentation - Update ATOMIZER_CONTEXT.md with v1.8 trial system - Update cheatsheet v2.2 with new utilities - Update SYS_14 protocol to v2.3 with TrialManager integration - Add LAC learnings for trial management patterns - Add archive/README.md for deprecated code policy Key principles: - Trial numbers NEVER reset (monotonic) - Folders NEVER get overwritten - Database always synced with filesystem - Surrogate predictions are NOT trials (only FEA results) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
---
|
||||
skill_id: SKILL_001
|
||||
version: 2.1
|
||||
last_updated: 2025-12-22
|
||||
version: 2.2
|
||||
last_updated: 2025-12-28
|
||||
type: reference
|
||||
code_dependencies:
|
||||
- optimization_engine/extractors/__init__.py
|
||||
- optimization_engine/method_selector.py
|
||||
- optimization_engine/utils/trial_manager.py
|
||||
- optimization_engine/utils/dashboard_db.py
|
||||
requires_skills:
|
||||
- SKILL_000
|
||||
---
|
||||
|
||||
# Atomizer Quick Reference Cheatsheet
|
||||
|
||||
**Version**: 2.1
|
||||
**Updated**: 2025-12-22
|
||||
**Version**: 2.2
|
||||
**Updated**: 2025-12-28
|
||||
**Purpose**: Rapid lookup for common operations. "I want X → Use Y"
|
||||
|
||||
---
|
||||
@@ -406,3 +408,75 @@ class FEARunner:
|
||||
**Reference implementations**:
|
||||
- `studies/m1_mirror_adaptive_V14/run_optimization.py`
|
||||
- `studies/m1_mirror_adaptive_V15/run_optimization.py`
|
||||
|
||||
---
|
||||
|
||||
## Trial Management Utilities
|
||||
|
||||
### TrialManager - Unified Trial Folder + DB Management
|
||||
|
||||
```python
|
||||
from optimization_engine.utils.trial_manager import TrialManager
|
||||
|
||||
tm = TrialManager(study_dir)
|
||||
|
||||
# Start new trial (creates folder, saves params)
|
||||
trial = tm.new_trial(
|
||||
params={'rib_thickness': 10.5, 'mirror_face_thickness': 17.0},
|
||||
source="turbo",
|
||||
metadata={'turbo_batch': 1, 'predicted_ws': 42.0}
|
||||
)
|
||||
# Returns: {'trial_id': 47, 'trial_number': 47, 'folder_path': Path(...)}
|
||||
|
||||
# After FEA completes
|
||||
tm.complete_trial(
|
||||
trial_number=trial['trial_number'],
|
||||
objectives={'wfe_40_20': 5.63, 'mass_kg': 118.67},
|
||||
weighted_sum=42.5,
|
||||
is_feasible=True
|
||||
)
|
||||
|
||||
# Mark failed trial
|
||||
tm.fail_trial(trial_number=47, error="NX solver timeout")
|
||||
```
|
||||
|
||||
### DashboardDB - Optuna-Compatible Database
|
||||
|
||||
```python
|
||||
from optimization_engine.utils.dashboard_db import DashboardDB, convert_custom_to_optuna
|
||||
|
||||
# Create new dashboard-compatible database
|
||||
db = DashboardDB(db_path, study_name="my_study")
|
||||
|
||||
# Log a trial
|
||||
trial_id = db.log_trial(
|
||||
params={'rib_thickness': 10.5},
|
||||
objectives={'wfe_40_20': 5.63, 'mass_kg': 118.67},
|
||||
weighted_sum=42.5,
|
||||
is_feasible=True,
|
||||
state="COMPLETE"
|
||||
)
|
||||
|
||||
# Mark best trial
|
||||
db.mark_best(trial_id)
|
||||
|
||||
# Get summary
|
||||
summary = db.get_summary()
|
||||
|
||||
# Convert existing custom database to Optuna format
|
||||
convert_custom_to_optuna(db_path, study_name)
|
||||
```
|
||||
|
||||
### Trial Naming Convention
|
||||
|
||||
```
|
||||
2_iterations/
|
||||
├── trial_0001/ # Zero-padded, monotonically increasing
|
||||
├── trial_0002/ # NEVER reset, NEVER overwritten
|
||||
└── trial_0003/
|
||||
```
|
||||
|
||||
**Key principles**:
|
||||
- Trial numbers **NEVER reset** across study lifetime
|
||||
- Surrogate predictions (5K per batch) are NOT logged as trials
|
||||
- Only FEA-validated results become trials
|
||||
|
||||
Reference in New Issue
Block a user