feat: Add post-optimization tools and mandatory best design archiving

New Tools (tools/):
- analyze_study.py: Generate comprehensive optimization reports
- find_best_iteration.py: Find best iteration folder, optionally copy it
- archive_best_design.py: Archive best design to 3_results/best_design_archive/<timestamp>/

Protocol Updates:
- OP_02_RUN_OPTIMIZATION.md v1.1: Add mandatory archive_best_design step
  in Post-Run Actions. This MUST be done after every optimization run.

V14 Updates:
- run_optimization.py: Auto-archive best design at end of optimization
- optimization_config.json: Expand bounds for V14 continuation
  - lateral_outer_angle: min 13->11 deg (was at 4.7%)
  - lateral_inner_pivot: min 7->5 mm (was at 8.1%)
  - lateral_middle_pivot: max 23->27 mm (was at 99.4%)
  - whiffle_min: max 60->72 mm (was at 96.3%)

Usage:
  python tools/analyze_study.py m1_mirror_adaptive_V14
  python tools/find_best_iteration.py m1_mirror_adaptive_V14
  python tools/archive_best_design.py m1_mirror_adaptive_V14

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Antoine
2025-12-12 10:28:35 -05:00
parent 70ac34e3d3
commit 1bb201e0b7
6 changed files with 913 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ PROTOCOL: Run Optimization
LAYER: Operations
VERSION: 1.0
STATUS: Active
LAST_UPDATED: 2025-12-05
LAST_UPDATED: 2025-12-12
PRIVILEGE: user
LOAD_WITH: []
-->
@@ -237,16 +237,39 @@ Continues from last completed trial. Same study database used.
After optimization completes:
1. **Check results**:
1. **Archive best design** (REQUIRED):
```bash
python -c "import optuna; s=optuna.load_study(...); print(s.best_params)"
python tools/archive_best_design.py {study_name}
```
This copies the best iteration folder to `3_results/best_design_archive/<timestamp>/`
with metadata. **Always do this** to preserve the winning design.
2. **View in dashboard**: `http://localhost:3000`
2. **Analyze results**:
```bash
python tools/analyze_study.py {study_name}
```
Generates comprehensive report with statistics, parameter bounds analysis.
3. **Generate report**: See [OP_04_ANALYZE_RESULTS](./OP_04_ANALYZE_RESULTS.md)
3. **Find best iteration folder**:
```bash
python tools/find_best_iteration.py {study_name}
```
Shows which `iter{N}` folder contains the best design.
4. **Update STUDY_REPORT.md**: Fill in results template
4. **View in dashboard**: `http://localhost:3000`
5. **Generate detailed report**: See [OP_04_ANALYZE_RESULTS](./OP_04_ANALYZE_RESULTS.md)
### Automated Archiving
The `run_optimization.py` script should call `archive_best_design()` automatically
at the end of each run. If implementing a new study, add this at the end:
```python
# At end of optimization
from tools.archive_best_design import archive_best_design
archive_best_design(study_name)
```
---
@@ -294,4 +317,5 @@ If `--neural` flag, uses trained surrogate for fast evaluation.
| Version | Date | Changes |
|---------|------|---------|
| 1.1 | 2025-12-12 | Added mandatory archive_best_design step, analyze_study and find_best_iteration tools |
| 1.0 | 2025-12-05 | Initial release |