-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmark.sh
executable file
·86 lines (78 loc) · 1.98 KB
/
benchmark.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
valid_methods=(
[0]="mip heuristic h"
[1]="mip heuristic h"
[2]="heuristic h pathheuristic ph"
[3]="heuristic h"
)
usage() {
echo "Usage: $(basename "$0") -d <data_dir> -c <case> -m <method>"
echo "Where <case> is one of the following: 0, 1, 2, 3"
echo "Where <method> can be:"
for c in ${!valid_methods[@]}; do
echo "Case $c:"
for m in ${valid_methods[$c]}; do
echo -e "\t$m"
done
done
echo "Example: ./$(basename "$0") -d data/ -c 0 -m mip"
exit 1
}
parse_arguments() {
while getopts ":d:c:m:" opt; do
case ${opt} in
d )
data_dir=$OPTARG
;;
c )
case_num=$OPTARG
;;
m )
method=$OPTARG
;;
\? )
usage
;;
: )
echo "Invalid option: $OPTARG requires an argument" 1>&2
usage
;;
esac
done
shift $((OPTIND -1))
if [[ -z $data_dir ]] || [[ -z $case_num ]] || [[ -z $method ]]; then
usage
fi
}
check_arguments() {
if [[ ! -d $data_dir ]]; then
echo "Error: $data_dir is not a directory"
usage
fi
if [[ ! ${valid_methods[$case_num]} =~ (^|[[:space:]])$method($|[[:space:]]) ]]; then
echo "Error: $method is not a valid method for case $case_num"
usage
fi
}
create_campaign() {
echo "Experimental Campaign:"
echo "Data directory: $data_dir"
echo "Output directory: log/"
echo "Case: $case_num"
echo "Method: $method"
mkdir -p log/$method/$case_num
}
run_solver() {
for instance in "$data_dir"/*; do
echo "Solving $instance"
python3 src/vrpwdSolver.py "$instance" "$case_num" "$method" -v > "log/$method/$case_num/result_$(basename "$instance" .txt).log"
done
}
main() {
parse_arguments "$@"
check_arguments
create_campaign
run_solver
echo "Done!"
}
main "$@"