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>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""Test neural surrogate integration"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add project paths
|
|
project_root = Path(__file__).parent
|
|
sys.path.insert(0, str(project_root))
|
|
sys.path.insert(0, str(project_root / 'atomizer-field'))
|
|
|
|
from optimization_engine.processors.surrogates.neural_surrogate import create_parametric_surrogate_for_study
|
|
|
|
# Create surrogate
|
|
print("Creating parametric surrogate...")
|
|
surrogate = create_parametric_surrogate_for_study(project_root=project_root)
|
|
|
|
if surrogate:
|
|
print('Surrogate created successfully!')
|
|
print(f'Design vars: {surrogate.design_var_names}')
|
|
print(f'Number of nodes: {surrogate.num_nodes}')
|
|
|
|
# Test prediction with example params
|
|
test_params = {name: 2.0 for name in surrogate.design_var_names}
|
|
print(f'\nTest params: {test_params}')
|
|
|
|
results = surrogate.predict(test_params)
|
|
print(f'\nTest prediction:')
|
|
print(f' Mass: {results["mass"]:.2f}')
|
|
print(f' Frequency: {results["frequency"]:.2f}')
|
|
print(f' Max Displacement: {results["max_displacement"]:.6f}')
|
|
print(f' Max Stress: {results["max_stress"]:.2f}')
|
|
print(f' Inference time: {results["inference_time_ms"]:.2f} ms')
|
|
|
|
print('\nSurrogate is ready for use in optimization!')
|
|
else:
|
|
print('Failed to create surrogate')
|