#!/bin/bash
#SBATCH --job-name=custom_individual_explanations
#SBATCH --output=logs/custom_individual_explanations_%A_%a.out
#SBATCH --error=logs/custom_individual_explanations_%A_%a.err
#SBATCH --array=0-7999   # Updated: (16 dims * 5 clusters * 20 cluster size * 5 seeds) - 1
#SBATCH --time=24:00:00
#SBATCH --cpus-per-task=1
#SBATCH --constraint="hsw"

TASK_ID=$SLURM_ARRAY_TASK_ID

# Configuration
NUM_DIMS=16
NUM_CLUSTERS=5
CLUSTER_SIZE=20
NUM_SEEDS=5

# Compute indices for 3D array (seeds, dims, samples)
NUM_SAMPLES=$((CLUSTER_SIZE * NUM_CLUSTERS))
SEED_INDEX=$((TASK_ID / (NUM_DIMS * NUM_SAMPLES)))
REMAINING=$((TASK_ID % (NUM_DIMS * NUM_SAMPLES)))
DIM_INDEX=$((REMAINING / NUM_SAMPLES))
SAMPLE_INDEX=$((REMAINING % NUM_SAMPLES))

# Compute actual values
DIM=$((10 + DIM_INDEX))
SEED=$SEED_INDEX

echo "Running task $TASK_ID with DIM=$DIM, SAMPLE=$SAMPLE_INDEX, and SEED=$SEED"

python -m scripts.tools.generate_explanations \
    --dataset custom \
    --custom-dim "$DIM" \
    --seed "$SEED" \
    --explainer individual \
    --sample-index "$SAMPLE_INDEX" \
    --num-explanations 100000 \
    --num-consumers 1 \
    --output data/logs/cluster/scalability/individual-explanations/custom_dim_"$DIM"_sample_"$SAMPLE_INDEX"_seed_"$SEED".json
