-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput_table_extractor_baron.sh
58 lines (50 loc) · 1.53 KB
/
output_table_extractor_baron.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
#!/bin/bash
# ls m1* | sort -V | xargs -I{} -n 1 ../../output_table_extractor_baron.sh {}
# ls m2* | sort -V | xargs -I{} -n 1 ../../output_table_extractor_baron.sh {}
# ls m3* | sort -V | xargs -I{} -n 1 ../../output_table_extractor_baron.sh {}
# ls m4* | sort -V | xargs -I{} -n 1 ../../output_table_extractor_baron.sh {}
echo -e "Processing file = '$1'"
OUTPUT_AWK=$(cat "$1" | awk -F' +' '
BEGIN { f=0; rows=0; }
/^ *$/ { if(f==2) f+=1; }
{
if(f==2) {
# if (rows <= 3) {
# print $1 "--" $2 "--" $3 "--" $4 "--" $5 "--" $6;
# print;
# rows += 1;
# }
varTime = $4;
varCost = $6;
if (s[varCost] == 0) {
s[varCost] = 1;
print varTime "," varCost;
rows += 1;
}
}
}
/ Iteration Open nodes Time \(s\) Lower bound Upper bound/ {f=2;}
END {
for (; rows <= 7; rows += 1) {
print ","
}
}
')
# Perform compression of output values
# The first and last values are always printed, and the results between them are compressed
echo "${OUTPUT_AWK}" | python -c "
import sys
from math import ceil
# str.strip() is required as 'l' will have trailing new line character
lines = [l.strip() for l in sys.stdin]
lines_out = list()
if len(lines) <= 1+8:
lines_out = lines
else:
lines_out.append(lines[0] + ',Compressed')
for i in range(1, len(lines) - 1, int(ceil((len(lines) - 2) / (8 - 2)))):
lines_out.append(lines[i])
lines_out.append(lines[-1])
for i in lines_out:
print(i)
"