#!/bin/bash

# 1. Prevent CPU thread deadlocks (CRITICAL for parallel runs)
export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export cv2_NUM_THREADS=0

# 2. Base command
BASE_CMD="python train_video_audio_flow_HAC.py --datapath ./data/ --use_video --use_audio --use_flow --bsz 16 --save_best"

echo "Starting 3 parallel 1-Source Domain Generalization experiments..."
echo "Models will be saved dynamically to the /models/ folder."

# ==========================================
# Launching the 3 combinations simultaneously 
# ==========================================
echo "Launching Experiment 1 (Source: Human)..."
$BASE_CMD -s human -t animal cartoon > log_source_human.txt 2>&1 &

echo "Launching Experiment 2 (Source: Animal)..."
$BASE_CMD -s animal -t human cartoon > log_source_animal.txt 2>&1 &

echo "Launching Experiment 3 (Source: Cartoon)..."
$BASE_CMD -s cartoon -t human animal > log_source_cartoon.txt 2>&1 &


wait 

echo "======================================================"
echo "SUCCESS: All 3 parallel experiments have finished!"
echo "======================================================"