Files
Atomizer/optimization_engine/processors/surrogates/__init__.py
Anto01 7bdb74f93b refactor: Reorganize code structure and create tests directory
- Consolidate surrogates module to processors/surrogates/
- Move ensemble_surrogate.py to proper location
- Add deprecation shim for old import path
- Create tests/ directory with pytest structure
- Move test files from archive/test_scripts/
- Add conftest.py with shared fixtures

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 09:01:37 -05:00

92 lines
3.4 KiB
Python

"""
Surrogate Models
================
Neural network and ML surrogate models for FEA acceleration.
Available modules:
- neural_surrogate: AtomizerField neural network surrogate
- generic_surrogate: Flexible surrogate interface
- adaptive_surrogate: Self-improving surrogate
- simple_mlp_surrogate: Simple multi-layer perceptron
- active_learning_surrogate: Active learning surrogate
- surrogate_tuner: Hyperparameter tuning
- auto_trainer: Automatic model training
- training_data_exporter: Export training data from studies
Note: Imports are done on-demand to avoid import errors from optional dependencies.
"""
# Lazy imports to avoid circular dependencies and optional dependency issues
def __getattr__(name):
"""Lazy import mechanism for surrogate modules."""
if name == 'NeuralSurrogate':
from .neural_surrogate import NeuralSurrogate
return NeuralSurrogate
elif name == 'create_surrogate_for_study':
from .neural_surrogate import create_surrogate_for_study
return create_surrogate_for_study
elif name == 'GenericSurrogate':
from .generic_surrogate import GenericSurrogate
return GenericSurrogate
elif name == 'ConfigDrivenSurrogate':
from .generic_surrogate import ConfigDrivenSurrogate
return ConfigDrivenSurrogate
elif name == 'create_surrogate':
from .generic_surrogate import create_surrogate
return create_surrogate
elif name == 'AdaptiveSurrogate':
from .adaptive_surrogate import AdaptiveSurrogate
return AdaptiveSurrogate
elif name == 'SimpleSurrogate':
from .simple_mlp_surrogate import SimpleSurrogate
return SimpleSurrogate
elif name == 'ActiveLearningSurrogate':
from .active_learning_surrogate import ActiveLearningSurrogate
return ActiveLearningSurrogate
elif name == 'SurrogateHyperparameterTuner':
from .surrogate_tuner import SurrogateHyperparameterTuner
return SurrogateHyperparameterTuner
elif name == 'tune_surrogate_for_study':
from .surrogate_tuner import tune_surrogate_for_study
return tune_surrogate_for_study
elif name == 'AutoTrainer':
from .auto_trainer import AutoTrainer
return AutoTrainer
elif name == 'TrainingDataExporter':
from .training_data_exporter import TrainingDataExporter
return TrainingDataExporter
elif name == 'create_exporter_from_config':
from .training_data_exporter import create_exporter_from_config
return create_exporter_from_config
elif name == 'EnsembleSurrogate':
from .ensemble_surrogate import EnsembleSurrogate
return EnsembleSurrogate
elif name == 'OODDetector':
from .ensemble_surrogate import OODDetector
return OODDetector
elif name == 'create_and_train_ensemble':
from .ensemble_surrogate import create_and_train_ensemble
return create_and_train_ensemble
raise AttributeError(f"module 'optimization_engine.processors.surrogates' has no attribute '{name}'")
__all__ = [
'NeuralSurrogate',
'create_surrogate_for_study',
'GenericSurrogate',
'ConfigDrivenSurrogate',
'create_surrogate',
'AdaptiveSurrogate',
'SimpleSurrogate',
'ActiveLearningSurrogate',
'SurrogateHyperparameterTuner',
'tune_surrogate_for_study',
'AutoTrainer',
'TrainingDataExporter',
'create_exporter_from_config',
'EnsembleSurrogate',
'OODDetector',
'create_and_train_ensemble',
]