2025-11-16 21:29:54 -05:00
|
|
|
"""Quick test of LLM runner initialization"""
|
|
|
|
|
import sys
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
|
|
refactor: Major reorganization of optimization_engine module structure
BREAKING CHANGE: Module paths have been reorganized for better maintainability.
Backwards compatibility aliases with deprecation warnings are provided.
New Structure:
- core/ - Optimization runners (runner, intelligent_optimizer, etc.)
- processors/ - Data processing
- surrogates/ - Neural network surrogates
- nx/ - NX/Nastran integration (solver, updater, session_manager)
- study/ - Study management (creator, wizard, state, reset)
- reporting/ - Reports and analysis (visualizer, report_generator)
- config/ - Configuration management (manager, builder)
- utils/ - Utilities (logger, auto_doc, etc.)
- future/ - Research/experimental code
Migration:
- ~200 import changes across 125 files
- All __init__.py files use lazy loading to avoid circular imports
- Backwards compatibility layer supports old import paths with warnings
- All existing functionality preserved
To migrate existing code:
OLD: from optimization_engine.nx_solver import NXSolver
NEW: from optimization_engine.nx.solver import NXSolver
OLD: from optimization_engine.runner import OptimizationRunner
NEW: from optimization_engine.core.runner import OptimizationRunner
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 12:30:59 -05:00
|
|
|
from optimization_engine.future.llm_optimization_runner import LLMOptimizationRunner
|
2025-11-16 21:29:54 -05:00
|
|
|
|
|
|
|
|
# Example LLM workflow
|
|
|
|
|
llm_workflow = {
|
|
|
|
|
'engineering_features': [
|
|
|
|
|
{
|
|
|
|
|
'action': 'extract_displacement',
|
|
|
|
|
'domain': 'result_extraction',
|
|
|
|
|
'description': 'Extract displacement from OP2',
|
|
|
|
|
'params': {'result_type': 'displacement'}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'inline_calculations': [
|
|
|
|
|
{
|
|
|
|
|
'action': 'normalize',
|
|
|
|
|
'params': {
|
|
|
|
|
'input': 'max_displacement',
|
|
|
|
|
'reference': 'max_allowed_disp',
|
|
|
|
|
'value': 5.0
|
|
|
|
|
},
|
|
|
|
|
'code_hint': 'norm_disp = max_displacement / 5.0'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'post_processing_hooks': [
|
|
|
|
|
{
|
|
|
|
|
'action': 'weighted_objective',
|
|
|
|
|
'params': {
|
|
|
|
|
'inputs': ['norm_disp'],
|
|
|
|
|
'weights': [1.0],
|
|
|
|
|
'objective': 'minimize'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'optimization': {
|
|
|
|
|
'algorithm': 'TPE',
|
|
|
|
|
'direction': 'minimize',
|
|
|
|
|
'design_variables': [
|
|
|
|
|
{
|
|
|
|
|
'parameter': 'wall_thickness',
|
|
|
|
|
'min': 3.0,
|
|
|
|
|
'max': 8.0
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def dummy_updater(dv):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def dummy_runner():
|
|
|
|
|
return Path('tests/bracket_sim1-solution_1.op2')
|
|
|
|
|
|
|
|
|
|
print("Initializing LLM runner...")
|
|
|
|
|
runner = LLMOptimizationRunner(
|
|
|
|
|
llm_workflow=llm_workflow,
|
|
|
|
|
model_updater=dummy_updater,
|
|
|
|
|
simulation_runner=dummy_runner,
|
|
|
|
|
study_name='test'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
print(f"\nSuccess!")
|
|
|
|
|
print(f"Extractors: {len(runner.extractors)}")
|
|
|
|
|
print(f"Inline code: {len(runner.inline_code)}")
|
|
|
|
|
print(f"Hooks: {runner.hook_manager.get_summary()['enabled_hooks']}")
|