-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_array_file.sh
executable file
·87 lines (71 loc) · 2.13 KB
/
generate_array_file.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# walk through all domain directories in DOMAIN_DIR
DOMAIN_DIR='domains'
PLANNER_DIR='planners'
RESULT_DIR='results'
LOG_DIR='logs'
# get full path to script location directory
# regardless of where the script was called
BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ARRAY_FILE="${BASE_DIR}/array.in"
rm -f ${ARRAY_FILE}
touch ${ARRAY_FILE}
# arg1 - domain
# delete files generated by previous experiments with domain
function clean () {
RESULT_PATH=${BASE_DIR}/${RESULT_DIR}/$1
DOMAIN_PATH=${BASE_DIR}/${DOMAIN_DIR}/$1
LOG_PATH=${BASE_DIR}/${LOG_DIR}
echo -n "cleaning files from previous experiments .."
[[ -d "$RESULT_PATH" ]] && rm -rf "$RESULT_PATH"
[[ -d "$LOG_PATH" ]] && rm -rf "$LOG_PATH"
echo "OK"
}
function process_domain () {
DOMAIN_PATH=${BASE_DIR}/${DOMAIN_DIR}/$1
RESULT_PATH=${BASE_DIR}/${RESULT_DIR}/$1
PLANNER_PATH=${BASE_DIR}/${PLANNER_DIR}
LOG_PATH=${BASE_DIR}/${LOG_DIR}
DOMAIN=$1
clean ${DOMAIN}
echo "creating result directory: $RESULT_PATH"
[[ -d "$RESULT_PATH" ]] || mkdir -p $RESULT_PATH
echo "creating log directory: $LOG_PATH"
[[ -d "$LOG_PATH" ]] || mkdir -p $LOG_PATH
cd ${DOMAIN_PATH}
echo "Generating array file:"
while read planner;
do
while read model;
do
while read task;
do
# get configuration list from planner directory
for config in `ls ${PLANNER_PATH}/${planner} | grep "\.conf$"`;
do
JOB_NAME="${planner}-${model%.*}-${task}-${config%.*}"
echo "${DOMAIN} ${planner} ${model} ${task} ${config}" >> ${ARRAY_FILE}
done
done < prob_list
done < mod_list
done < pla_list
cd ${BASE_DIR}
}
# ------------- process domains ---------------
# if no parameters are given the script will process all domains in $DOMAIN_DIR
# otherwise each parameter should name domain selected for processing
if [ $# -gt 0 ]; then
echo "Processing specified domains:"
for D in $@;
do
echo "==== Processing $D ====";
process_domain $D
done
else
echo "No parameter specified - processing all domains."
for D in `ls $DOMAIN_DIR | grep -v README.md`;
do
echo "==== Processing $D ====";
process_domain $D
done
fi