Non-Uniform CA Designer (C++, GAlib, Boost)
File detail
Source code
#!/bin/bash
# Copyright (C) 2009 Kamil Dudka <xdudka00@stud.fit.vutbr.cz>
#
# This file is part of nucad (Non-Uniform CA Designer).
#
# nucad is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# nucad is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nucad. If not, see <http://www.gnu.org/licenses/>.
function die() {
echo "$0: error occurred, see log for details!"
exit -1
}
set -x
# setup paths
export PWD=`pwd`
export DATA_DIR="$PWD/data"
export LOG_DIR="$PWD/log"
export RUN_GQCA="$PWD/build/nucad"
export RUN_CHECK="$PWD/build/check"
# check for output directory
OUT_DIR="$DATA_DIR"
test -n "$1" && OUT_DIR="$1"
export OUT_DIR
if test ! -d "$OUT_DIR"; then
mkdir "$OUT_DIR" || die
fi
if test ! -d "$LOG_DIR"; then
mkdir "$LOG_DIR" || die
fi
# check for executables
test -x $RUN_GQCA || die
test -x $RUN_CHECK || die
# run tests in parallel
LIST=`$RUN_CHECK -l` || die
for i in $LIST; do
LOG="$LOG_DIR/gate-$i.log"
printf "\n\n@ starting nucad at `LC_ALL=C date`\n" >> $LOG
(time $RUN_GQCA $i > "$OUT_DIR/$i.nucad" 2>&4) 2>> "$LOG" 4>&1 || die &
done
# wait for all tests to be done
for i in $LIST; do
wait || die
done
# write statistics
for i in $LIST; do
OUT="$OUT_DIR/$i.nucad"
LOG="$LOG_DIR/gate-$i.log"
echo "- solutions found: `cat $OUT | wc -l`" >> $LOG || die
cat "$OUT" | "$RUN_CHECK" $i | grep fitness >> "$LOG"
done
exit 0