|
|
Go to the documentation of this file. 33 #include "scip/scip.h" 42 #define DEFAULT_HEURRUNS 100 43 #define DEFAULT_DARUNS 5 54 char label[SCIP_MAXSTRLEN]; 60 assert(graph != NULL); 61 file = fopen((filename != NULL) ? filename : "stpgraph.gml", "w"); 64 for( e = 0; e < graph-> edges; e += 2 ) 66 assert(graph-> tail[e] == graph-> head[e + 1]); 67 assert(graph-> tail[e + 1] == graph-> head[e]); 72 SCIPgmlWriteOpening(file, FALSE); 77 for( n = 0; n < graph-> knots; ++n ) 80 if( n == graph-> source[0] ) 82 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, "(%d) Root", n); 83 SCIPgmlWriteNode(file, ( unsigned int)n, label, "rectangle", "#666666", NULL); 86 else if( graph-> term[n] == 0 ) 88 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, "(%d) Terminal %d", n, e + 1); 89 SCIPgmlWriteNode(file, ( unsigned int)n, label, "circle", "#ff0000", NULL); 94 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, "(%d) Node %d", n, n + 1 - e - m); 95 SCIPgmlWriteNode(file, ( unsigned int)n, label, "circle", "#336699", NULL); 98 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, ""); 99 if( n == graph-> source[0] ) 102 SCIPgmlWriteNode(file, ( unsigned int)n, label, "rectangle", "#666666", NULL); 105 else if( graph-> term[n] == 0 ) 108 SCIPgmlWriteNode(file, ( unsigned int)n, label, "rectangle", "#666666", NULL); 113 SCIPgmlWriteNode(file, ( unsigned int)n, label, "circle", "#666666", NULL); 120 for( e = 0; e < graph-> edges; e += 2 ) 123 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, "%8.2f", graph-> cost[e]); 125 if( edgemark != NULL && edgemark[e / 2] ) 126 SCIPgmlWriteEdge(file, ( unsigned int)graph-> tail[e], ( unsigned int)graph-> head[e], label, "#ff0000"); 128 SCIPgmlWriteEdge(file, ( unsigned int)graph-> tail[e], ( unsigned int)graph-> head[e], label, NULL); 132 SCIPgmlWriteClosing(file); 156 assert(graph != NULL); 157 assert(starts != NULL); 160 nnodes = graph-> knots; 161 nterms = graph-> terms; 164 if( graph-> mark[root] ) 166 randval = SCIPgetRandomInt(0, nnodes - 1, seed); 169 for( k = 0; k < nnodes; k++ ) 171 if( r >= runs || r >= nterms ) 174 l = (k + randval) % nnodes; 182 for( k = 0; k < r && r < runs; k++ ) 184 for( e = graph-> outbeg[starts[k]]; e != EAT_LAST && r < runs; e = graph->oeat[e] ) 193 for( k = 0; k < nnodes && r < runs; k++ ) 195 l = (k + randval) % nnodes; 219 SCIP_HEURDATA* tmheurdata; 224 SCIP_Real upperbound; 225 SCIP_Real minpathcost; 254 assert(scip != NULL); 255 assert(graph != NULL); 256 assert(nelims != NULL); 262 nedges = graph-> edges; 263 nnodes = graph-> knots; 268 SCIP_CALL( SCIPallocBufferArray(scip, &result, nedges) ); 269 SCIP_CALL( SCIPallocBufferArray(scip, &marked, nedges) ); 273 SCIP_CALL( SCIPallocBufferArray(scip, &terms, graph-> terms) ); 274 SCIP_CALL( SCIPallocBufferArray(scip, &termdegs, graph-> terms) ); 283 SCIP_CALL( SCIPallocBufferArray(scip, &sd, 4) ); 284 SCIP_CALL( SCIPallocBufferArray(scip, &ancestors, 4) ); 285 SCIP_CALL( SCIPallocBufferArray(scip, &revancestors, 4) ); 286 SCIP_CALL( SCIPallocBufferArray(scip, &ecost, 4) ); 287 SCIP_CALL( SCIPallocBufferArray(scip, &adjvert, 4) ); 288 SCIP_CALL( SCIPallocBufferArray(scip, &reinsert, 4) ); 289 SCIP_CALL( SCIPallocBufferArray(scip, &incedge, 4) ); 291 for( i = 0; i < 4; i++ ) 295 revancestors[i] = NULL; 303 for( i = 0; i < nnodes; i++ ) 306 graph-> mark[i] = (graph-> grad[i] > 0); 323 if( !rpc && heursources != NULL ) 326 starts = heursources; 335 assert(SCIPfindHeur(scip, "TM") != NULL); 336 tmheurdata = SCIPheurGetData(SCIPfindHeur(scip, "TM")); 338 for( e = 0; e < nedges; e++ ) 340 cost[e] = graph-> cost[e]; 345 maxcost = graph-> cost[e]; 352 SCIP_CALL( SCIPheurComputeSteinerTree(scip, tmheurdata, graph, starts, &best_start, result, runs, root, cost, costrev, &hopfactor, NULL, maxcost, &success) ); 367 for( e = 0; e < nedges; e++ ) 369 upperbound += graph-> cost[e]; 372 for( i = 0; i < nnodes; i++ ) 374 assert(graph-> grad[i] > 0); 379 assert(terms != NULL); 380 assert(termdegs != NULL); 382 for( i = 0; i < nnodes; i++ ) 386 termdegs[k] = graph-> grad[i]; 391 SCIPsortIntInt(termdegs, terms, nterms); 402 for( run = 0; run < nruns; run++ ) 410 assert(terms != NULL); 411 root = terms[nterms - run - 1]; 414 SCIP_CALL( SCIPdualAscentStp(scip, graph, cost, &lpobjval, FALSE, gnodearr, edgearrint, state, root, 1, NULL, nodearrchar) ); 417 minpathcost = upperbound - lpobjval; 418 SCIPdebugMessage( "da: upperbound %f, lpobjval %f\n", upperbound, lpobjval); 420 for( e = 0; e < nedges; e++ ) 426 for( k = 0; k < nnodes; k++ ) 427 graph-> mark[k] = (graph-> grad[k] > 0); 439 for( k = 0; k < nnodes; k++ ) 441 assert(vbase[k + nnodes] != root ); 450 for( k = 0; k < nnodes; k++ ) 452 if( !graph-> mark[k] ) 455 if( ! Is_term(graph-> term[k]) && SCIPisGT(scip, pathdist[k] + vnoi[k].dist, minpathcost) ) 468 etmp = graph-> oeat[e]; 471 if( rpc && !graph-> mark[graph-> head[e]] ) 477 if( SCIPisGT(scip, pathdist[k] + cost[e] + vnoi[graph-> head[e]]. dist, minpathcost) ) 494 for( k = 0; k < nnodes; k++ ) 498 if( graph-> grad[k] == 3 ) 501 if( SCIPisGT(scip,pathdist[k] + vnoi[k].dist + vnoi[k + nnodes].dist, minpathcost) ) 505 SCIPdebugMessage( "DA eliminates 3-Vertex: %d %f min: %f \n", k, pathdist[k] + vnoi[k].dist + vnoi[k + nnodes].dist, minpathcost); 512 ecost[i] = graph-> cost[e]; 513 adjvert[i++] = graph-> head[e]; 518 for( i = 0; i < 3; i++ ) 526 for( i = 0; i < 3; i++ ) 529 SCIP_CALL( graph_edge_reinsert(scip, graph, incedge[i], adjvert[i], adjvert[i2], ecost[i] + ecost[i2], ancestors[i], ancestors[i2], revancestors[i], revancestors[i2]) ); 534 if( graph-> grad[k] == 4 ) 537 if( SCIPisGT(scip,pathdist[k] + vnoi[k].dist + vnoi[k + nnodes].dist + vnoi[k + 2 * nnodes].dist, minpathcost) ) 539 SCIPdebugMessage( "DA could eliminate 4-Vertex: %d %f min: %f \n", k, pathdist[k] + vnoi[k].dist + vnoi[k + nnodes].dist, minpathcost); 543 SCIPdebugMessage( "deleted by da: %d \n", nfixed ); 554 for( k = 0; k < 4; k++ ) 560 SCIPfreeBufferArray(scip, &incedge); 561 SCIPfreeBufferArray(scip, &reinsert); 562 SCIPfreeBufferArray(scip, &adjvert); 563 SCIPfreeBufferArray(scip, &ecost); 564 SCIPfreeBufferArray(scip, &revancestors); 565 SCIPfreeBufferArray(scip, &ancestors); 566 SCIPfreeBufferArray(scip, &sd); 567 SCIPfreeBufferArrayNull(scip, &termdegs); 568 SCIPfreeBufferArrayNull(scip, &terms); 569 SCIPfreeBufferArray(scip, &marked); 570 SCIPfreeBufferArray(scip, &result); 593 SCIP_HEURDATA* tmheurdata; 600 SCIP_Real upperbound; 601 SCIP_Real minpathcost; 626 assert(scip != NULL); 627 assert(graph != NULL); 628 assert(nelims != NULL); 629 assert(nodearrchar != NULL); 633 nnodes = graph-> knots; 634 nedges = graph-> edges; 639 if( edgearrint == NULL ) 641 SCIP_CALL( SCIPallocBufferArray(scip, &result, nedges) ); 647 SCIP_CALL( SCIPallocBufferArray(scip, &marked, nedges + 2 * (graph-> terms - 1)) ); 650 SCIP_CALL( SCIPallocBufferArray(scip, &sd, 4) ); 651 SCIP_CALL( SCIPallocBufferArray(scip, &ancestors, 4) ); 652 SCIP_CALL( SCIPallocBufferArray(scip, &revancestors, 4) ); 653 SCIP_CALL( SCIPallocBufferArray(scip, &ecost, 4) ); 654 SCIP_CALL( SCIPallocBufferArray(scip, &adjvert, 4) ); 655 SCIP_CALL( SCIPallocBufferArray(scip, &reinsert, 4) ); 656 SCIP_CALL( SCIPallocBufferArray(scip, &incedge, 4) ); 658 for( i = 0; i < 4; i++ ) 662 revancestors[i] = NULL; 670 for( i = 0; i < nnodes; i++ ) 688 assert(SCIPfindHeur(scip, "TM") != NULL); 689 tmheurdata = SCIPheurGetData(SCIPfindHeur(scip, "TM")); 691 for( e = 0; e < nedges; e++ ) 694 cost[e] = graph-> cost[e]; 702 SCIP_CALL( SCIPheurComputeSteinerTree(scip, tmheurdata, graph, NULL, &best_start, result, runs, root, cost, costrev, &hopfactor, NULL, 0.0, &success) ); 714 for( e = 0; e < nedges; e++ ) 716 upperbound += graph-> cost[e]; 725 for( run = 0; run < nruns; run++ ) 729 transnnodes = transgraph-> knots; 730 transnedges = transgraph-> edges; 732 SCIP_CALL( SCIPdualAscentStp(scip, transgraph, cost, &lpobjval, FALSE, gnodearr, edgearrint, state, root, 1, marked, nodearrchar) ); 737 minpathcost = upperbound - lpobjval; 738 SCIPdebugMessage( "xupperbound %f, lpobjval %f\n", upperbound, lpobjval); 740 for( e = 0; e < transnedges; e++ ) 746 for( k = 0; k < transnnodes; k++ ) 747 transgraph-> mark[k] = (transgraph-> grad[k] > 0); 756 for( i = 0; i < transnnodes; i++ ) 758 assert(SCIPisEQ(scip, pathdist[i], 0.0)); 771 for( k = 0; k < nnodes; k++ ) 776 if( SCIPisGT(scip, pathdist[k] + vnoi[k].dist, minpathcost) ) 780 e = transgraph-> outbeg[k]; 789 e = transgraph-> outbeg[k]; 792 etmp = transgraph-> oeat[e]; 794 if( SCIPisGT(scip, pathdist[k] + cost[e] + vnoi[transgraph-> head[e]]. dist, minpathcost) ) 812 SCIPdebugMessage( "fixed by da: %d \n", nfixed ); 822 for( k = 0; k < 4; k++ ) 828 SCIPfreeBufferArray(scip, &incedge); 829 SCIPfreeBufferArray(scip, &reinsert); 830 SCIPfreeBufferArray(scip, &adjvert); 831 SCIPfreeBufferArray(scip, &ecost); 832 SCIPfreeBufferArray(scip, &revancestors); 833 SCIPfreeBufferArray(scip, &ancestors); 834 SCIPfreeBufferArray(scip, &sd); 835 SCIPfreeBufferArray(scip, &marked); 837 if( edgearrint == NULL ) 838 SCIPfreeBufferArray(scip, &result); 854 SCIP_Real* upperbound, 861 SCIP_HEURDATA* tmheurdata; 905 assert(scip != NULL); 906 assert(graph != NULL); 907 assert(vnoi != NULL); 908 assert(cost != NULL); 909 assert(radius != NULL); 910 assert(costrev != NULL); 911 assert(heap != NULL); 912 assert(state != NULL); 913 assert(vbase != NULL); 914 assert(nelims != NULL); 915 assert(graph-> source[0] >= 0); 916 assert(upperbound != NULL); 923 nedges = graph-> edges; 924 nnodes = graph-> knots; 929 ub = SCIPisGT(scip, *upperbound, 0.0); 946 SCIP_CALL( SCIPallocBufferArray(scip, &result, nedges) ); 947 SCIP_CALL( SCIPallocBufferArray(scip, &stnode, nnodes) ); 958 for( k = 0; k < nnodes; k++ ) 962 assert(stnode != NULL); 966 graph-> mark[k] = (graph-> grad[k] > 0); 979 SCIPfreeBufferArrayNull(scip, &stnode); 980 SCIPfreeBufferArrayNull(scip, &result); 993 SCIP_CALL( SCIPallocBufferArray(scip, &starts, nnodes) ); 1000 if( graph-> mark[root] ) 1002 randval = SCIPgetRandomInt(0, nnodes - 1, &seed); 1005 for( k = 0; k < nnodes; k++ ) 1007 if( r >= runs || r >= nterms ) 1010 l = (k + randval) % nnodes; 1018 for( k = 0; k < r && r < runs; k++ ) 1020 for( e = graph-> outbeg[starts[k]]; e != EAT_LAST && r < runs; e = graph->oeat[e] ) 1029 for( k = 0; k < nnodes && r < runs; k++ ) 1031 l = (k + randval) % nnodes; 1044 for( e = 0; e < nedges; e++ ) 1048 assert(result != NULL); 1051 cost[e] = graph-> cost[e]; 1054 assert(SCIPisGE(scip, cost[e], 0.0)); 1057 maxcost = graph-> cost[e]; 1063 SCIP_CALL( graph_init(scip, &adjgraph, nterms, MIN(nedges, (nterms - 1) * nterms), 1, 0) ); 1071 SCIP_CALL( voronoi_radius(scip, graph, adjgraph, vnoi, radius, cost, costrev, vbase, heap, state) ); 1074 get2next(scip, graph, cost, costrev, vnoi, vbase, heap, state); 1077 get3next(scip, graph, cost, costrev, vnoi, vbase, heap, state); 1081 get4next(scip, graph, cost, costrev, vnoi, vbase, heap, state); 1086 assert(adjgraph != NULL); 1091 SCIP_CALL( SCIPallocBufferArray(scip, &mst, nterms) ); 1097 for( k = 1; k < nterms; k++ ) 1102 tmpcost = adjgraph-> cost[e]; 1104 if( SCIPisGT(scip, tmpcost, max) ) 1106 else if( SCIPisGT(scip, tmpcost, r) ) 1110 mstobj2 = mstobj - r; 1117 for( k = 0; k < nnodes; k++ ) 1122 if( SCIPisGT(scip, radius[k], prize[k]) && k != graph-> source[0] ) 1123 radius[k] = prize[k]; 1128 for( k = 0; k < nnodes; k++ ) 1130 if( !graph-> mark[k] ) 1133 if( Is_term(graph-> term[k]) && SCIPisGT(scip, radius[k], prize[k]) ) 1134 radius[k] = prize[k]; 1140 for( k = 0; k < nnodes; k++ ) 1145 assert(SCIPisGE(scip, prize[k], 0.0)); 1146 if( SCIPisGT(scip, prize[k], max) ) 1149 if( SCIPisGE(scip, radius[k], 0.0 ) ) 1152 radius[k] = -radius[k]; 1159 SCIP_CALL( SCIPallocBufferArray(scip, &perm, nnodes) ); 1160 for( k = 0; k < nnodes; k++ ) 1162 SCIPsortRealInt(radius, perm, nnodes); 1166 SCIPsortReal(radius, nnodes); 1174 for( k = 2; k < nterms; k++ ) 1176 assert( SCIPisGT(scip, FARAWAY, radius[k]) ); 1177 radiim2 += radius[k]; 1182 for( k = 0; k < nterms - 2; k++ ) 1184 assert( SCIPisGT(scip, FARAWAY, radius[k]) ); 1185 radiim2 += radius[k]; 1188 radii = radiim2 + radius[nterms - 2] + radius[nterms - 1]; 1191 radiim3 = radiim2 - radius[nterms - 3]; 1196 assert(SCIPfindHeur(scip, "TM") != NULL); 1197 tmheurdata = SCIPheurGetData(SCIPfindHeur(scip, "TM")); 1202 assert(stnode != NULL); 1203 assert(result != NULL); 1209 SCIP_CALL( SCIPheurComputeSteinerTree(scip, tmheurdata, graph, starts, &best_start, result, runs, root, cost, costrev, &obj, NULL, maxcost, &success) ); 1224 SCIPfreeBufferArrayNull(scip, &mst); 1225 SCIPfreeBufferArrayNull(scip, &starts); 1226 SCIPfreeBufferArray(scip, &result); 1227 SCIPfreeBufferArray(scip, &stnode); 1233 for( e = 0; e < nedges; e++ ) 1237 head = graph-> head[e]; 1240 if( graph-> mark[head] ) 1242 assert(stnode[head] == FALSE); 1248 obj += graph-> cost[e]; 1249 stnode[head] = TRUE; 1254 *upperbound = obj + *offset; 1258 obj = *upperbound - *offset; 1259 assert(SCIPisGE(scip, obj, 0.0)); 1262 printf( "radiim2: %f \n", radiim2); 1263 printf( "mstobj: %f \n", mstobj); 1264 printf( "totalobj: %f \n", obj); 1266 if( SCIPisGT(scip, radiim2, mstobj) ) 1272 for( k = 0; k < nnodes; k++ ) 1274 if( (!graph-> mark[k] && (pcmw)) || graph-> grad[k] == 0 ) 1279 tmpcost = -vnoi[k]. dist - vnoi[k + nnodes]. dist + bound - graph-> prize[k]; 1281 if( ! Is_term(graph-> term[k]) && (SCIPisLT(scip, tmpcost, obj)) ) 1294 etemp = graph-> oeat[e]; 1295 tail = graph-> tail[e]; 1296 head = graph-> head[e]; 1297 if( !graph-> mark[head] ) 1302 tmpcost = bound - graph-> prize[k]; 1303 if( vbase[tail] != vbase[head] ) 1305 tmpcost -= vnoi[head]. dist + vnoi[tail]. dist; 1309 if( SCIPisGT(scip, vnoi[tail].dist + vnoi[head + nnodes].dist, vnoi[tail + nnodes].dist + vnoi[head].dist) ) 1310 tmpcost -= vnoi[tail + nnodes]. dist + vnoi[head]. dist; 1312 tmpcost -= vnoi[tail]. dist + vnoi[head + nnodes]. dist; 1314 if( (SCIPisLT(scip, tmpcost, obj)) ) 1325 tmpcost = vnoi[k]. dist + vnoi[k + nnodes]. dist + bound; 1328 if( ! Is_term(graph-> term[k]) && (SCIPisGT(scip, tmpcost, obj) 1329 || (((stnode != NULL) ? !stnode[k] : 0) && SCIPisGE(scip, tmpcost, obj))) ) 1331 SCIPdebugMessage( "delete vertex: %d of degree: %d\n", k, graph-> grad[k]); 1337 assert(!pc || graph-> tail[e] != root); 1338 assert(!pc || graph-> mark[graph-> head[e]]); 1350 etemp = graph-> oeat[e]; 1351 tail = graph-> tail[e]; 1352 head = graph-> head[e]; 1353 tmpcost = graph-> cost[e] + bound; 1355 if( vbase[tail] != vbase[head] ) 1357 tmpcost += vnoi[head]. dist + vnoi[tail]. dist; 1361 if( SCIPisGT(scip, vnoi[tail].dist + vnoi[head + nnodes].dist, vnoi[tail + nnodes].dist + vnoi[head].dist) ) 1362 tmpcost += vnoi[tail + nnodes]. dist + vnoi[head]. dist; 1364 tmpcost += vnoi[tail]. dist + vnoi[head + nnodes]. dist; 1365 assert(SCIPisGE(scip, tmpcost, vnoi[head].dist + vnoi[tail].dist + graph-> cost[e] + bound)); 1368 if( (SCIPisGT(scip, tmpcost, obj) || (((result != NULL) ? (result[e] != CONNECT) : 0) && result[ flipedge(e)] != CONNECT && SCIPisGE(scip, tmpcost, obj))) 1369 && SCIPisLT(scip, graph-> cost[e], FARAWAY) && (!(pc || mw) || graph-> mark[head]) ) 1371 SCIPdebugMessage( "delete edge: %d->%d \n", graph-> tail[e], graph-> head[e]); 1393 for( k = 0; k < nnodes; k++ ) 1395 if( (!graph-> mark[k] && pc) || graph-> grad[k] == 0 ) 1400 tmpcost = vnoi[k]. dist + vnoi[k + nnodes]. dist + vnoi[k + 2 * nnodes]. dist + radiim3; 1401 if( SCIPisGT(scip, tmpcost, obj) ) 1404 if( ancestors == NULL ) 1406 SCIP_CALL( SCIPallocBufferArray(scip, &cost3, 3) ); 1407 SCIP_CALL( SCIPallocBufferArray(scip, &edges3, 3) ); 1408 SCIP_CALL( SCIPallocBufferArray(scip, &nodes3, 3) ); 1409 SCIP_CALL( SCIPallocBufferArray(scip, &ancestors, 3) ); 1410 SCIP_CALL( SCIPallocBufferArray(scip, &revancestors, 3) ); 1411 for( l = 0; l < 3; l++ ) 1413 ancestors[l] = NULL; 1414 revancestors[l] = NULL; 1418 assert(cost3 != NULL); 1419 assert(edges3 != NULL); 1420 assert(nodes3 != NULL); 1421 assert(ancestors != NULL); 1422 assert(revancestors != NULL); 1423 SCIPdebugMessage( "eliminated 3 knot %d\n", k); 1430 nodes3[l] = graph-> head[e]; 1431 cost3[l++] = graph-> cost[e]; 1435 for( l = 0; l < 3; l++ ) 1451 SCIP_CALL( graph_edge_reinsert(scip, graph, edges3[0], nodes3[0], nodes3[1], cost3[0] + cost3[1], ancestors[0], ancestors[1], revancestors[0], revancestors[1]) ); 1452 SCIP_CALL( graph_edge_reinsert(scip, graph, edges3[1], nodes3[1], nodes3[2], cost3[1] + cost3[2], ancestors[1], ancestors[2], revancestors[1], revancestors[2]) ); 1453 SCIP_CALL( graph_edge_reinsert(scip, graph, edges3[2], nodes3[2], nodes3[0], cost3[2] + cost3[0], ancestors[2], ancestors[0], revancestors[2], revancestors[0]) ); 1455 assert(graph-> grad[k] == 0); 1460 if( ancestors != NULL ) 1462 assert(revancestors != NULL); 1463 for( k = 0; k < 3; k++ ) 1468 SCIPfreeBufferArray(scip, &revancestors); 1469 SCIPfreeBufferArray(scip, &ancestors); 1470 SCIPfreeBufferArray(scip, &nodes3); 1471 SCIPfreeBufferArray(scip, &edges3); 1472 SCIPfreeBufferArray(scip, &cost3); 1480 getnext4tterms(scip, graph, cost, costrev, vnoi, vbase, heap, state); 1482 for( k = 0; k < nnodes; k++ ) 1487 assert(perm != NULL); 1488 for( l = 0; l < nterms; l++ ) 1492 tmpcost = vnoi[k]. dist + radii - radius[l]; 1494 if( l == nterms - 1 ) 1495 tmpcost -= radius[nterms - 2]; 1497 tmpcost -= radius[nterms - 1]; 1500 if( SCIPisGT(scip, tmpcost, obj) ) 1502 SCIPdebugMessage( "alternative bnd elimination!!! \n\n"); 1504 (*offset) += graph-> prize[k]; 1508 tmpcost += vnoi[k + nnodes]. dist; 1509 if( l >= nterms - 2 ) 1510 tmpcost -= radius[nterms - 3]; 1512 tmpcost -= radius[nterms - 2]; 1513 if( SCIPisGT(scip, tmpcost, obj) || SCIPisGT(scip, mstobj2 + vnoi[k].dist + vnoi[k + nnodes].dist, obj) ) 1516 if( graph-> mark[graph-> head[e]] && SCIPisLT(scip, graph-> cost[e], graph-> prize[k]) ) 1521 SCIPdebugMessage( "second elimination!!! prize: %f \n\n", graph-> prize[k]); 1522 (*offset) += graph-> prize[k]; 1531 SCIPdebugMessage( "nelims (edges) in bound reduce: %d,\n", *nelims); 1541 SCIPfreeBufferArrayNull(scip, &perm); 1542 SCIPfreeBufferArrayNull(scip, &mst); 1543 SCIPfreeBufferArrayNull(scip, &starts); 1544 SCIPfreeBufferArrayNull(scip, &stnode); 1545 SCIPfreeBufferArrayNull(scip, &result); 1583 assert(scip != NULL); 1584 assert(graph != NULL); 1585 assert(vnoi != NULL); 1586 assert(cost != NULL); 1587 assert(radius != NULL); 1588 assert(costrev != NULL); 1589 assert(heap != NULL); 1590 assert(state != NULL); 1591 assert(vbase != NULL); 1592 assert(nelims != NULL); 1596 nedges = graph-> edges; 1597 nnodes = graph-> knots; 1599 for( k = 0; k < nnodes; k++ ) 1601 graph-> mark[k] = (graph-> grad[k] > 0); 1606 for( e = 0; e < nedges; e++ ) 1619 SCIP_CALL( graph_init(scip, &adjgraph, nterms, MIN(nedges, (nterms - 1) * nterms), 1, 0) ); 1621 SCIP_CALL( voronoi_radius(scip, graph, adjgraph, vnoi, radius, cost, costrev, vbase, heap, state) ); 1624 get2next(scip, graph, cost, costrev, vnoi, vbase, heap, state); 1630 SCIP_CALL( SCIPallocBufferArray(scip, &mst, nterms) ); 1635 assert(mst[0].edge == -1); 1639 for( k = 1; k < nterms; k++ ) 1644 tmpcost = adjgraph-> cost[e]; 1646 if( SCIPisGT(scip, tmpcost, max) ) 1652 SCIPsortReal(radius, nnodes); 1655 for( e = 0; e < nterms - 2; e++ ) 1657 assert( SCIPisGT(scip, FARAWAY, radius[e]) ); 1658 radiim2 += radius[e]; 1661 hoplimit = (SCIP_Real) graph-> hoplimit; 1663 printf( "radiim2: %f \n", radiim2); 1664 printf( "mstobj: %f \n", mstobj); 1665 printf( "hoplimit: %f \n", hoplimit); 1667 if( SCIPisGT(scip, radiim2, mstobj) ) 1673 for( k = 0; k < nnodes; k++ ) 1676 if( ! Is_term(graph-> term[k]) && SCIPisGT(scip, vnoi[k].dist + vnoi[k + nnodes].dist + bound, hoplimit) ) 1685 etemp = graph-> oeat[e]; 1696 tail = graph-> tail[e]; 1697 head = graph-> head[e]; 1698 tmpcost = 1.0 + bound; 1699 if( vbase[tail] != vbase[head] ) 1701 tmpcost += vnoi[head]. dist + vnoi[tail]. dist; 1705 if( SCIPisGT(scip, vnoi[tail].dist + vnoi[head + nnodes].dist, vnoi[tail + nnodes].dist + vnoi[head].dist) ) 1706 tmpcost += vnoi[tail + nnodes]. dist + vnoi[head]. dist; 1708 tmpcost += vnoi[tail]. dist + vnoi[head + nnodes]. dist; 1709 assert(SCIPisGE(scip, tmpcost, vnoi[head].dist + vnoi[tail].dist + 1.0 + bound)); 1713 if( SCIPisGT(scip, tmpcost, hoplimit) && SCIPisLT(scip, graph-> cost[e], FARAWAY) ) 1715 etemp = graph-> oeat[e]; 1736 SCIPdebugMessage( "nelimsX (edges) in hop bound reduce: %d,\n", *nelims); 1743 SCIPfreeBufferArray(scip, &mst); 1756 SCIP_Real* pathdist, 1776 assert(scip != NULL); 1777 assert(graph != NULL); 1778 assert(vnoi != NULL); 1779 assert(cost != NULL); 1780 assert(costrev != NULL); 1781 assert(heap != NULL); 1782 assert(state != NULL); 1783 assert(vbase != NULL); 1784 assert(nelims != NULL); 1789 nedges = graph-> edges; 1790 nnodes = graph-> knots; 1793 for( k = 0; k < nnodes; k++ ) 1795 graph-> mark[k] = (graph-> grad[k] > 0); 1800 for( e = 0; e < nedges; e++ ) 1805 cost[e] = graph-> cost[e]; 1820 voronoi_terms(scip, graph, costrev, vnoi, vbase, heap, state); 1823 for( k = 0; k < nnodes; k++ ) 1826 if( ! Is_term(graph-> term[k]) && SCIPisGT(scip, vnoi[k].dist + pathdist[k] + ( double) bound, ( double) hoplimit) ) 1835 etemp = graph-> oeat[e]; 1846 head = graph-> head[e]; 1847 tmpcost = pathdist[k] + 1.0 + vnoi[head]. dist + bound; 1849 etemp = graph-> oeat[e]; 1851 if( SCIPisGT(scip, tmpcost, ( double) hoplimit) && SCIPisLT(scip, graph-> cost[e], FARAWAY) ) 1870 SCIPdebugMessage( "eliminated (edges) in hcr bound reduce: %d,\n", *nelims); 1884 SCIP_Real* pathdist, 1895 SCIP_HEURDATA* tmheurdata; 1901 SCIP_Real hopfactor; 1913 assert(scip != NULL); 1914 assert(graph != NULL); 1915 assert(vnoi != NULL); 1916 assert(cost != NULL); 1917 assert(costrev != NULL); 1918 assert(heap != NULL); 1919 assert(state != NULL); 1920 assert(vbase != NULL); 1921 assert(nelims != NULL); 1930 nedges = graph-> edges; 1931 nnodes = graph-> knots; 1933 SCIP_CALL( SCIPallocBufferArray(scip, &result, nedges) ); 1938 assert(vars != NULL); 1939 for( e = 0; e < nedges; e += 2 ) 1944 if( SCIPvarGetUbLocal(vars[e + 1]) < 0.5 ) 1950 costrev[e] = graph-> cost[e + 1]; 1952 if( SCIPisGT(scip, costrev[e], maxcost) && SCIPisLT(scip, costrev[e], BLOCKED) ) 1953 maxcost = costrev[e]; 1955 cost[e + 1] = costrev[e]; 1956 if( SCIPvarGetUbLocal(vars[e]) < 0.5 ) 1962 costrev[e + 1] = graph-> cost[e]; 1964 if( SCIPisGT(scip, graph-> cost[e], maxcost) && SCIPisLT(scip, costrev[e + 1], BLOCKED) ) 1965 maxcost = graph-> cost[e]; 1967 cost[e] = costrev[e + 1]; 1972 for( e = 0; e < nedges; e++ ) 1975 cost[e] = graph-> cost[e]; 1977 if( SCIPisGT(scip, graph-> cost[e], maxcost) ) 1978 maxcost = graph-> cost[e]; 1983 for( k = 0; k < nnodes; k++ ) 1985 graph-> mark[k] = (graph-> grad[k] > 0); 1992 if( SCIPisLT(scip, cost[e], min) ) 1994 assert(SCIPisGT(scip, BLOCKED, min)); 1995 if( SCIPisGT(scip, min, maxmin) ) 2012 voronoi_terms(scip, graph, costrev, vnoi, vbase, heap, state); 2014 if( SCIPisLT(scip, objval, 0.0) ) 2017 assert(SCIPfindHeur(scip, "TM") != NULL); 2018 tmheurdata = SCIPheurGetData(SCIPfindHeur(scip, "TM")); 2021 SCIP_CALL( SCIPheurComputeSteinerTree(scip, tmheurdata, graph, NULL, &best_start, result, 50, root, cost, costrev, &hopfactor, NULL, maxcost, &success) ); 2024 for( e = 0; e < nedges; e++ ) 2026 objval += graph-> cost[e]; 2031 objval = SCIPgetCutoffbound(scip); 2032 assert(SCIPisGT(scip, objval, 0.0)); 2036 for( k = 0; k < nnodes; k++ ) 2041 if( SCIPisGT(scip, vnoi[k].dist + pathdist[k] + bound, objval) ) 2050 etemp = graph-> oeat[e]; 2053 assert(vars != NULL); 2055 SCIP_CALL( fixedgevar(scip, vars[e], nelims) ); 2074 head = graph-> head[e]; 2075 tmpcost = pathdist[k] + graph-> cost[e] + vnoi[head]. dist + bound; 2077 etemp = graph-> oeat[e]; 2079 if( SCIPisGT(scip, tmpcost, objval) && SCIPisLT(scip, graph-> cost[e], FARAWAY) ) 2083 assert(vars != NULL); 2086 SCIP_CALL( fixedgevar(scip, vars[e], nelims) ); 2107 SCIPdebugMessage( "CCC eliminated (edges) in hcrc bound reduce: %d,\n", *nelims); 2109 SCIPfreeBufferArray(scip, &result); SCIP_RETCODE graph_path_init(SCIP *, GRAPH *)
void get3next(SCIP *, const GRAPH *, SCIP_Real *, SCIP_Real *, PATH *, int *, int *, int *)
static void compTMstarts(GRAPH *graph, int *starts, unsigned int *seed, int runs)
int graph_valid(const GRAPH *)
SCIP_RETCODE SCIPdualAscentStp(SCIP *scip, GRAPH *g, SCIP_Real *redcost, SCIP_Real *objval, SCIP_Bool addcuts, GNODE **gnodearrterms, int *edgearrint, int *nodearrint, int root, int nruns, char *edgearrchar, char *nodearrchar)
SCIP_RETCODE fixedgevar(SCIP *scip, SCIP_VAR *edgevar, int *nfixed)
Constraint handler for Steiner problems.
#define DEFAULT_HOPFACTOR
void getnext4tterms(SCIP *, const GRAPH *, SCIP_Real *, SCIP_Real *, PATH *, int *, int *, int *)
SCIP_RETCODE da_reduce(SCIP *scip, GRAPH *graph, PATH *vnoi, GNODE **gnodearr, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real *pathdist, int *edgearrint, int *vbase, int *pathedge, int *state, int *heursources, char *nodearrchar, int *nelims)
SCIP_VAR ** SCIPprobdataGetVars(SCIP *scip)
SCIP_RETCODE graph_PcSapCopy(SCIP *, GRAPH *, GRAPH **, SCIP_Real *)
SCIP_RETCODE graph_init_history(SCIP *, GRAPH *)
void get4next(SCIP *, const GRAPH *, SCIP_Real *, SCIP_Real *, PATH *, int *, int *, int *)
SCIP_RETCODE graph_edge_reinsert(SCIP *, GRAPH *, int, int, int, SCIP_Real, IDX *, IDX *, IDX *, IDX *)
SCIP_RETCODE pcgraphtrans(SCIP *, GRAPH *)
Problem data for stp problem.
void graph_path_exit(SCIP *, GRAPH *)
static SCIP_RETCODE probdataPrintGraph(GRAPH *graph, const char *filename, SCIP_Bool *edgemark)
void get2next(SCIP *, const GRAPH *, SCIP_Real *, SCIP_Real *, PATH *, int *, int *, int *)
void graph_free(SCIP *, GRAPH *, SCIP_Bool)
void graph_knot_chg(GRAPH *, int, int)
int deleteterm(SCIP *, GRAPH *, int)
void SCIPintListNodeFree(SCIP *scip, IDX **node)
SCIP_RETCODE pcgraphorg(SCIP *, GRAPH *)
void graph_path_execX(SCIP *, const GRAPH *, int, SCIP_Real *, SCIP_Real *, int *)
miscellaneous methods used for solving Steiner problems
SCIP_RETCODE voronoi_radius(SCIP *scip, const GRAPH *, GRAPH *, PATH *, SCIP_Real *, SCIP_Real *, SCIP_Real *, int *, int *, int *)
SCIP_RETCODE SCIPheurComputeSteinerTree(SCIP *scip, SCIP_HEURDATA *heurdata, const GRAPH *graph, int *starts, int *bestnewstart, int *best_result, int runs, int bestincstart, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real *hopfactor, SCIP_Real *nodepriority, SCIP_Real maxcost, SCIP_Bool *success)
#define STP_MAX_NODE_WEIGHT
void voronoi_terms(SCIP *, const GRAPH *, SCIP_Real *, PATH *, int *, int *, int *)
void getnext4terms(SCIP *, const GRAPH *, SCIP_Real *, SCIP_Real *, PATH *, int *, int *, int *)
Improvement heuristic for Steiner problems.
propagator for Steiner tree problems, using the LP reduced costs
SCIP_RETCODE hcrcbound_reduce(SCIP *scip, GRAPH *graph, PATH *vnoi, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real *pathdist, SCIP_Real objval, int *heap, int *state, int *vbase, int *nelims, int *pathedge, SCIP_Bool fix)
SCIP_RETCODE SCIPintListNodeAppendCopy(SCIP *scip, IDX **node1, IDX *node2)
#define STP_PRIZE_COLLECTING
SCIP_RETCODE graph_init(SCIP *, GRAPH **, int, int, int, int)
void graph_edge_del(SCIP *, GRAPH *, int, SCIP_Bool)
includes various files containing graph methods used for Steiner problems
SCIP_RETCODE hopbound_reduce(SCIP *scip, GRAPH *graph, PATH *vnoi, SCIP_Real *cost, SCIP_Real *radius, SCIP_Real *costrev, int *heap, int *state, int *vbase, int *nelims)
SCIP_RETCODE bound_reduce(SCIP *scip, GRAPH *graph, PATH *vnoi, SCIP_Real *cost, SCIP_Real *prize, SCIP_Real *radius, SCIP_Real *costrev, SCIP_Real *offset, SCIP_Real *upperbound, int *heap, int *state, int *vbase, int *nelims)
SCIP_RETCODE hcrbound_reduce(SCIP *scip, GRAPH *graph, PATH *vnoi, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real *pathdist, int *heap, int *state, int *vbase, int *nelims, int *pathedge)
SCIP_RETCODE extendSteinerTreePcMw(SCIP *scip, const GRAPH *graph, PATH *vnoi, SCIP_Real *costrev, int *vbase, int *stedge, char *stvertex, int *adds)
#define STP_ROOTED_PRIZE_COLLECTING
SCIP_RETCODE daPc_reduce(SCIP *scip, GRAPH *graph, PATH *vnoi, GNODE **gnodearr, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real *pathdist, int *vbase, int *pathedge, int *edgearrint, int *state, char *nodearrchar, int *nelims)
shortest paths based primal heuristics for Steiner problems
void graph_path_exec(SCIP *, const GRAPH *, int, int, SCIP_Real *, PATH *)
|