#!/bin/sh

# 
# Script for GENESIS stochastic search (SS) parameter search demo.
#
# usage: SS_run <genesis program> <filename> [-resume]
#

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

# This script checks the "sim_status" file, which contains a
# single number, representing the number of simulations done so far.  
# If the number is >= 10000 the search is finished.

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

while [ $status -lt 10000 ]
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

