This repository was archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
102 lines (81 loc) · 2.32 KB
/
run.sh
File metadata and controls
102 lines (81 loc) · 2.32 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# n = number of vertices
# p = arc probability (0 <= p <= 1)
# r = maximum range of capacity
# s = random seed
# f = output file name
# example: python3 gen.py 10 0.4 100 1234 data.in
# https://stackoverflow.com/questions/40175868/how-to-create-csv-file-using-shell-script
csv()
{
local items=("$@")
(
IFS=,
echo "${items[*]}"
)
}
# Decimal Separator
LC_NUMERIC=en_US.UTF-8
# Number of Instances
N=$(seq 1 1 30)
# Number of Measurements
M=$(seq 1 1 1)
# Seed (incremental)
SEED=0
# Algorithms: Dinic EK MPM
ALGORITHMS="Dinic EK MPM"
# Maximum CPU Time (in seconds)
TIMEOUT=10
# Maximum Range of Capacity
RANGE=100
# Number of Vertices
VERTICES=$(seq 100 50 1000)
# Arc Probability (0 <= p <= 1)
PROBABILITIES=$(seq 0.1 0.1 0.7)
# Directories
INPUT="inputs"
OUTPUT="outputs"
# Create directories if they do not exist
mkdir -p $INPUT
mkdir -p $OUTPUT
# Header of CSV File
FILENAME="results.csv"
csv measurement instance algorithm seed vertices probability arcs max-capacity max-cpu result time >> $FILENAME
for A in $ALGORITHMS
do
for V in $VERTICES
do
for P in $PROBABILITIES
do
for I in $N
do
INPUT_FILE="$INPUT/input,$V,$P,$RANGE,$SEED.in"
python gen.py $V $P $RANGE $SEED $INPUT_FILE 2>&1
read LINE < $INPUT_FILE
while [ "$LINE" == "-1" ]
do
rm $INPUT_FILE
((++SEED))
INPUT_FILE="$INPUT/input,$V,$P,$RANGE,$SEED.in"
python gen.py $V $P $RANGE $SEED $INPUT_FILE 2>&1
read LINE < $INPUT_FILE
done
OIFS=$IFS
IFS=' '
read -r IGNORE ARCS < $INPUT_FILE
IFS=$OIFS
for J in $M
do
OUTPUT_FILE="$OUTPUT/$A,$J,$I,$V,$P,$RANGE,$SEED.out"
./$A $TIMEOUT $INPUT_FILE > $OUTPUT_FILE
exec 6< "$OUTPUT_FILE"
read RESULT <&6
read TIME <&6
csv $J $I $A $SEED $V $P $ARCS $RANGE $TIMEOUT $RESULT $TIME >> $FILENAME
done
((++SEED))
done
done
done
done
echo "DONE!"