feat: Add optimization configuration builder with multi-objective support

Created interactive configuration builder that discovers available
options and helps users set up multi-objective optimization with constraints.

Features:
- Lists all available design variables from discovered model
- Provides catalog of objectives (minimize mass, stress, displacement, volume)
- Provides catalog of constraints (max stress, max displacement, mass limits)
- Suggests reasonable bounds for design variables based on type
- Supports multi-objective optimization with configurable weights
- Validates and builds complete optimization_config.json

Available Objectives:
- minimize_mass: Weight reduction (weight: 5.0)
- minimize_max_stress: Failure prevention (weight: 10.0)
- minimize_max_displacement: Stiffness (weight: 3.0)
- minimize_volume: Material usage (weight: 4.0)

Available Constraints:
- max_stress_limit: Stress <= limit (typical: 200 MPa)
- max_displacement_limit: Displacement <= limit (typical: 1.0 mm)
- min_mass_limit: Mass >= limit (structural integrity)
- max_mass_limit: Mass <= limit (weight budget)

Example Configuration:
- Design Variables: tip_thickness, support_angle, support_blend_radius
- Objectives: Minimize mass (5.0) + Minimize stress (10.0)
- Constraints: max_displacement <= 1.0 mm, max_stress <= 200 MPa
- Settings: 150 trials, TPE sampler

Usage:
  python optimization_engine/optimization_config_builder.py

Output: optimization_config.json with complete multi-objective setup

Integration:
- Works with discover_fea_model() to find design variables
- Links to result extractors (stress, displacement, mass)
- Ready for MCP build_optimization_config tool
- Supports LLM-driven configuration building

This enables the workflow:
1. User: "Minimize weight and stress with max displacement < 1mm"
2. LLM discovers model → lists options → builds config
3. Optimization engine executes with multi-objective + constraints
This commit is contained in:
Claude
2025-11-15 13:56:41 +00:00
parent 16cddd5243
commit 6c30b91a82
2 changed files with 593 additions and 0 deletions

190
optimization_config.json Normal file
View File

@@ -0,0 +1,190 @@
{
"design_variables": [
{
"name": "tip_thickness",
"type": "continuous",
"bounds": [
15.0,
25.0
],
"units": "mm",
"initial_value": 20.0
},
{
"name": "support_angle",
"type": "continuous",
"bounds": [
20.0,
40.0
],
"units": "degrees",
"initial_value": 30.0
},
{
"name": "support_blend_radius",
"type": "continuous",
"bounds": [
5.0,
15.0
],
"units": "mm",
"initial_value": 10.0
}
],
"objectives": [
{
"name": "minimize_mass",
"description": "Minimize total mass (weight reduction)",
"extractor": "mass_extractor",
"metric": "total_mass",
"direction": "minimize",
"weight": 5.0
},
{
"name": "minimize_max_stress",
"description": "Minimize maximum von Mises stress",
"extractor": "stress_extractor",
"metric": "max_von_mises",
"direction": "minimize",
"weight": 10.0
}
],
"constraints": [
{
"name": "max_displacement_limit",
"description": "Maximum allowable displacement",
"extractor": "displacement_extractor",
"metric": "max_displacement",
"type": "upper_bound",
"limit": 1.0,
"units": "mm"
},
{
"name": "max_stress_limit",
"description": "Maximum allowable von Mises stress",
"extractor": "stress_extractor",
"metric": "max_von_mises",
"type": "upper_bound",
"limit": 200.0,
"units": "MPa"
}
],
"optimization_settings": {
"n_trials": 150,
"sampler": "TPE",
"n_startup_trials": 20
},
"model_info": {
"sim_file": "/home/user/Atomizer/tests/Bracket_sim1.sim",
"solutions": [
{
"name": "DisableInThermalSolution",
"type": "DisableInThermalSolution",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Disable in Thermal Solution 3D",
"type": "Disable in Thermal Solution 3D",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "-Flow-Structural Coupled Solution Parameters",
"type": "-Flow-Structural Coupled Solution Parameters",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Direct Frequency Response",
"type": "Direct Frequency Response",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "*Thermal-Flow Coupled Solution Parameters",
"type": "*Thermal-Flow Coupled Solution Parameters",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "0Thermal-Structural Coupled Solution Parameters",
"type": "0Thermal-Structural Coupled Solution Parameters",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Linear Statics",
"type": "Linear Statics",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Disable in Thermal Solution 2D",
"type": "Disable in Thermal Solution 2D",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Thermal Solution Parameters",
"type": "Thermal Solution Parameters",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Nonlinear Statics",
"type": "Nonlinear Statics",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Modal Frequency Response",
"type": "Modal Frequency Response",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "1Pass Structural Contact Solution to Flow Solver",
"type": "1Pass Structural Contact Solution to Flow Solver",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "\"ObjectDisableInThermalSolution3D",
"type": "\"ObjectDisableInThermalSolution3D",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Design Optimization",
"type": "Design Optimization",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "\"ObjectDisableInThermalSolution2D",
"type": "\"ObjectDisableInThermalSolution2D",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Normal Modes",
"type": "Normal Modes",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Direct Transient Response",
"type": "Direct Transient Response",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
},
{
"name": "Modal Transient Response",
"type": "Modal Transient Response",
"solver": "NX Nastran",
"description": "Extracted from binary .sim file"
}
]
}
}