#!/bin/sh

# 
# Script for GENESIS genetic algorithm (GA) parameter search demo.
#
# usage: GA_run <genesis program> <filename> [-resume]
#

if [ $# -lt 3 ]  # Not resuming a previous search.
then
echo
echo Beginning parameter search using the GA method...
echo
else
echo
echo Resuming parameter search using the GA method...
echo
fi

# This script checks the "sim_status" file, which contains a
# single number which represents the number of generations that have
# been simulated so far.  If the number is "100" the search is finished.

genesis=$1
filename=$2
maxgenerations=100
status=`head -1 sim_status`

while [ $status -ne $maxgenerations ]
do
    $genesis $filename
    status=`head -1 sim_status`
    sleep 10 # wait 10 seconds; hopefully, memory will be cleaned up by then.
    clear
done

echo
echo Parameter search completed.
echo

