Implements JSON Schema validation for optimization configurations to ensure
consistency across all studies and prevent configuration errors.
Added:
- optimization_engine/schemas/optimization_config_schema.json
- Comprehensive schema for Protocol 10 & 11 configurations
- Validates objectives, constraints, design variables, simulation settings
- Enforces standard field names (goal, bounds, parameter, threshold)
- optimization_engine/config_manager.py
- ConfigManager class with schema validation
- CLI tool: python config_manager.py <config.json>
- Type-safe accessor methods for config elements
- Custom validations: bounds check, multi-objective consistency, location check
- optimization_engine/schemas/README.md
- Complete documentation of standard configuration format
- Validation examples and common error fixes
- Migration guidance for legacy configs
- docs/07_DEVELOPMENT/Phase_1_2_Implementation_Plan.md
- Detailed implementation plan for remaining Phase 1.2 tasks
- Migration tool design, integration guide, testing plan
Testing:
- Validated drone_gimbal_arm_optimization config successfully
- ConfigManager works with drone_gimbal format (new standard)
- Identifies legacy format issues in bracket studies
Standards Established:
- Configuration location: studies/{name}/1_setup/
- Objective direction: "goal" not "type"
- Design var bounds: "bounds": [min, max] not "min"/"max"
- Design var name: "parameter" not "name"
- Constraint threshold: "threshold" not "value"
Next Steps (Phase 1.2.1+):
- Config migration tool for legacy studies
- Integration with run_optimization.py
- Update create-study Claude skill with schema reference
- Migrate bracket studies to new format
Relates to: Phase 1.2 MVP Development Plan
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
5.6 KiB
5.6 KiB
Atomizer Configuration Schemas
This directory contains JSON Schema files for validating Atomizer optimization study configurations.
Files
- optimization_config_schema.json - Schema for
optimization_config.jsonfiles- Validates study configuration including objectives, constraints, design variables
- Ensures consistency across all studies
- Based on Protocol 10 (single-objective) and Protocol 11 (multi-objective) standards
Usage
Validate a Configuration
Use the ConfigManager CLI tool:
python optimization_engine/config_manager.py studies/your_study/1_setup/optimization_config.json
In Python Code
from pathlib import Path
from optimization_engine.config_manager import ConfigManager
config_path = Path("studies/my_study/1_setup/optimization_config.json")
manager = ConfigManager(config_path)
manager.load_config()
if manager.validate():
print("Configuration is valid")
design_vars = manager.get_design_variables()
objectives = manager.get_objectives()
else:
print(manager.get_validation_report())
Schema Standards
Standard Configuration Format
Based on the drone_gimbal_arm_optimization study, the standard format is:
{
"study_name": "study_name_lowercase_with_underscores",
"description": "Brief description of optimization problem",
"engineering_context": "Real-world scenario and requirements",
"optimization_settings": {
"protocol": "protocol_11_multi_objective", // or protocol_10_single_objective
"n_trials": 30,
"sampler": "NSGAIISampler", // or TPESampler, CmaEsSampler
"pruner": null,
"timeout_per_trial": 600
},
"design_variables": [
{
"parameter": "nx_expression_name",
"bounds": [min, max],
"description": "What this parameter controls"
}
],
"objectives": [
{
"name": "objective_name",
"goal": "minimize", // or "maximize"
"weight": 1.0,
"description": "What this measures",
"target": 100.0, // optional
"extraction": {
"action": "extract_mass", // or extract_stress, extract_displacement, etc.
"domain": "result_extraction",
"params": {
"result_type": "mass",
"metric": "total"
}
}
}
],
"constraints": [
{
"name": "constraint_name",
"type": "less_than", // or "greater_than"
"threshold": 100.0,
"description": "Engineering justification",
"extraction": {
"action": "extract_displacement",
"domain": "result_extraction",
"params": {
"result_type": "displacement",
"metric": "max"
}
}
}
],
"simulation": {
"model_file": "Model.prt",
"sim_file": "Model_sim1.sim",
"fem_file": "Model_fem1.fem",
"solver": "nastran",
"analysis_types": ["static", "modal"]
},
"reporting": {
"generate_plots": true,
"save_incremental": true,
"llm_summary": false
}
}
Field Name Standards
IMPORTANT: Use these field names (not legacy alternatives):
| Field | Standard Name | Legacy (DON'T USE) |
|---|---|---|
| Objective direction | "goal" |
"type" |
| Design var bounds | "bounds": [min, max] |
"min": X, "max": Y" |
| Design var name | "parameter" |
"name" |
| Constraint limit | "threshold" |
"value" |
File Location Standard
Configuration files MUST be in the 1_setup/ directory:
studies/your_study/
├── 1_setup/
│ ├── optimization_config.json ← HERE
│ └── workflow_config.json
├── 2_results/
└── run_optimization.py
Validation Rules
The schema enforces:
- Study Name: Lowercase with underscores, 3-100 characters
- Design Variable Bounds: min < max
- Multi-Objective Consistency:
- 2-3 objectives → protocol_11_multi_objective + NSGAIISampler
- 1 objective → protocol_10_single_objective + TPESampler/CmaEsSampler
- Extraction Specs: All objectives and constraints must have extraction blocks
- File Extensions: .prt, .sim, .fem
- Analysis Types: static, modal, thermal, or buckling
Common Validation Errors
Error: "min must be < max"
// BAD
{"parameter": "thickness", "bounds": [10, 5]}
// GOOD
{"parameter": "thickness", "bounds": [5, 10]}
Error: "Multi-objective should use NSGAIISampler"
// BAD
{
"objectives": [{...}, {...}], // 2 objectives
"optimization_settings": {"sampler": "TPESampler"} // Wrong sampler!
}
// GOOD
{
"objectives": [{...}, {...}],
"optimization_settings": {"sampler": "NSGAIISampler"}
}
Error: "Config should be in 1_setup/"
Move your configuration file from study root to 1_setup/ directory.
Dependencies
The ConfigManager requires:
pip install jsonschema>=4.17.0
Migration from Legacy Format
If you have old configuration files with:
"type"instead of"goal"in objectives"min"/"max"instead of"bounds"in design variables"name"instead of"parameter"in design variables"value"instead of"threshold"in constraints
See the migration tool (coming in Phase 1.2.1):
python optimization_engine/config_migrator.py studies/old_study/optimization_config.json
References
Questions?
For MVP development questions, refer to DEVELOPMENT.md or the MVP plan in docs/07_DEVELOPMENT/Today_Todo.md.