Skip to content

Instantly share code, notes, and snippets.

@jameskyle
Last active October 19, 2015 05:44
Show Gist options
  • Save jameskyle/5431b99f4d7f077a742b to your computer and use it in GitHub Desktop.
Save jameskyle/5431b99f4d7f077a742b to your computer and use it in GitHub Desktop.
#!/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