@echo off
REM ============================================================================
REM Atomizer Installation Script
REM ============================================================================
REM This script installs all dependencies for Atomizer including neural networks
REM
REM Prerequisites:
REM   - Python 3.10+ installed
REM   - pip available in PATH
REM
REM For GPU support, run this BEFORE the script:
REM   pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
REM ============================================================================

echo.
echo ============================================================================
echo                    ATOMIZER INSTALLATION
echo ============================================================================
echo.

REM Check Python
python --version >nul 2>&1
if errorlevel 1 (
    echo ERROR: Python not found in PATH
    echo Please install Python 3.10+ and add it to PATH
    pause
    exit /b 1
)

echo Found Python:
python --version
echo.

REM Upgrade pip
echo Upgrading pip...
python -m pip install --upgrade pip
echo.

REM Install core dependencies
echo Installing core dependencies...
python -m pip install numpy">=1.24.0,<2.0.0" scipy pandas scikit-learn
echo.

REM Install optimization framework
echo Installing optimization framework...
python -m pip install optuna plotly matplotlib
echo.

REM Install FEA tools
echo Installing FEA/Nastran tools...
python -m pip install "pyNastran>=1.4.0,<1.5.0" h5py
echo.

REM Install web framework
echo Installing web framework...
python -m pip install fastapi uvicorn websockets pydantic python-multipart jinja2
echo.

REM Install utilities
echo Installing utilities...
python -m pip install psutil tqdm
echo.

REM Install PyTorch (CPU version by default)
echo.
echo ============================================================================
echo Installing PyTorch...
echo ============================================================================
echo.
echo NOTE: Installing CPU version. For GPU support, run:
echo   pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
echo.
python -m pip install torch
echo.

REM Install PyTorch Geometric
echo Installing PyTorch Geometric (Graph Neural Networks)...
python -m pip install torch-geometric
echo.

REM Install TensorBoard
echo Installing TensorBoard...
python -m pip install tensorboard
echo.

REM Verify installation
echo.
echo ============================================================================
echo Verifying installation...
echo ============================================================================
echo.
python -c "import numpy; import optuna; import torch; import torch_geometric; print('All core imports OK!')"
if errorlevel 1 (
    echo.
    echo WARNING: Some packages may not have installed correctly
    echo Please check the error messages above
) else (
    echo.
    echo ============================================================================
    echo                    INSTALLATION COMPLETE!
    echo ============================================================================
    echo.
    echo Atomizer is ready to use.
    echo.
    echo To train a neural network:
    echo   train_neural.bat
    echo.
    echo To run an optimization study:
    echo   cd studies\your_study
    echo   python run_optimization.py --run --trials 100
    echo.
)

pause
