#!/bin/bash

# Configuration
SCRIPT_PATH="./mining.py"
LOG_BASE_DIR="./search_benchmark"
MODELS=("deepseek-chat" "gpt-4.1")
DATASETS=(
    "./dataset/benchmark/csv/FF100MEOPnew.csv"
    "./dataset/benchmark/csv/FF100new.csv"
    "./dataset/benchmark/csv/FF25new.csv"
    "./dataset/benchmark/csv/FF32new.csv"
    "./dataset/benchmark/csv/FF49new.csv"
)

# Create base log directory if it doesn't exist
mkdir -p "$LOG_BASE_DIR"

# Function to get current timestamp
get_timestamp() {
    date +"%Y%m%d_%H%M%S"
}

# Run each combination
for model in "${MODELS[@]}"; do
    for dataset in "${DATASETS[@]}"; do
        # Extract dataset name without path and extension
        dataset_name=$(basename "$dataset" .csv)
        
        # Create specific log directory for this combination
        LOG_DIR="${LOG_BASE_DIR}/${model}_${dataset_name}"
        mkdir -p "$LOG_DIR"
        
        # Create log file name
        timestamp=$(get_timestamp)
        log_file="${LOG_DIR}/${model}_${dataset_name}_${timestamp}.log"
        
        # Print what we're running
        echo "Starting: python $SCRIPT_PATH --data_path $dataset --model $model > $log_file 2>&1 &"
        
        # Run the command in background and redirect output to log file
        python "$SCRIPT_PATH" --data_path "$dataset" --model "$model" --exp_name fulldata --log_dir "$LOG_DIR" > "$log_file" 2>&1 &
        
        # Optional: sleep between runs to avoid overloading system
        # sleep 5
    done
done

echo "All jobs have been started in the background."
echo "Check log files in subdirectories of $LOG_BASE_DIR for progress."