File: parse.awk

package info (click to toggle)
coinor-cbc 2.9.9%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,848 kB
  • ctags: 5,787
  • sloc: cpp: 104,337; sh: 8,921; xml: 2,950; makefile: 520; ansic: 491; awk: 197
file content (160 lines) | stat: -rw-r--r-- 4,362 bytes parent folder | download | duplicates (5)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/awk -f
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#*                                                                           *
#*            This file is part of the test engine for MIPLIB2010            *
#*                                                                           *
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# $Id: parse.awk 1854 2013-01-28 00:02:55Z stefan $

function abs(x)
{
   return x < 0 ? -x : x;
}
function min(x,y)
{
   return (x) < (y) ? (x) : (y);
}
function max(x,y)
{
   return (x) > (y) ? (x) : (y);
}
BEGIN {
   printf("----------------------------+----------------+----------------+------+-------+-------+--------+---------\n");
   printf("Name                        |   Dual Bound   |  Primal Bound  | Gap%% | Nodes |  Time | Status | Solution \n");
   printf("----------------------------+----------------+----------------+------+-------+-------+--------+---------\n");

   infty = +1e+20;
   eps = 1e-04;
   largegap = 1e+04;

   # initialize summary data
   nsolved = 0;
   nstopped = 0;
   nfailed = 0;

   # initialize data to be set in parse_<solver>.awk
   solver = "?";
   solverversion = "?";
   solverremark = "";
}
# instance name 
/^@01/ { 
   n  = split ($2, a, "/");
   m = split(a[n], b, ".");
   prob = b[1];
   if( b[m] == "gz" || b[m] == "z" || b[m] == "GZ" || b[m] == "Z" )
      m--;
   for( i = 2; i < m; ++i )
      prob = prob "." b[i];

   # initialize data to be set in parse.awk
   timelimit = 0;
   starttime = 0.0;
   endtime = 0.0;
   time = 0.0;

   # initialize data to be set parse_<solver>.awk
   bbnodes = 0;
   pb = +infty;
   db = -infty;
   aborted = 1;
   timeout = 0;
   solstatus = "none";
   read_error = 0;
}
# time
/@03/ { starttime = $2; }
/@04/ { endtime = $2; }
/@05/ { timelimit = $2; }
# solution status
/Read SOL:/ { 
   solstatus = "--";
}
/Check SOL:/ { 
   intcheck = $4;
   conscheck = $6;
   objcheck = $8;
   if( intcheck && conscheck && objcheck ) 
      solstatus = "ok";
   else
      solstatus = "fail";
}
/^=ready=/ {
   # measure wallclock time externaly rounded up to the next second 
   time = max(1, endtime - starttime);

   if( timelimit > 0 )
   {
      # report time limit as time for instances stopped by time limit
      if( timeout )
	 time = timelimit;

      # report time limit as time for aborted instances 
      if( aborted )
	 time = timelimit;

      # report time limit as time for instances that exceeded the time limit but did not stop
      time = min(time, timelimit);
   }

   # determine solving status
   status = "";
   if( aborted && !read_error) 
     status = "abort";
   else if (aborted && read_error)
     status = "noread";
   else if( timeout )
     status = "stopped";
   else
     status = "ok";

   # determine overall status from solving status and solution status:

   # instance solved correctly (including case that no solution was found) 
   if( status == "ok" && (solstatus == "ok" || solstatus == "--") )
      nsolved++;
   # incorrect solving process or infeasible solution (including errors with solution checker)
   else if( status == "abort" || (solstatus == "fail" || solstatus == "error") )
      nfailed++;
   # stopped due to imposed limits
   else if ( status == "stopped" )
      nstopped++;
   else
     nnoread++;
 
  # compute gap
   temp = pb;
   pb = 1.0*temp;
   temp = db;
   db = 1.0*temp;

   if( abs(pb - db) < eps && pb < +infty ) 
      gap = 0.0;
   else if( abs(db) < eps )
      gap = -1.0;
   else if( pb*db < 0.0 )
      gap = -1.0;
   else if( abs(db) >= +infty )
      gap = -1.0;
   else if( abs(pb) >= +infty )
      gap = -1.0;
   else
      gap = 100.0*abs((pb-db)/db);

   if( gap < 0.0 )
      gapstr = "    --";
   else if( gap < largegap )
      gapstr = sprintf("%6.1f", gap);
   else
      gapstr = " Large";

   printf("%-28s %16.9g %16.9g %6s %7d %7d %8s %9s\n", prob, db, pb, gapstr, bbnodes, time, status, solstatus);
}
END {
   printf("----------------------------+----------------+----------------+------+-------+-------+--------+---------\n");
   printf("\n");
   printf("solved/stopped/noread/failed: %d/%d/%d/%d\n", nsolved, nstopped, nnoread, nfailed);
   printf("\n");
   printf("@02 timelimit: %g\n", timelimit);
   printf("@01 %s(%s)%s\n", solver, solverversion, solverremark);
}