Created
June 24, 2024 22:16
-
-
Save jeanmidevacc/91a0b61c230c9b59cc75d31f4dbd18bb to your computer and use it in GitHub Desktop.
suika trigger simulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if the user provided an argument | |
if [ -z "$1" ]; then | |
echo "Please specify the number of runs as an argument." | |
exit 1 | |
fi | |
# Total number of runs specified by the first argument | |
TOTAL_RUNS=$1 | |
MODEL=$2 | |
SCENARIO=$3 | |
# Initialize Conda environment | |
conda init | |
conda activate pygame_p310 | |
# Start the initial batch of up to 4 simulations | |
for ((i=1; i<=TOTAL_RUNS && i<=4; i++)); do | |
python suika/simulation.py --scenario=$SCENARIO --model=$MODEL & | |
done | |
# Keep track of how many simulations we have started | |
STARTED_RUNS=$i | |
# While not all simulations have been started | |
while [ $STARTED_RUNS -le $TOTAL_RUNS ]; do | |
# Check if there are less than 4 background jobs running | |
while [ $(jobs -p | wc -l) -lt 4 ] && [ $STARTED_RUNS -le $TOTAL_RUNS ]; do | |
python suika/simulation.py --scenario=$SCENARIO --model=$MODEL & | |
let STARTED_RUNS+=1 | |
done | |
# Wait for any simulation to finish before checking again | |
wait -n | |
done | |
# Wait for the last batch of simulations to complete | |
wait | |
echo "All simulations completed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment