#!/bin/bash
#SBATCH --job-name=classic_mnist_cluster_explanations
#SBATCH --output=logs/classic_mnist_cluster_explanations_%A_%a.out
#SBATCH --error=logs/classic_mnist_cluster_explanations_%A_%a.err
#SBATCH --array=0-2  # (1 label * 3 deltas * 1 cluster) - 1
#SBATCH --time=24:00:00
#SBATCH --cpus-per-task=1
#SBATCH --mem=8G
#SBATCH --constraint="hsw"

TASK_ID=$SLURM_ARRAY_TASK_ID
DATASET="mnist"

# Configuration
NUM_LABELS=1
NUM_DELTAS=3
NUM_CLUSTERS=1
CLUSTER_SIZE=3

# Compute indices
LABEL_INDEX=$((TASK_ID / (NUM_DELTAS * NUM_CLUSTERS)))
DELTA_INDEX=$((TASK_ID % NUM_DELTAS))
CLUSTER_INDEX=$((TASK_ID % NUM_CLUSTERS))

# Compute actual values
LABEL=$((LABEL_INDEX+5))
DELTA=$(printf "%.1f" "$(echo "$DELTA_INDEX * 0.1 + 0.1" | bc -l)")
CLUSTER=$CLUSTER_INDEX

echo "Running task $TASK_ID on dataset $DATASET with LABEL=$LABEL, DELTA=$DELTA and CLUSTER=$CLUSTER"

python -m scripts.tools.generate_explanations \
    --dataset "$DATASET" \
    --explainer cluster \
    --cluster-index "$CLUSTER" \
    --cluster-size $CLUSTER_SIZE \
    --label "$LABEL" \
    --delta "$DELTA" \
    --prototype "mean" \
    --epsilon 0.05 \
    --num-explanations 1 \
    --num-consumers 1 \
    --output data/logs/cluster/examples/cluster-explanations/"$DATASET"_label_"$LABEL"_delta_"$DELTA"_cluster_"$CLUSTER".json
