#!/bin/bash

# Testujeme vsechny matice po dobu jedne hodiny (t=3600) pri pouziti discardingu

matice="s838_1"

sel="4"

pop[0]="50"
pop[1]="100"
pop[2]="200"
pop[3]="500"
pop[4]="1000"
pop[5]="2000"

cros="0.7"
mutation="0.01"
pr="0.01"

while [ `ps aux | grep ColMatch | wc -l` -gt 1 ]; do
  echo "waiting"
  sleep 600;
done
    
r=0
while [ "$r" -le 2 ];
do

n=0
while [ "$n" -le 5 ];
do

    filename="10_uni_${pop[$n]}_${r}_${matice}"

echo "matrix-C                                matrix/${matice}_s.pat" > $filename
echo "matrix-T                                matrix/${matice}_d.pat" >> $filename
echo "estimate-population-size                0" >> $filename
echo "max-duration                            300" >> $filename
echo "population-size                         ${pop[$n]}" >> $filename
echo "max-generations                         10000" >> $filename
echo "bad-generations-to-terminate(pt)        5" >> $filename
echo "selection-parameter(ps)                 ${sel}" >> $filename
echo "use-threshold                           1" >> $filename
echo "crossover-method                        0" >> $filename
echo "crossover-probability(pc)               ${cros}" >> $filename
echo "use-discarding                          1" >> $filename
echo "mutation-matches-probability(pm)        ${mutation}" >> $filename
echo "mutation-rank1-probability(pr1)         ${pr}" >> $filename
echo "mutation-rank2-probability(pr2)         0" >> $filename
    

    mkdir "_$filename"
    ./gcma2_7 $filename
    
  n=$(expr "$n" + 1)

done

  r=$(expr "$r" + 1)

done
