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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
|
#!/usr/bin/awk -f
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#* *
#* This file is part of the program and library *
#* SCIP --- Solving Constraint Integer Programs *
#* *
#* Copyright (c) 2002-2026 Zuse Institute Berlin (ZIB) *
#* *
#* Licensed under the Apache License, Version 2.0 (the "License"); *
#* you may not use this file except in compliance with the License. *
#* You may obtain a copy of the License at *
#* *
#* http://www.apache.org/licenses/LICENSE-2.0 *
#* *
#* Unless required by applicable law or agreed to in writing, software *
#* distributed under the License is distributed on an "AS IS" BASIS, *
#* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
#* See the License for the specific language governing permissions and *
#* limitations under the License. *
#* *
#* You should have received a copy of the Apache-2.0 license *
#* along with SCIP; see the file LICENSE. If not visit scipopt.org. *
#* *
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#
#@file check_cbc.awk
#@brief CBC Check Report Generator
#@author Thorsten Koch
#@author Tobias Achterberg
#@author Robert Waniek
#
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 {
timegeomshift = 60.0;
nodegeomshift = 1000.0;
onlyinsolufile = 0; # should only instances be reported that are included in the .solu file?
useshortnames = 1; # should problem name be truncated to fit into column?
writesolufile = 0; # should a solution file be created from the results
NEWSOLUFILE = "new_solufile.solu";
infty = +1e+20;
headerprinted = 0;
nprobs = 0;
sbab = 0;
scut = 0;
stottime = 0.0;
sgap = 0.0;
nodegeom = 0.0;
timegeom = 0.0;
shiftednodegeom = nodegeomshift;
shiftedtimegeom = timegeomshift;
failtime = 0.0;
timeouttime = 0.0;
fail = 0;
pass = 0;
timeouts = 0;
settings = "default";
version = "?";
threads = 1;
starttime = 0.0;
endtime = 0.0;
timelimit = 0.0;
}
/=opt=/ { solstatus[$2] = "opt"; sol[$2] = $3; } # get optimum
/=inf=/ { solstatus[$2] = "inf"; } # problem infeasible (no feasible solution exists)
/=best=/ { solstatus[$2] = "best"; sol[$2] = $3; } # get best known solution value
/=unkn=/ { solstatus[$2] = "unkn"; } # no feasible solution known
#
# problem 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];
if( useshortnames && length(prob) > 18 )
shortprob = substr(prob, length(prob)-17, 18);
else
shortprob = prob;
# Escape _ for TeX
n = split(prob, a, "_");
pprob = a[1];
for( i = 2; i <= n; i++ )
pprob = pprob "\\_" a[i];
origvars = 0;
origcons = 0;
vars = 0;
cons = 0;
timeout = 0;
opti = 0;
feasible = 1;
cuts = 0;
pb = +infty;
db = -infty;
mipgap = 1e-4;
absmipgap = 1e-6;
bbnodes = 0;
iters = 0;
primlps = 0;
primiter = 0;
duallps = 0;
dualiter = 0;
sblps = 0;
sbiter = 0;
tottime = 0.0;
aborted = 1;
cbcversion = "";
}
/@03/ { starttime = $2; }
/@04/ { endtime = $2; }
#
# remove Coin:
#
/^Coin:/ {
$0 = substr($0, 6, length($0)-5);
}
#
# Cbc version
#
/^Coin Cbc and Clp/ {
split($7, v, ",");
cbcversion = v[1];
}
#
# settings
#
/^@05 SETTINGS:/ {
settings = $3;
}
/^ratioGap has value/ {
mipgap = $4;
}
/^allowableGap has value/ {
absmipgap = $4;
}
/^seconds has value/ {
timelimit = $4;
}
/^threads was changed from/ {
threads = $7;
}
#
# problem size
#
/^Problem / {
if ( $3 == "has" ) {
origcons = $4;
origvars = $6;
if ( cons == 0 )
cons = origcons;
if ( vars == 0 )
vars = origvars;
}
else {
cons = $3;
vars = $5;
}
}
/^Cgl0004I processed model has / {
cons = $5;
vars = $7;
}
#
# node log (dual bound)
#
#/^Cbc0010I After [0-9]* nodes, [0-9]* on tree, [-+.0-9eE]* best solution, best possible [-+.0-9eE]* ([-+.0-9eE]* seconds)/ {
/^Cbc0010I After .* nodes, .* on tree, .* best solution, best possible .* (.* seconds)/ {
bbnodes = $3;
pb = $8;
db = $13;
tottime = substr($14, 2, length($14)-1);
tottime = 1.0*tottime;
}
#
# solution
#
/^Result - Optimal solution found/ {
opti = 1;
timeout = 0;
aborted = 0;
}
/^Result - Stopped on time limit/ {
opti = 0;
timeout = 1;
aborted = 0;
}
/^Objective value:/ {
pb = $3;
feasible = (pb < +infty);
if ( opti == 1) {
db = pb;
}
}
/^Lower bound:/ {
db = $3;
}
/^Enumerated nodes:/ {
bbnodes = $3;
}
/^Total iterations:/ {
dualiter = $3;
iters = dualiter;
}
/^Time \(CPU seconds\):/ {
tottime = $4;
tottime = 1.0*tottime;
}
/^Result - Finished objective/ {
pb = ( $5 == 1e+50 ) ? +infty : $5; # since CBC (version 2.3.0) doesn't report infeasibility in tree, this is a workaround
db = pb;
bbnodes = $7;
dualiter = $10;
iters = dualiter;
tottime = $14;
feasible = (pb < +infty);
opti = 1;
aborted = 0;
}
/^Result - Finishedgap objective/ {
pb = $5;
db = pb;
bbnodes = $7;
dualiter = $10;
iters = dualiter;
tottime = $14;
feasible = (pb < +infty);
opti = 1;
aborted = 0;
}
/^Result - Stopped on time objective/ {
pb = ( $7 == 1e+50 ) ? +infty : $7;
bbnodes = $9;
dualiter = $12;
iters = dualiter;
tottime = $16;
feasible = (pb < +infty);
opti = 0;
timeout = 1;
aborted = 0;
}
/^Result - Stopped on nodes objective/ {
pb = $7;
bbnodes = $9;
dualiter = $12;
iters = dualiter;
tottime = $16;
feasible = (pb < +infty);
opti = 0;
timeout = 1;
aborted = 0;
}
/^Result - User ctrl-c objective/ {
pb = $6;
bbnodes = $8;
dualiter = $11;
iters = dualiter;
tottime = $15;
feasible = (pb < +infty);
opti = 0;
timeout = 1;
aborted = 0;
}
/^Cputime limit exceeded/ {
feasible = (pb < +infty);
opti = 0;
timeout = 1;
aborted = 0;
tottime = max(tottime, timelimit);
}
/^Pre-processing says infeasible or unbounded/ {
feasible = 0;
aborted = 0;
pb = +infty;
db = +infty;
}
/^Result - Finishedproven-infeasible objective/ {
feasible = 0;
aborted = 0;
pb = +infty;
db = +infty;
bbnodes = $7;
dualiter = $10;
iters = dualiter;
tottime = $14;
}
/^Problem is infeasible/ {
feasible = 0;
aborted = 0;
pb = +infty;
db = +infty;
tottime = $5;
}
#
# evaluation
#
# solver status overview (in order of priority):
# 1) solver broke before returning solution => abort
# 2) solver cut off the optimal solution (solu-file-value is not between primal and dual bound) => fail
# (especially of problem is claimed to be solved but solution is not the optimal solution)
# 3) solver solved problem with the value in solu-file (if existing) => ok
# 4) solver solved problem which has no (optimal) value in solu-file => solved
# 5) solver found solution better than known best solution (or no solution was known so far) => better
# 6) solver reached any other limit (like time or nodes) => timeout
# 7) otherwise => unknown
#
/^=ready=/ {
#since the header depends on the parameter settings it is no longer possible to print it in the BEGIN section
if( !headerprinted ) {
printf("\\documentclass[leqno]{article}\n") >TEXFILE;
printf("\\usepackage{a4wide}\n") >TEXFILE;
printf("\\usepackage{amsmath,amsfonts,amssymb,booktabs}\n") >TEXFILE;
printf("\\usepackage{supertabular}\n") >TEXFILE;
printf("\\pagestyle{empty}\n\n") >TEXFILE;
printf("\\begin{document}\n\n") >TEXFILE;
printf("\\begin{center}\n") >TEXFILE;
printf("\\setlength{\\tabcolsep}{2pt}\n") >TEXFILE;
printf("\\newcommand{\\g}{\\raisebox{0.25ex}{\\tiny $>$}}\n") >TEXFILE;
printf("\\tablehead{\n\\toprule\n") >TEXFILE;
printf("Name & Conss & Vars & Dual Bound & Primal Bound & Gap\\%% & Nodes & Time \\\\\n") >TEXFILE;
printf("\\midrule\n}\n") >TEXFILE;
printf("\\tabletail{\n\\midrule\n") >TEXFILE;
printf("\\multicolumn{%d}{r} \\; continue next page \\\\\n", ntexcolumns) >TEXFILE;
printf("\\bottomrule\n}\n") >TEXFILE;
printf("\\tablelasttail{\\bottomrule}\n") >TEXFILE;
printf("\\tablecaption{CBC with %s settings}\n",settings) >TEXFILE;
printf("\\begin{supertabular*}{\\textwidth}{@{\\extracolsep{\\fill}}lrrrrrrr@{}}\n") >TEXFILE;
printf("-------------------+--- Original --+-- Presolved --+----------------+----------------+------+--------+-------+-------+-------\n");
printf("Name | Conss | Vars | Conss | Vars | Dual Bound | Primal Bound | Gap%% | Iters | Nodes | Time | \n");
printf("-------------------+-------+-------+-------+-------+----------------+----------------+------+--------+-------+-------+-------\n");
headerprinted = 1;
}
if( !onlyinsolufile || solstatus[prob] != "" ) {
temp = pb;
pb = 1.0*temp;
temp = db;
db = 1.0*temp;
bbnodes = max(bbnodes, 1); # in case solver reports 0 nodes if the primal heuristics find the optimal solution in the root node
nprobs++;
optimal = 0;
markersym = "\\g";
if( abs(pb - db) < 1e-06 && pb < infty ) {
gap = 0.0;
optimal = 1;
markersym = " ";
}
else if( abs(db) < 1e-06 )
gap = -1.0;
else if( abs(pb) < 1e-06 )
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)/min(abs(db),abs(pb)));
if( gap < 0.0 )
gapstr = " -- ";
else if( gap < 1e+04 )
gapstr = sprintf("%6.1f", gap);
else
gapstr = " Large";
if( aborted && endtime - starttime > timelimit && timelimit > 0.0 ) {
timeout = 1;
aborted = 0;
tottime = endtime - starttime;
}
if( timelimit > 0.0 )
tottime = min(tottime, timelimit);
printf("%-19s & %6d & %6d & %14.9g & %14.9g & %6s &%s%8d &%s%7.1f \\\\\n",
pprob, cons, vars, db, pb, gapstr, markersym, bbnodes, markersym, tottime) >TEXFILE;
printf("%-19s %7d %7d %7d %7d %16.9g %16.9g %6s %8d %7d %7.1f ",
shortprob, origcons, origvars, cons, vars, db, pb, gapstr, iters, bbnodes, tottime);
if( aborted ) {
printf("abort\n");
failtime += tottime;
fail++;
}
else if( solstatus[prob] == "opt" ) {
reltol = max(mipgap, 1e-5) * max(abs(pb),1.0);
abstol = max(absmipgap, 1e-4);
if( ( pb-db > max(abstol,reltol) && (db-sol[prob] > reltol || sol[prob]-pb > reltol)) || ( db-pb > max(reltol,abstol) && (sol[prob]-db > reltol || pb-sol[prob] > reltol)) ) {
printf("fail\n");
failtime += tottime;
fail++;
}
else {
if ( timeout ) {
printf("timeout\n");
timeouttime += tottime;
timeouts++;
}
else {
if( (abs(pb - db) <= max(abstol, reltol)) && abs(pb - sol[prob]) <= reltol ) {
printf("ok\n");
pass++;
}
else {
printf("fail\n");
failtime += tottime;
fail++;
}
}
}
}
else if( solstatus[prob] == "best" ) {
reltol = max(mipgap, 1e-5) * max(abs(pb),1.0);
abstol = max(absmipgap, 1e-4);
if( ( pb-db > max(abstol,reltol) && db-sol[prob] > reltol) || ( db-pb > max(reltol,abstol) && sol[prob]-db > reltol) ) {
printf("fail\n");
failtime += tottime;
fail++;
}
else {
if (timeout) {
if( (pb-db > max(abstol,reltol) && sol[prob]-pb > reltol) || (db-pb > max(abstol,reltol) && pb-sol[prob] > reltol) ) {
printf("better\n");
timeouttime += tottime;
timeouts++;
}
else {
printf("timeout\n");
timeouttime += tottime;
timeouts++;
}
}
else {
if( abs(pb - db) <= max(abstol, reltol) ) {
printf("solved not verified\n");
pass++;
}
else {
printf("fail\n");
failtime += tottime;
fail++;
}
}
}
}
else if( solstatus[prob] == "unkn" ) {
reltol = max(mipgap, 1e-5) * max(abs(pb),1.0);
abstol = max(absmipgap, 1e-4);
if( timeout || nodeout ) {
if( abs(pb) < infty )
printf("better\n");
else if( timeout )
printf("timeout\n");
else if (nodeout)
printf("nodelimit\n");
timeouttime += tottime;
timeouts++;
}
else if( abs(pb - db) <= max(abstol, reltol) ) {
printf("solved not verified\n");
pass++;
}
else
printf("unknown\n");
}
else if( solstatus[prob] == "inf" ) {
if( timeout ) {
printf("timeout\n");
timeouttime += tottime;
timeouts++;
}
else if( !feasible ) {
printf("ok\n");
pass++;
}
else {
printf("fail\n");
failtime += tottime;
fail++;
}
}
else {
reltol = max(mipgap, 1e-5) * max(abs(pb),1.0);
abstol = max(absmipgap, 1e-4);
if( timeout || nodeout ) {
if( timeout )
printf("timeout\n");
else if (nodeout)
printf("nodelimit\n");
timeouttime += tottime;
timeouts++;
}
else if( abs(pb - db) <= max(abstol, reltol) ) {
printf("solved not verified\n");
pass++;
}
else
printf("unknown\n");
}
if( writesolufile ) {
if( pb == +infty && db == +infty )
printf("=inf= %-18s\n",prob)>NEWSOLUFILE;
else if( pb == db )
printf("=opt= %-18s %16.9g\n",prob,pb)>NEWSOLUFILE;
else if( pb < +infty )
printf("=best= %-18s %16.9g\n",prob,pb)>NEWSOLUFILE;
else
printf("=unkn= %-18s\n",prob)>NEWSOLUFILE;
}
sbab += bbnodes;
scut += cuts;
stottime += tottime;
timegeom = timegeom^((nprobs-1)/nprobs) * max(tottime, 1.0)^(1.0/nprobs);
nodegeom = nodegeom^((nprobs-1)/nprobs) * max(bbnodes, 1.0)^(1.0/nprobs);
shiftedtimegeom = shiftedtimegeom^((nprobs-1)/nprobs) * max(tottime+timegeomshift, 1.0)^(1.0/nprobs);
shiftednodegeom = shiftednodegeom^((nprobs-1)/nprobs) * max(bbnodes+nodegeomshift, 1.0)^(1.0/nprobs);
}
}
END {
shiftednodegeom -= nodegeomshift;
shiftedtimegeom -= timegeomshift;
printf("\\midrule\n") >TEXFILE;
printf("%-14s (%2d) & & & & & & %9d & %8.1f \\\\\n",
"Total", nprobs, sbab, stottime) >TEXFILE;
printf("%-14s & & & & & & %9d & %8.1f \\\\\n",
"Geom. Mean", nodegeom, timegeom) >TEXFILE;
printf("%-14s & & & & & & %9d & %8.1f \\\\\n",
"Shifted Geom.", shiftednodegeom, shiftedtimegeom) >TEXFILE;
printf("\\bottomrule\n") >TEXFILE;
printf("\\noalign{\\vspace{6pt}}\n") >TEXFILE;
printf("\\end{supertabular*}\n") >TEXFILE;
printf("\\end{center}\n") >TEXFILE;
printf("\\end{document}\n") >TEXFILE;
printf("-------------------+-------+-------+-------+-------+----------------+----------------+------+--------+-------+-------+-------\n");
printf("\n");
printf("------------------------------[Nodes]---------------[Time]------\n");
printf(" Cnt Pass Time Fail total(k) geom. total geom. \n");
printf("----------------------------------------------------------------\n");
printf("%5d %5d %5d %5d %9d %9.1f %9.1f %9.1f\n",
nprobs, pass, timeouts, fail, sbab / 1000, nodegeom, stottime, timegeom);
printf(" shifted geom. [%5d/%5.1f] %9.1f %9.1f\n",
nodegeomshift, timegeomshift, shiftednodegeom, shiftedtimegeom);
printf("----------------------------------------------------------------\n");
printf("@02 threads: %g\n", threads);
printf("@02 timelimit: %g\n", timelimit);
printf("@01 CBC(%s):%s\n", cbcversion, settings);
}
|