Last active
October 19, 2015 05:44
-
-
Save jameskyle/5431b99f4d7f077a742b to your computer and use it in GitHub Desktop.
This file contains 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 | |
CORES=7 | |
OUTPUT=${OUTPUT:-results} | |
array=( | |
AssignmentTwo | |
ContinuousPeaksTest | |
CountOnesTest | |
FlipFlopTest | |
FourPeaksTest | |
KnapsackTest | |
TravelingSalesmanTest | |
) | |
mkdir -p ${OUTPUT} | |
count=0 | |
function set_header { | |
if [[ $1 = "AssignmentTwo" ]]; then | |
echo "algorithm,iterations,training error,testing error,training time,testing time" > ${OUTPUT}/${1}.csv | |
else | |
echo "algorithm,iterations,time,optim" > ${OUTPUT}/${1}.csv | |
fi | |
} | |
for j in "${array[@]}";do | |
for i in $(seq 1 20 10001);do | |
count=$((count+1)) | |
if [[ $count -eq 0 ]]; then | |
set_header ${j} | |
fi | |
java -cp ABAGAIL.jar opt.test.${j} ${i} >| /tmp/${j}${i}.csv & | |
if [[ $(expr $count % ${CORES}) -eq 0 ]]; then | |
# wait for cores to free up | |
wait | |
fi | |
done | |
# catch overflow | |
wait | |
cat /tmp/${j}*.csv >> ${OUTPUT}/${j}.csv | |
rm -f /tmp/${j}*.csv | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment