1 | #!/usr/bin/awk -f |
---|
2 | #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
---|
3 | #* * |
---|
4 | #* This file is part of the test engine for MIPLIB2010 * |
---|
5 | #* * |
---|
6 | #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
---|
7 | # $Id: parse.awk,v 1.1 2010/10/07 16:14:36 bzfwolte Exp $ |
---|
8 | |
---|
9 | function abs(x) |
---|
10 | { |
---|
11 | return x < 0 ? -x : x; |
---|
12 | } |
---|
13 | function min(x,y) |
---|
14 | { |
---|
15 | return (x) < (y) ? (x) : (y); |
---|
16 | } |
---|
17 | function max(x,y) |
---|
18 | { |
---|
19 | return (x) > (y) ? (x) : (y); |
---|
20 | } |
---|
21 | BEGIN { |
---|
22 | printf("------------------+------+-------+-------+--------+---------\n"); |
---|
23 | printf("Name | Gap%% | Nodes | Time | Status | Solution \n"); |
---|
24 | printf("------------------+------+-------+-------+--------+---------\n"); |
---|
25 | |
---|
26 | infty = +1e+20; |
---|
27 | eps = 1e-04; |
---|
28 | largegap = 1e+04; |
---|
29 | |
---|
30 | # initialize data to be set in parse_<solver>.awk |
---|
31 | solver = "?"; |
---|
32 | solverversion = "?"; |
---|
33 | lps = "none"; |
---|
34 | lpsversion = "-"; |
---|
35 | } |
---|
36 | # instance name |
---|
37 | /^@01/ { |
---|
38 | n = split ($2, a, "/"); |
---|
39 | m = split(a[n], b, "."); |
---|
40 | prob = b[1]; |
---|
41 | if( b[m] == "gz" || b[m] == "z" || b[m] == "GZ" || b[m] == "Z" ) |
---|
42 | m--; |
---|
43 | for( i = 2; i < m; ++i ) |
---|
44 | prob = prob "." b[i]; |
---|
45 | |
---|
46 | # initialize data to be set in parse.awk |
---|
47 | timelimit = 0; |
---|
48 | starttime = 0.0; |
---|
49 | endtime = 0.0; |
---|
50 | time = 0.0; |
---|
51 | |
---|
52 | # initialize data to be set parse_<solver>.awk |
---|
53 | bbnodes = 0; |
---|
54 | pb = +infty; |
---|
55 | db = -infty; |
---|
56 | aborted = 1; |
---|
57 | timeout = 0; |
---|
58 | solstatus = "unkown"; |
---|
59 | } |
---|
60 | # time |
---|
61 | /@03/ { starttime = $2; } |
---|
62 | /@04/ { endtime = $2; } |
---|
63 | /@05/ { timelimit = $2; } |
---|
64 | # solution status |
---|
65 | /Check SOL:/ { |
---|
66 | intcheck = $4; |
---|
67 | conscheck = $6; |
---|
68 | objcheck = $8; |
---|
69 | if( intcheck && conscheck && objcheck ) |
---|
70 | solstatus = "ok"; |
---|
71 | else |
---|
72 | solstatus = "fail"; |
---|
73 | } |
---|
74 | /^=ready=/ { |
---|
75 | # measure wallclock time externaly rounded up to the next second |
---|
76 | time = max(1, endtime - starttime); |
---|
77 | |
---|
78 | if( timelimit > 0 ) |
---|
79 | { |
---|
80 | # report time limit as time for instances stopped by time limit |
---|
81 | if( timeout ) |
---|
82 | time = timelimit; |
---|
83 | |
---|
84 | # report time limit as time for aborted instances |
---|
85 | if( aborted ) |
---|
86 | time = timelimit; |
---|
87 | |
---|
88 | # report time limit as time for instances that exceeded the time limit but did not stop |
---|
89 | time = min(time, timelimit); |
---|
90 | } |
---|
91 | |
---|
92 | # determine solving status |
---|
93 | status = ""; |
---|
94 | if( aborted ) |
---|
95 | status = "abort"; |
---|
96 | else if( timeout ) |
---|
97 | status = "timeout"; |
---|
98 | else |
---|
99 | status = "ok"; |
---|
100 | |
---|
101 | # compute gap |
---|
102 | temp = pb; |
---|
103 | pb = 1.0*temp; |
---|
104 | temp = db; |
---|
105 | db = 1.0*temp; |
---|
106 | |
---|
107 | if( abs(pb - db) < eps && pb < +infty ) |
---|
108 | gap = 0.0; |
---|
109 | else if( abs(db) < eps ) |
---|
110 | gap = -1.0; |
---|
111 | else if( pb*db < 0.0 ) |
---|
112 | gap = -1.0; |
---|
113 | else if( abs(db) >= +infty ) |
---|
114 | gap = -1.0; |
---|
115 | else if( abs(pb) >= +infty ) |
---|
116 | gap = -1.0; |
---|
117 | else |
---|
118 | gap = 100.0*abs((pb-db)/db); |
---|
119 | |
---|
120 | if( gap < 0.0 ) |
---|
121 | gapstr = " --"; |
---|
122 | else if( gap < largegap ) |
---|
123 | gapstr = sprintf("%6.1f", gap); |
---|
124 | else |
---|
125 | gapstr = " Large"; |
---|
126 | |
---|
127 | printf("%-18s %6s %7d %7d %8s %9s\n", prob, gapstr, bbnodes, time, status, solstatus); |
---|
128 | } |
---|
129 | END { |
---|
130 | printf("------------------+------+-------+-------+--------+---------\n"); |
---|
131 | printf("@02 timelimit: %g\n", timelimit); |
---|
132 | printf("@01 %s(%s)%s(%s)\n", solver, solverversion, lps, lpsversion); |
---|
133 | } |
---|