#!/bin/bash

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

matice[0]="s820"
matice[1]="s420.1_1"
matice[2]="s420.1_4"
matice[3]="s641_1"
matice[4]="s5378_3"
matice[5]="s13207.1_3"
matice[6]="s38417_1"

sel[0]="3"
sel[1]="3"
sel[2]="3"
sel[3]="3"
sel[4]="4"
sel[5]="3"
sel[6]="3"

pop[0]="5000"
pop[1]="5000"
pop[2]="3000"
pop[3]="8000"
pop[4]="2000"
pop[5]="70"
pop[6]="70"

cros[0]="0.5"
cros[1]="0.5"
cros[2]="0.5"
cros[3]="0.5"
cros[4]="0.7"
cros[5]="0.5"
cros[6]="0.5"

mutation[0]="0.002"
mutation[1]="0.002"
mutation[2]="0.002"
mutation[3]="0.002"
mutation[4]="0.01"
mutation[5]="0.01"
mutation[6]="0.01"

pr[0]="0.1"
pr[1]="0.1"
pr[2]="0.1"
pr[3]="0.1"
pr[4]="0.1"
pr[5]="0.1"
pr[6]="0.1"

n=2
while [ "$n" -le 2 ];
do

  m=0
  while [ "$m" -le 6 ];
  do

    filename="9_pnt_${n}_${matice[$m]}"

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

    mkdir "_$filename"
    ./gcma2 $filename
    
    m=$(expr "$m" + 1)

  done

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

done
