#!/bin/bash

# --------------------------------------
# Metalauncher: Best Configs + TF Sweep
# All models run with attention = True
# --------------------------------------

REGION="W011"
PATIENCE="5"
LOG_SCALE="False"
ATTENTION="True"
BATCH_SIZE="16384"
CSV_LOG="True"
CSV_FILE="teacher_forcing_tuning.csv"
TEACHER_FORCING_VALUES=("0.0" "0.25" "0.5" "0.75")

# ------------------------
# Vanilla RNN
# ------------------------
CELL_TYPE="rnn"

# Config 1: Best for MAE
DROPOUT_1="0.0"
WD_1="0.0"
HS_1="64"

# Config 2: Best for RMSE/MSE/R²
DROPOUT_2="0.5"
WD_2="1e-5"
HS_2="64"

for TF in "${TEACHER_FORCING_VALUES[@]}"; do
  echo "Submitting RNN (MAE-opt) | hidden=$HS_1 | dropout=$DROPOUT_1 | wd=$WD_1 | tf=$TF"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT_1 $HS_1 $PATIENCE $REGION $TF $LOG_SCALE $WD_1 $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1

  echo "Submitting RNN (RMSE-opt) | hidden=$HS_2 | dropout=$DROPOUT_2 | wd=$WD_2 | tf=$TF"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT_2 $HS_2 $PATIENCE $REGION $TF $LOG_SCALE $WD_2 $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1
done

# ------------------------
# LSTM
# ------------------------
CELL_TYPE="lstm"

# Config 1: Best for MAE
DROPOUT_1="0.0"
WD_1="0.0"
HS_1="128"

# Config 2: Best for RMSE/MSE/R²
DROPOUT_2="0.25"
WD_2="0.0"
HS_2="32"

for TF in "${TEACHER_FORCING_VALUES[@]}"; do
  echo "Submitting LSTM (MAE-opt) | hidden=$HS_1 | dropout=$DROPOUT_1 | wd=$WD_1 | tf=$TF"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT_1 $HS_1 $PATIENCE $REGION $TF $LOG_SCALE $WD_1 $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1

  echo "Submitting LSTM (RMSE-opt) | hidden=$HS_2 | dropout=$DROPOUT_2 | wd=$WD_2 | tf=$TF"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT_2 $HS_2 $PATIENCE $REGION $TF $LOG_SCALE $WD_2 $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1
done

# ------------------------
# GRU
# ------------------------
CELL_TYPE="gru"

# Config 1: Best for MAE
DROPOUT_1="0.0"
WD_1="1e-5"
HS_1="64"

# Config 2: Best for RMSE/MSE/R²
DROPOUT_2="0.5"
WD_2="1e-5"
HS_2="64"

for TF in "${TEACHER_FORCING_VALUES[@]}"; do
  echo "Submitting GRU (MAE-opt) | hidden=$HS_1 | dropout=$DROPOUT_1 | wd=$WD_1 | tf=$TF"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT_1 $HS_1 $PATIENCE $REGION $TF $LOG_SCALE $WD_1 $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1

  echo "Submitting GRU (RMSE-opt) | hidden=$HS_2 | dropout=$DROPOUT_2 | wd=$WD_2 | tf=$TF"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT_2 $HS_2 $PATIENCE $REGION $TF $LOG_SCALE $WD_2 $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1
done
