Skip to content

Commit

Permalink
UPD: drop explicit gui support, change upper end year limit
Browse files Browse the repository at this point in the history
  • Loading branch information
vkhodygo committed Oct 2, 2023
1 parent 70f9144 commit 9ed76d2
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions do_full_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ usage() {
-b --batch_size The number of simulations to run in one batch, strictly integer and positive
-p --population The size of a population, strictly integer and positive
-s --start_year The year simulation starts, from 2010 to 2023
-e --end_year The year simulation ends, from 2010 to 2023, greater or equal than \`-s\`
-g --gui GUI flag, \`true\` or \`false\` to enable/disable GUI support" 1>&2
-e --end_year The year simulation ends, from 2010 to 2023, greater or equal than \`-s\`" 1>&2
}

# Function: print usage and exit with error.
Expand All @@ -28,7 +27,7 @@ exit_abnormal() {
}

# parse input arguments
VALID_ARGS="$(getopt -o b:p:s:e:g: -l batch_size:,population:,start_year:,end_year:,gui: --name "$0" -- "$@")"
VALID_ARGS="$(getopt -o b:p:s:e: -l batch_size:,population:,start_year:,end_year: --name "$0" -- "$@")"

eval set -- "$VALID_ARGS"

Expand All @@ -38,6 +37,10 @@ re_is_year='^20(1[0-9]|2[0-3])$'
# Regex: match whole positive numbers only
re_isanum='^[0-9]*[1-9][0-9]*$'

# Regex: match years in range [2010 : 2099]
# Note: this is an artificial limit, actual simulations have no upper bound
re_is_year_end='^20[1-9][0-9]$'

while true
do
case "$1" in
Expand Down Expand Up @@ -79,29 +82,16 @@ do
;;
-e|--end_year)
# if $2 not in range:
if ! [[ $2 =~ $re_is_year ]]
if ! [[ $2 =~ $re_is_year_end ]]
then
echo "Error: end year must be in range [2010 : 2023]" >&2
echo "Error: end year must be in range [2010 : 2099]" >&2
# Exit abnormally.
exit_abnormal
fi
# Set END_YEAR to specified value.
END_YEAR=$2
shift 2
;;
-g|--gui)
re_is_bool='^(true|false)$'
# if $2 not boolean:
if ! [[ $2 =~ $re_is_bool ]]
then
echo "Error: must be either \`true\` or \`false\`, case-sensitive" >&2
# Exit abnormally.
exit_abnormal
fi
# Set GUI to specified value.
GUI=$2
shift 2
;;
--)
shift
break
Expand Down Expand Up @@ -142,7 +132,7 @@ parallel java -jar simpaths.jar -r {} -n $BATCH_SIZE \
-p $POPULATION_SIZE \
-s $START_YEAR \
-e $END_YEAR \
-g $GUI \
-g false \
-f \
::: {100..5000..100}

Expand Down

0 comments on commit 9ed76d2

Please sign in to comment.