Created
May 19, 2019 22:19
-
-
Save shipof123/935cb52d95d7b5e31402717e859e1275 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 | |
# Connell Paxton | |
# Bash (Bourne Again SHell) doesn't support floating point math, so `bc` is used | |
float_scale=2 | |
function float_math() | |
{ | |
local stat=0 | |
local result=0.0 | |
if [[ $# -gt 0 ]]; then | |
result=$(echo "scale=$float_scale; $*" | bc -q 2>/dev/null) | |
stat=$? | |
if [[ $stat -eq 0 && -z "$result" ]]; then stat=1; fi | |
fi | |
echo $result | |
return $stat | |
} | |
if false | |
then | |
# 1. Run algorithm 80 times with Mutation disabled, and Crossover ranging from 0.55 - 0.95 | |
# Step up Crossover rate by 0.05 every ten runs | |
c=0.55 | |
for i in `seq 0 9` | |
do | |
for j in `seq 0 9` | |
do | |
./ga.py `float_math "$c + (0.05 * $i)"` 0 2>>data.tsv | |
done | |
done | |
./sv > cr.html | |
mv data.tsv cr.tsv | |
echo "Step one is done" | |
# 2. Same as 1, but with Mutation going from 0.001 to 0.005 with an iteration of 0.001 every 10 | |
# and crossover disabled | |
m=0.005 | |
for i in `seq 0 9` | |
do | |
for j in `seq 0 9` | |
do | |
./ga.py 0 `float_math "$m + 0.001 * $i"` 2>> data.tsv | |
done | |
done | |
./sv > mu.html | |
mv data.tsv mu.tsv | |
echo "Step two, too" | |
# 3. A combination of both | |
fi | |
m=0.005 | |
c=0.55 | |
for i in `seq 0 9` | |
do | |
for j in `seq 0 9` | |
do | |
for y in `seq 0 9` | |
do | |
./ga.py `float_math "$c + (0.05 * $i)"` `float_math "$m + (0.001 * $j)"` 2>> data.tsv | |
done | |
done | |
done | |
./sv > crmu.html | |
mv data.tsv crmu.tsv | |
echo -e "Step three is finishedn\\nAll done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment