#!/bin/bash

# --------------------------------------
# Metalauncher: Evaluation (No Teacher Forcing)
# Only runs 2 fixed configs per architecture
# --------------------------------------

REGION="W011"
PATIENCE="10"
LOG_SCALE="False"
ATTENTION="True"
BATCH_SIZE="16384"
CSV_LOG="True"
TEACHER_FORCING="0.0"

# Years
TRAINING_YEARS=("2010" "2011" "2012" "2013" "2014")
TESTING_YEARS=("2008")

# Derive year-based indicators
VAL_YEAR="2010"
TRAIN_YEARS_SHORT="2011 2012 2013 2014"
TRAIN_LABEL=$(echo $TRAIN_YEARS_SHORT | tr ' ' '-')
TEST_LABEL=$(echo ${TESTING_YEARS[*]} | tr ' ' '-')

# Dynamic CSV name
CSV_FILE="evaluation${REGION}_train_${TRAIN_LABEL}_val_${VAL_YEAR}_test_${TEST_LABEL}.csv"

# ---------------
# RNN Configs
# ---------------
CELL_TYPE="rnn"
CONFIGS=(
  "0.0 64 0.0"     # MAE-opt
  "0.5 64 1e-5"    # RMSE-opt
)

for CONFIG in "${CONFIGS[@]}"; do
  read -r DROPOUT HS WD <<< "$CONFIG"
  echo "Submitting RNN | hidden=$HS | dropout=$DROPOUT | wd=$WD"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT $HS $PATIENCE $REGION $TEACHER_FORCING $LOG_SCALE $WD $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1
done

# ---------------
# LSTM Configs
# ---------------
CELL_TYPE="lstm"
CONFIGS=(
  "0.0 128 0.0"    # MAE-opt
  "0.25 32 0.0"    # RMSE-opt
)

for CONFIG in "${CONFIGS[@]}"; do
  read -r DROPOUT HS WD <<< "$CONFIG"
  echo "Submitting LSTM | hidden=$HS | dropout=$DROPOUT | wd=$WD"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT $HS $PATIENCE $REGION $TEACHER_FORCING $LOG_SCALE $WD $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1
done

# ---------------
# GRU Configs
# ---------------
CELL_TYPE="gru"
CONFIGS=(
  "0.0 64 1e-5"    # MAE-opt
  "0.5 64 1e-5"    # RMSE-opt
)

for CONFIG in "${CONFIGS[@]}"; do
  read -r DROPOUT HS WD <<< "$CONFIG"
  echo "Submitting GRU | hidden=$HS | dropout=$DROPOUT | wd=$WD"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiconfig.sh \
    $CELL_TYPE $ATTENTION $DROPOUT $HS $PATIENCE $REGION $TEACHER_FORCING $LOG_SCALE $WD $BATCH_SIZE $CSV_LOG $CSV_FILE
  sleep 1
done
