#!/bin/bash

# --------------------------------------
# Metalauncher: Region 11 - Extra Training Years Study (Test on 2005)
# One fixed config per architecture
# --------------------------------------

REGION="W025"
PATIENCE="5"
LOG_SCALE="False"
ATTENTION="True"
BATCH_SIZE="16384"
CSV_LOG="True"
TEACHER_FORCING="0.0"
TEST_YEAR="2005"
CSV_FILE="evaluation_${REGION}_extra_training_years_study.csv"

# Define full set of candidate training years
ALL_YEARS=(2006 2007 2008 2009 2010 2011 2012 2013 2014)

# Architecture-specific configs
RNN_CONFIG="0.0 64 0.0"
LSTM_CONFIG="0.25 32 0.0"
GRU_CONFIG="0.0 64 1e-5"

# Loop over increasing training year windows
for ((i=2; i<=${#ALL_YEARS[@]}; i++)); do
  TRAINING_YEARS=("${ALL_YEARS[@]: -$i}")
  echo ">>> Running with training years: ${TRAINING_YEARS[*]}"

  # ---- RNN ----
  CELL_TYPE="rnn"
  read -r DROPOUT HS WD <<< "$RNN_CONFIG"
  echo "Submitting RNN | hidden=$HS | dropout=$DROPOUT | wd=$WD"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiyear.sh \
    $CELL_TYPE $ATTENTION $DROPOUT $HS $PATIENCE $REGION $TEACHER_FORCING \
    $LOG_SCALE $WD $BATCH_SIZE $CSV_LOG $CSV_FILE "${TRAINING_YEARS[@]}" $TEST_YEAR
  sleep 1

  # ---- LSTM ----
  CELL_TYPE="lstm"
  read -r DROPOUT HS WD <<< "$LSTM_CONFIG"
  echo "Submitting LSTM | hidden=$HS | dropout=$DROPOUT | wd=$WD"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiyear.sh \
    $CELL_TYPE $ATTENTION $DROPOUT $HS $PATIENCE $REGION $TEACHER_FORCING \
    $LOG_SCALE $WD $BATCH_SIZE $CSV_LOG $CSV_FILE "${TRAINING_YEARS[@]}" $TEST_YEAR
  sleep 1

  # ---- GRU ----
  CELL_TYPE="gru"
  read -r DROPOUT HS WD <<< "$GRU_CONFIG"
  echo "Submitting GRU | hidden=$HS | dropout=$DROPOUT | wd=$WD"
  sbatch -A bsc32 -q acc_bsces launch_training_rnn_multiyear.sh \
    $CELL_TYPE $ATTENTION $DROPOUT $HS $PATIENCE $REGION $TEACHER_FORCING \
    $LOG_SCALE $WD $BATCH_SIZE $CSV_LOG $CSV_FILE "${TRAINING_YEARS[@]}" $TEST_YEAR
  sleep 1

done
