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

TASK_ID=$SLURM_ARRAY_TASK_ID

# Configuration
NUM_DELTAS=10
NUM_DIMS=16
NUM_CLUSTERS=20
CLUSTER_SIZE=20

# Compute indices for 3D array
SAMPLE_INDEX=$((TASK_ID / (NUM_DELTAS * NUM_DIMS)))
REMAINING=$((TASK_ID % (NUM_DELTAS * NUM_DIMS)))
DIM_INDEX=$((REMAINING / NUM_DELTAS))
DELTA_INDEX=$((REMAINING % NUM_DELTAS))

# Compute actual values
DIM=$((10 + DIM_INDEX))
DELTA=$(printf "%.2f" "$(echo "$DELTA_INDEX * 0.01" | bc -l)")
SAMPLE=$SAMPLE_INDEX

echo "Running task $TASK_ID with DIM=$DIM and SAMPLE=$SAMPLE"

python -m scripts.tools.generate_explanations \
    --dataset custom \
    --custom-dim "$DIM" \
    --explainer cluster \
    --sample-index "$SAMPLE" \
    --delta "$DELTA" \
    --prototype "mean" \
    --num-explanations 1 \
    --num-consumers 1 \
    --output data/logs/delta_robust/scalability/robust-explanations/custom_dim_"$DIM"_sample_"$SAMPLE"_delta_"$DELTA".json
