#!/bin/bash
#SBATCH --job-name=classic_cluster_explanations
#SBATCH --output=logs/classic_cluster_explanations_%A_%a.out
#SBATCH --error=logs/classic_cluster_explanations_%A_%a.err
#SBATCH --array=0-99  # Updated: (2 labels * 10 deltas * 5 clusters) - 1
#SBATCH --time=10:00:00
#SBATCH --cpus-per-task=1
#SBATCH --constraint="hsw"

TASK_ID=$SLURM_ARRAY_TASK_ID
DATASET="wine"

# Configuration
NUM_LABELS=2
NUM_DELTAS=10
NUM_CLUSTERS=5
CLUSTER_SIZE=10

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

# Compute actual values
LABEL=$LABEL_INDEX
DELTA=$(printf "%.2f" "$(echo "$DELTA_INDEX * 0.02" | 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" \
    --num-explanations 100000 \
    --num-consumers 1 \
    --output data/logs/cluster/classic/cluster-explanations/"$DATASET"_label_"$LABEL"_delta_"$DELTA"_cluster_"$CLUSTER".json
