|
|
Go to the documentation of this file. 37 #include "scip/scip.h" 41 #define KNOTLIMIT 1e+20 47 SCIP_RETCODE printGraph( 54 char label[SCIP_MAXSTRLEN]; 60 SCIP_CALL( SCIPallocBufferArray(scip, &stnodes, graph-> knots ) ); 62 assert(graph != NULL); 63 file = fopen((filename != NULL) ? filename : "graphX.gml", "w"); 65 for( e = 0; e < graph-> knots; e++ ) 69 for( e = 0; e < graph-> edges; e++ ) 79 SCIPgmlWriteOpening(file, FALSE); 84 for( n = 0; n < graph-> knots; ++n ) 88 if( n == graph-> source[0] ) 90 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, "(%d) Root", n); 91 SCIPgmlWriteNode(file, ( unsigned int)n, label, "rectangle", "#666666", NULL); 94 else if( graph-> term[n] == 0 ) 96 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, "(%d) Terminal %d", n, e + 1); 97 SCIPgmlWriteNode(file, ( unsigned int)n, label, "circle", "#ff0000", NULL); 102 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, "(%d) Node %d", n, n + 1 - e - m); 103 SCIPgmlWriteNode(file, ( unsigned int)n, label, "circle", "#336699", NULL); 110 for( e = 0; e < graph-> edges; e ++ ) 114 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN, "%8.2f", graph-> cost[e]); 115 SCIPgmlWriteEdge(file, ( unsigned int)graph-> tail[e], ( unsigned int)graph-> head[e], label, "#ff0000"); 118 SCIPfreeBufferArray(scip, &stnodes); 120 SCIPgmlWriteClosing(file); 148 assert(path != NULL); 149 assert(scip != NULL); 150 assert(vbase != NULL); 151 assert(forbidden != NULL); 166 printf( "deletable! \n"); 171 if( forbidden[edge] ) 190 e = path[tail + tpos * nnodes]. edge; 193 assert(g-> head[e] == tail); 195 if( g-> tail[e] == head ) 199 base = vbase[tail + tpos * nnodes]; 200 shift = tpos * nnodes; 203 e = path[k + shift]. edge; 207 if( e == edge || e == antiedge || g-> ieat[e] == EAT_FREE ) 216 e = path[head + hpos * nnodes]. edge; 219 assert(g-> head[e] == head); 221 if( g-> tail[e] == tail ) 231 SCIP_Real ecost = g-> cost[edge]; 236 if( SCIPisEQ(scip, g-> cost[e], ecost) ) 250 SCIP_Real ecost = g-> cost[edge]; 255 if( SCIPisEQ(scip, g-> cost[e], ecost) ) 265 printf( "deletable! \n"); 287 assert(scip != NULL); 288 assert(vnoi != NULL); 289 assert(vbase != NULL); 290 assert(termdist != NULL); 291 assert(neighbterms != NULL); 293 for( k = 0; k < 4; k++ ) 295 if( SCIPisLT(scip, vnoi[pos].dist, ecost) ) 297 neighbterms[nnterms] = vbase[pos]; 298 termdist[nnterms++] = vnoi[pos]. dist; 326 assert(scip != NULL); 327 assert(vnoi != NULL); 328 assert(vbase != NULL); 329 assert(termdist != NULL); 330 assert(neighbterms != NULL); 332 for( k = 0; k < 4; k++ ) 334 if( SCIPisLE(scip, vnoi[pos].dist, ecost) ) 336 neighbterms[nnterms] = vbase[pos]; 337 termdist[nnterms++] = vnoi[pos]. dist; 352 const double* pathdist, 353 const double* pathtran, 357 return (SCIPisLT(scip, pathdist[a], pathdist[b]) || (!SCIPisGT(scip, pathdist[a], pathdist[b]) && SCIPisLT(scip, pathtran[a], pathtran[b]))); 361 const double* pathdist, 362 const double* pathtran, 366 return (SCIPisGT(scip, pathdist[a], pathdist[b]) || (!SCIPisLT(scip, pathdist[a], pathdist[b]) && SCIPisGT(scip, pathtran[a], pathtran[b]))); 380 const double* pathdist, 381 const double* pathtran) 394 heap[1] = heap[(*count)--]; 398 if ( islarger(scip, pathdist, pathtran, heap[2], heap[3])) 401 while((c <= (*count)) && islarger(scip, pathdist, pathtran, heap[j], heap[c])) 411 if ((c + 1) <= (*count)) 412 if ( issmaller(scip, pathdist, pathtran, heap[c + 1], heap[c])) 437 heap[++(*count)] = l; 446 while((j > 1) && ( islarger(scip, pathdist, pathtran, heap[c], heap[j]))) 467 const double* randarr, 484 assert(scip != NULL); 487 assert(start < p->knots); 488 assert(heap != NULL); 489 assert(state != NULL); 490 assert(pathdist != NULL); 491 assert(pathtran != NULL); 492 assert(cost != NULL); 493 assert(count != NULL); 505 for(i = 0; i < p-> knots; i++) 534 k = nearest(scip, heap, state, count, pathdist, pathtran); 541 if (++done >= p-> grad[start]) 556 if ((state[m]) && (p-> mark[m])) 573 tran = pathtran[k] + cost[i]; 574 temprand = pathrand[k] + randarr[i]; 577 if( SCIPisGE(scip, pathdist[k], pathtran[k] + cost[i]) ) 580 dist = pathtran[k] + cost[i]; 582 if( SCIPisLT(scip, dist, pathdist[m]) 583 || (SCIPisEQ(scip, dist, pathdist[m]) && SCIPisLT(scip, tran, pathtran[m])) ) 587 pathrand[m] = temprand; 589 correct(scip, heap, state, count, pathdist, pathtran, m); 602 SCIP_Real* edgepreds, 615 SCIP_Real* termdist1; 616 SCIP_Real* termdist2; 644 assert(scip != NULL); 645 assert(heap != NULL); 646 assert(vnoi != NULL); 647 assert(state != NULL); 648 assert(vbase != NULL); 649 assert(nelims != NULL); 650 assert(nodesid != NULL); 651 assert(mstsdist != NULL); 652 assert(nodesorg != NULL); 653 assert(edgepreds != NULL); 654 assert(forbidden != NULL); 660 maxnedges = MIN(nedges, (nterms - 1) * nterms); 666 SCIP_CALL( SCIPallocBufferArray(scip, &termdist1, 4) ); 667 SCIP_CALL( SCIPallocBufferArray(scip, &termdist2, 4) ); 668 SCIP_CALL( SCIPallocBufferArray(scip, &neighbterms1, 4) ); 669 SCIP_CALL( SCIPallocBufferArray(scip, &neighbterms2, 4) ); 678 for( tpos = 0; tpos < 4; tpos++ ) 680 for( k = 0; k < nnodes; k++ ) 686 base = vbase[k + tpos * nnodes]; 689 shift = tpos * nnodes; 691 printf( "in %d\n", base); 697 printf( "FAIL k: %d, tpos: %d, base: %d\n",k, tpos, base); 700 e = vnoi[i + shift]. edge; 712 SCIP_Real** pathdist = NULL; 713 int** pathedge = NULL; 714 SCIP_CALL( SCIPallocBufferArray(scip, &pathdist, nnodes) ); 715 SCIP_CALL( SCIPallocBufferArray(scip, &pathedge, nnodes) ); 716 BMSclearMemoryArray(pathdist, nnodes); 717 BMSclearMemoryArray(pathedge, nnodes); 719 for( k = 0; k < nnodes; k++ ) 725 SCIP_CALL( SCIPallocBufferArray(scip, &(pathdist[k]), nnodes) ); 726 SCIP_CALL( SCIPallocBufferArray(scip, &(pathedge[k]), nnodes) ); 730 for( k = 0; k < nnodes; k++ ) 734 assert(pathdist[k] != NULL); 735 assert(pathedge[k] != NULL); 742 printf( "x %f, %f ", pathdist[k][i], vnoi[k].dist); 743 printf( "node terminal %d, %d \n\n", k, i); 745 if( !SCIPisEQ(scip, pathdist[k][i], vnoi[k].dist ) ) 747 printf( "FAILS0 %f, %f ", pathdist[k][i], vnoi[k].dist); 748 printf( "node terminal %d, %d \n\n", k, i); 753 i = vbase[k + nnodes]; 754 printf( "x2 %f, %f ", pathdist[k][i], vnoi[k + nnodes].dist); 755 printf( "node terminal %d, %d \n\n", k, i); 757 if( i != -1 && !SCIPisEQ(scip, pathdist[k][i], vnoi[k + nnodes].dist ) ) 759 printf( "FAILS1 %f, %f ", pathdist[k][i], vnoi[k + nnodes].dist); 760 printf( "node terminal %d, %d \n\n", k, i); 763 i = vbase[k + 2 * nnodes]; 764 printf( "x3 %f, %f ", pathdist[k][i], vnoi[k + 2 * nnodes].dist); 765 printf( "node terminal %d, %d \n\n", k, i); 767 if( i != -1 && !SCIPisEQ(scip, pathdist[k][i], vnoi[k + 2 * nnodes].dist ) ) 769 printf( "FAILS2 %f, %f ", pathdist[k][i], vnoi[k + 2 * nnodes].dist); 770 printf( "node terminal %d, %d \n\n", k, i); 774 i = vbase[k + 3 * nnodes]; 775 printf( "x4 %f, %f ", pathdist[k][i], vnoi[k + 3 * nnodes].dist); 776 printf( "node terminal %d, %d \n\n", k, i); 778 if( i != -1 && SCIPisLT(scip, pathdist[k][i], vnoi[k + 3 * nnodes].dist ) ) 780 printf( "FAILS3 %f, %f ", pathdist[k][i], vnoi[k + 3 * nnodes].dist); 781 printf( "node terminal %d, %d \n\n", k, i); 787 for( k = nnodes - 1; k >= 0; k-- ) 789 SCIPfreeBufferArrayNull(scip, &(pathedge[k])); 790 SCIPfreeBufferArrayNull(scip, &(pathdist[k])); 793 SCIPfreeBufferArray(scip, &pathedge); 794 SCIPfreeBufferArray(scip, &pathdist); 801 SCIP_CALL( graph_init(scip, &netgraph, nterms, maxnedges, 1, 0) ); 804 for( k = 0; k < nnodes; k++ ) 818 forbidden[k] = FALSE; 822 for( k = nnodes - 1; k < nedges; k++ ) 824 forbidden[k] = FALSE; 828 assert(netgraph-> knots == j); 829 assert(netgraph-> knots == nterms); 831 for( k = 0; k < nnodes; k++ ) 838 if( i != vbase[g-> head[e]] ) 840 i2 = vbase[g-> head[e]]; 849 if( netgraph-> head[ne] == id2 ) 859 assert(netgraph-> tail[ne] == id1); 860 assert(netgraph-> head[ne] == id2); 863 if( SCIPisGT(scip, netgraph-> cost[ne], ecost) ) 865 netgraph-> cost[ne] = ecost; 870 assert(ne <= maxnedges); 875 edgepreds[netgraph-> edges] = e; 879 assert(netgraph-> edges <= maxnedges); 889 SCIP_CALL( SCIPallocBufferArray(scip, &mst, nterms) ); 895 for( k = 1; k < netgraph-> knots; k++ ) 897 assert(mst[k].edge != -1); 898 assert(( int) edgepreds[mst[k].edge] != -1); 899 assert(( int) edgepreds[ flipedge(mst[k].edge)] != -1); 901 e = (int) edgepreds[mst[k].edge]; 903 assert(vbase[g-> tail[e]] == nodesorg[k] || vbase[g-> head[e]] == nodesorg[k]); 913 while( i1 != vbase[i1] ) 921 while( i2 != vbase[i2] ) 932 for( i = 0; i < nnodes; i++ ) 951 if( i2 < i || !g->mark[i2] ) 961 nnterms1 = getcloseterms(scip, vnoi, termdist1, ecost, vbase, neighbterms1, i, nnodes); 963 nnterms2 = getlecloseterms(scip, vnoi, termdist2, ecost, vbase, neighbterms2, i2, nnodes); 965 nnterms1 = getlecloseterms(scip, vnoi, termdist1, ecost, vbase, neighbterms1, i, nnodes); 977 neighbterms2[0] = i2; 984 nnterms2 = getcloseterms(scip, vnoi, termdist2, ecost, vbase, neighbterms2, i2, nnodes); 986 nnterms2 = getlecloseterms(scip, vnoi, termdist2, ecost, vbase, neighbterms2, i2, nnodes); 988 nnterms2 = getlecloseterms(scip, vnoi, termdist2, ecost, vbase, neighbterms2, i2, nnodes); 994 for( j = 0; j < nnterms1; j++ ) 1000 tj = neighbterms1[j]; 1004 for( k = 0; k < nnterms2; k++ ) 1006 tk = neighbterms2[k]; 1014 if( SCIPisGE(scip, termdist1[j], termdist2[k] ) ) 1015 dist = termdist1[j]; 1017 dist = termdist2[k]; 1019 assert(SCIPisGE(scip, ecost, dist)); 1021 if( SCIPisEQ(scip, dist, ecost) ) 1022 if( ! sddeltable(scip, g, vnoi, vbase, forbidden, j, k, i, i2, e, nnodes ) ) 1046 assert(netgraph-> head[ne] == l); 1048 l = netgraph-> tail[ne]; 1050 if( SCIPisGT(scip, netgraph-> cost[ne], dist) ) 1051 dist = netgraph-> cost[ne]; 1072 l = netgraph-> tail[ne]; 1074 if( SCIPisGT(scip, netgraph-> cost[ne], dist) ) 1075 dist = netgraph-> cost[ne]; 1077 if( mstsdist[l] >= 0 ) 1079 if( SCIPisGT(scip, mstsdist[l], dist) ) 1094 l = netgraph-> tail[ne]; 1100 assert(SCIPisGT(scip, dist, 0.0)); 1102 if( SCIPisLT(scip, dist, termdist1[j]) ) 1103 dist = termdist1[j]; 1105 if( SCIPisLT(scip, dist, termdist2[k]) ) 1106 dist = termdist2[k]; 1108 if( SCIPisGE(scip, ecost, dist) ) 1110 if( SCIPisEQ(scip, ecost, dist) ) 1111 if( !( sddeltable(scip, g, vnoi, vbase, forbidden, j, k, i, i2, e, nnodes)) ) 1114 assert(SCIPisGE(scip, ecost, termdist1[j])); 1115 assert(SCIPisGE(scip, ecost, termdist2[k])); 1128 SCIP_CALL( bdr_reduction(scip, g, netgraph, mst, vnoi, mstsdist, termdist1, termdist2, vbase, nodesid, neighbterms1, neighbterms2, nelims) ); 1133 SCIPfreeBufferArray(scip, &mst); 1134 SCIPfreeBufferArray(scip, &neighbterms2); 1135 SCIPfreeBufferArray(scip, &neighbterms1); 1136 SCIPfreeBufferArray(scip, &termdist2); 1137 SCIPfreeBufferArray(scip, &termdist1); 1148 SCIP_Real* boundedges, 1158 SCIP_Real* termdist1; 1159 SCIP_Real* termdist2; 1185 assert(heap != NULL); 1186 assert(vnoi != NULL); 1187 assert(state != NULL); 1188 assert(vbase != NULL); 1189 assert(scip != NULL); 1190 assert(nelims != NULL); 1191 assert(nodesid != NULL); 1192 assert(nodesorg != NULL); 1193 assert(boundedges != NULL); 1200 maxnedges = MIN(nedges, (nterms - 1) * nterms); 1202 SCIP_CALL( SCIPallocBufferArray(scip, &termdist1, 4) ); 1203 SCIP_CALL( SCIPallocBufferArray(scip, &termdist2, 4) ); 1204 SCIP_CALL( SCIPallocBufferArray(scip, &neighbterms1, 4) ); 1205 SCIP_CALL( SCIPallocBufferArray(scip, &neighbterms2, 4) ); 1213 SCIP_CALL( graph_init(scip, &netgraph, nterms, maxnedges, 1, 0) ); 1215 for( k = 0; k < 4; k++ ) 1222 for( k = 0; k < nnodes; k++ ) 1236 assert(netgraph-> knots == j); 1237 assert(netgraph-> knots == nterms); 1240 for( k = 0; k < nnodes; k++ ) 1250 if( i != vbase[g-> head[e]] ) 1252 i2 = vbase[g-> head[e]]; 1256 assert(nodesid[i] >= 0); 1257 assert(nodesid[i2] >= 0); 1259 if( netgraph-> head[ne] == nodesid[i2] ) 1267 assert(netgraph-> head[ne] == nodesid[i2]); 1268 assert(netgraph-> tail[ne] == nodesid[i]); 1269 if( SCIPisGT(scip, netgraph-> cost[ne], ecost) ) 1271 netgraph-> cost[ne] = ecost; 1273 assert(ne <= maxnedges); 1278 graph_edge_add(scip, netgraph, nodesid[i], nodesid[i2], ecost, ecost); 1279 assert(netgraph-> edges <= maxnedges); 1289 for( i = 0; i < nnodes; i++ ) 1308 for( k = 0; k < 4; k++ ) 1314 if( SCIPisLT(scip, netgraph-> cost[ne], ecost) ) 1316 j = nodesorg[netgraph-> head[ne]]; 1317 necost = netgraph-> cost[ne]; 1322 for( k = 0; k < 4; k++ ) 1324 if( neighbterms1[k] == UNKNOWN || SCIPisGT(scip, termdist1[k], necost) ) 1326 for( l = 3; l > k; l-- ) 1328 neighbterms1[l] = neighbterms1[l - 1]; 1329 termdist1[l] = termdist1[l - 1]; 1331 neighbterms1[k] = j; 1332 termdist1[k] = necost; 1341 nnterms1 = getcloseterms(scip, vnoi, termdist1, ecost, vbase, neighbterms1, i, nnodes); 1344 nnterms1 = getcloseterms(scip, vnoi, termdist1, ecost, vbase, neighbterms1, i, nnodes); 1353 for( k = 0; k < 4; k++ ) 1359 if( SCIPisLT(scip, netgraph-> cost[ne], ecost) ) 1361 j = nodesorg[netgraph-> head[ne]]; 1362 necost = netgraph-> cost[ne]; 1367 for( k = 0; k < 4; k++ ) 1369 if( neighbterms2[k] == UNKNOWN || SCIPisGT(scip, termdist2[k], necost) ) 1371 for( l = 3; l > k; l-- ) 1373 neighbterms2[l] = neighbterms2[l - 1]; 1374 termdist2[l] = termdist2[l - 1]; 1376 neighbterms2[k] = j; 1377 termdist2[k] = necost; 1386 nnterms2 = getcloseterms(scip, vnoi, termdist2, ecost, vbase, neighbterms2, i2, nnodes); 1389 nnterms2 = getcloseterms(scip, vnoi, termdist2, ecost, vbase, neighbterms2, i2, nnodes); 1395 for( j = 0; j < nnterms1; j++ ) 1400 tj = neighbterms1[j]; 1403 for( k = 0; k < nnterms2; k++ ) 1405 tk = neighbterms2[k]; 1410 if( SCIPisGT(scip, ecost, termdist1[j] + termdist2[k] - g-> prize[tj]) || tj == root ) 1423 if( netgraph-> head[e2] == nodesid[tk] ) 1425 necost = netgraph-> cost[e2]; 1431 for( l = 0; l < 4; l++ ) 1435 if( vbase[pos] == tk && SCIPisLT(scip, vnoi[pos].dist, necost) ) 1437 necost = vnoi[pos]. dist; 1445 if( e2 != EAT_LAST && SCIPisGT(scip, ecost, necost) 1446 && SCIPisGT(scip, ecost, necost + termdist1[j] - g-> prize[tj]) 1447 && SCIPisGT(scip, ecost, necost + termdist2[k] - g-> prize[tk]) 1448 && SCIPisGT(scip, ecost, necost + termdist1[j] + termdist2[k] - g-> prize[tj] - g-> prize[tk]) ) 1450 SCIPdebugMessage( "SDSP delete: %d %d (%d)\n", g-> tail[e], g-> head[e], e); 1463 SCIPfreeBufferArray(scip, &neighbterms2); 1464 SCIPfreeBufferArray(scip, &neighbterms1); 1465 SCIPfreeBufferArray(scip, &termdist2); 1466 SCIPfreeBufferArray(scip, &termdist1); 1478 SCIP_Real* mstsdist, 1479 SCIP_Real* termdist1, 1480 SCIP_Real* termdist2, 1506 assert(scip != NULL); 1508 assert(netgraph != NULL); 1509 assert(mst != NULL); 1510 assert(mstsdist != NULL); 1511 assert(termdist1 != NULL); 1512 assert(termdist2 != NULL); 1513 assert(neighbterms1 != NULL); 1514 assert(neighbterms2 != NULL); 1522 if( g-> head[e] == i2 ) 1534 neighbterms1[0] = i; 1538 nnterms1 = getcloseterms(scip, vnoi, termdist1, sd, vbase, neighbterms1, i, nnodes); 1549 neighbterms2[0] = i2; 1554 nnterms2 = getcloseterms(scip, vnoi, termdist2, sd, vbase, neighbterms2, i2, nnodes); 1560 for( j = 0; j < nnterms1; j++ ) 1562 tj = neighbterms1[j]; 1564 for( k = 0; k < nnterms2; k++ ) 1566 tk = neighbterms2[k]; 1571 if( SCIPisGT(scip, termdist1[j], termdist2[k]) ) 1578 if( SCIPisLT(scip, max, sd) ) 1596 assert(netgraph-> head[ne] == l); 1597 l = netgraph-> tail[ne]; 1598 if( SCIPisGT(scip, netgraph-> cost[ne], dist) ) 1599 dist = netgraph-> cost[ne]; 1618 l = netgraph-> tail[ne]; 1619 if( SCIPisGT(scip, netgraph-> cost[ne], dist) ) 1620 dist = netgraph-> cost[ne]; 1622 if( mstsdist[l] >= 0 ) 1624 if( SCIPisGT(scip, mstsdist[l], dist) ) 1638 l = netgraph-> tail[ne]; 1644 assert(SCIPisGT(scip, dist, 0.0)); 1645 if( SCIPisGT(scip, dist, max) ) 1647 if( SCIPisLT(scip, max, sd) ) 1664 SCIP_Real distlimit, 1688 assert(scip != NULL); 1689 assert(pathtail != NULL); 1690 assert(pathhead != NULL); 1691 assert(heap != NULL); 1692 assert(statetail != NULL); 1693 assert(statehead != NULL); 1694 assert(memlbltail != NULL); 1695 assert(memlblhead != NULL); 1696 assert(sdist != NULL); 1702 sdpaths(scip, g, pathtail, g-> cost, distlimit, heap, statetail, memlbltail, &nlbltail, i, i2, limit); 1705 sdpaths(scip, g, pathhead, g-> cost, distlimit, heap, statehead, memlblhead, &nlblhead, i2, i, limit); 1709 if( statetail[i2] != UNKNOWN ) 1711 sd = pathtail[i2]. dist; 1712 assert(SCIPisGT(scip, FARAWAY, sd)); 1714 if( statehead[i] != UNKNOWN && SCIPisGT(scip, sd, pathhead[i].dist) ) 1716 sd = pathhead[i]. dist; 1717 assert(SCIPisGT(scip, FARAWAY, sd)); 1721 for( k = 0; k < nlbltail; k++ ) 1724 assert(statetail[l] != UNKNOWN); 1727 assert(SCIPisGT(scip, FARAWAY, pathtail[l].dist)); 1728 assert(SCIPisGT(scip, FARAWAY, pathhead[l].dist)); 1732 if( SCIPisLT(scip, dist, pathhead[l].dist) ) 1733 dist = pathhead[l]. dist; 1734 if( SCIPisLT(scip, dist, pathtail[l].dist) ) 1735 dist = pathtail[l]. dist; 1736 if( pcmw && SCIPisLT(scip, dist, pathhead[l].dist + pathtail[l].dist - g-> prize[l]) ) 1738 if( SCIPisGT(scip, sd, dist) ) 1743 if( mw && l != i && l != i2 ) 1744 assert(SCIPisLE(scip, g-> prize[l], 0.0)); 1745 if( mw && SCIPisLT(scip, g-> prize[l], 0.0) ) 1748 dist = pathhead[l]. dist + pathtail[l]. dist; 1749 if( SCIPisGT(scip, sd, dist) ) 1759 for( k = 0; k < nlblhead; k++ ) 1768 for( k = 0; k < nnodes; k++ ) 1770 assert(statetail[k] == UNKNOWN); 1771 assert(pathtail[k].dist == FARAWAY); 1772 assert(pathtail[k].edge == UNKNOWN); 1773 assert(statehead[k] == UNKNOWN); 1774 assert(pathhead[k].dist == FARAWAY); 1775 assert(pathhead[k].edge == UNKNOWN); 1783 if( g-> head[e] == i2 ) 1787 else if( SCIPisGT(scip, sd, g-> cost[e]) ) 1802 SCIP_Real* nodecost, 1818 assert(scip != NULL); 1819 assert(nelims != NULL); 1820 assert(adjacent != NULL); 1821 assert(nodecost != NULL); 1828 for( i = 0; i < nnodes; i++ ) 1830 for( i = 0; i < nnodes; i++ ) 1831 adjacent[i] = FALSE; 1833 for( i = 0; i < nnodes; i++ ) 1844 adjacent[i2] = TRUE; 1845 nodecost[i2] = g-> cost[e]; 1848 assert(!adjacent[i]); 1857 if( i2 < i || !g->mark[i2] ) 1872 assert(g-> mark[i3]); 1874 if( ( Is_term(g-> term[i3]) && SCIPisGE(scip, cost, g-> cost[e2]) && SCIPisGE(scip, cost, nodecost[i3])) || 1875 (! Is_term(g-> term[i3]) && SCIPisGE(scip, cost, g-> cost[e2] + nodecost[i3])) ) 1877 if( pc && Is_term(g-> term[i3]) && !SCIPisGE(scip, cost, g-> cost[e2] + nodecost[i3] - g-> prize[i3]) ) 1880 adjacent[i2] = FALSE; 1928 assert(scip != NULL); 1929 assert(pathtail != NULL); 1930 assert(pathhead != NULL); 1931 assert(heap != NULL); 1932 assert(statetail != NULL); 1933 assert(statehead != NULL); 1934 assert(memlbltail != NULL); 1935 assert(memlblhead != NULL); 1936 assert(nelims != NULL); 1942 for( i = 0; i < nnodes; i++ ) 1953 SCIP_CALL( SCIPallocBufferArray(scip, &costrev, nedges) ); 1955 for( e = 0; e < nedges; e++ ) 1959 for( i = 0; i < nnodes; i++ ) 1971 assert(g-> mark[i2]); 1974 sdpaths(scip, g, pathtail, g-> cost, g-> cost[e], heap, statetail, memlbltail, &nlbltail, i, i2, limit); 1977 sdpaths(scip, g, pathhead, costrev, g-> cost[e], heap, statehead, memlblhead, &nlblhead, i2, i, limit); 1981 if( statetail[i2] != UNKNOWN ) 1983 sdist = pathtail[i2]. dist; 1984 assert(SCIPisGT(scip, FARAWAY, sdist)); 1986 if( statehead[i] != UNKNOWN && SCIPisGT(scip, sdist, pathhead[i].dist) ) 1988 sdist = pathhead[i]. dist; 1989 assert(SCIPisGT(scip, FARAWAY, sdist)); 1993 for( k = 0; k < nlbltail; k++ ) 1997 assert(statetail[l] != UNKNOWN); 2000 assert(SCIPisGT(scip, FARAWAY, pathtail[l].dist)); 2001 assert(SCIPisGT(scip, FARAWAY, pathhead[l].dist)); 2003 if( SCIPisGT(scip, sdist, pathhead[l].dist + pathtail[l].dist) ) 2004 sdist = pathhead[l]. dist + pathtail[l]. dist; 2012 for( k = 0; k < nlblhead; k++ ) 2021 for( k = 0; k < nnodes; k++ ) 2023 assert(statetail[k] == UNKNOWN); 2024 assert(pathtail[k].dist == FARAWAY); 2025 assert(pathtail[k].edge == UNKNOWN); 2026 assert(statehead[k] == UNKNOWN); 2027 assert(pathhead[k].dist == FARAWAY); 2028 assert(pathhead[k].edge == UNKNOWN); 2032 if( SCIPisGE(scip, g-> cost[e], sdist) ) 2035 if( SCIPisGE(scip, costrev[e], FARAWAY) ) 2036 printf( "ELIM edge \n"); 2038 printf( "counteredge \n"); 2040 if( SCIPisGE(scip, costrev[e], FARAWAY) ) 2051 SCIPfreeBufferArray(scip, &costrev); 2086 assert(scip != NULL); 2087 assert(pathtail != NULL); 2088 assert(pathhead != NULL); 2089 assert(heap != NULL); 2090 assert(statetail != NULL); 2091 assert(statehead != NULL); 2092 assert(memlbltail != NULL); 2093 assert(memlblhead != NULL); 2094 assert(nelims != NULL); 2101 for( i = 0; i < nnodes; i++ ) 2104 for( i = 0; i < nnodes; i++ ) 2115 for( i = 0; i < nnodes; i++ ) 2128 if( i2 < i || !g->mark[i2] ) 2135 sdpaths(scip, g, pathtail, g-> cost, g-> cost[e], heap, statetail, memlbltail, &nlbltail, i, i2, limit); 2138 sdpaths(scip, g, pathhead, g-> cost, g-> cost[e], heap, statehead, memlblhead, &nlblhead, i2, i, limit); 2142 if( statetail[i2] != UNKNOWN ) 2144 sdist = pathtail[i2]. dist; 2145 assert(SCIPisGT(scip, FARAWAY, sdist)); 2147 if( statehead[i] != UNKNOWN && SCIPisGT(scip, sdist, pathhead[i].dist) ) 2149 sdist = pathhead[i]. dist; 2150 assert(SCIPisGT(scip, FARAWAY, sdist)); 2154 for( k = 0; k < nlbltail; k++ ) 2158 assert(statetail[l] != UNKNOWN); 2161 assert(SCIPisGT(scip, FARAWAY, pathtail[l].dist)); 2162 assert(SCIPisGT(scip, FARAWAY, pathhead[l].dist)); 2166 if( SCIPisLT(scip, dist, pathhead[l].dist) ) 2167 dist = pathhead[l]. dist; 2168 if( SCIPisLT(scip, dist, pathtail[l].dist) ) 2169 dist = pathtail[l]. dist; 2170 if( pc && SCIPisLT(scip, dist, pathhead[l].dist + pathtail[l].dist - g-> prize[l]) ) 2172 if( SCIPisGT(scip, sdist, dist) ) 2177 if( SCIPisGT(scip, sdist, pathhead[l].dist + pathtail[l].dist) ) 2178 sdist = pathhead[l]. dist + pathtail[l]. dist; 2187 for( k = 0; k < nlblhead; k++ ) 2196 for( k = 0; k < nnodes; k++ ) 2198 assert(statetail[k] == UNKNOWN); 2199 assert(pathtail[k].dist == FARAWAY); 2200 assert(pathtail[k].edge == UNKNOWN); 2201 assert(statehead[k] == UNKNOWN); 2202 assert(pathhead[k].dist == FARAWAY); 2203 assert(pathhead[k].edge == UNKNOWN); 2207 if( SCIPisGE(scip, g-> cost[e], sdist) ) 2243 SCIP_Real redstarttime; 2244 SCIP_Real timelimit; 2245 SCIP_Real stalltime; 2253 SCIPdebugMessage( "SD-Reduktion: "); 2256 assert(scip != NULL); 2257 assert(heap != NULL); 2258 assert(state != NULL); 2259 assert(sddist != NULL); 2260 assert(sdtrans != NULL); 2261 assert(cost != NULL); 2262 assert(knotexamined != NULL); 2266 redstarttime = SCIPgetTotalTime(scip); 2267 SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) ); 2268 stalltime = timelimit * 0.1; 2270 for( i = 0; i < nnodes; i++ ) 2275 randarr[e] = SCIPgetRandomReal(0.0, (g-> cost[e]), seed); 2276 cost[e] = g-> cost[e] * 1.0 + randarr[e]; 2283 srand((( unsigned int)runnum * 100)); 2289 } while( nnodes > KNOTLIMIT && knotexamined[knotoffset] >= 0 && i < 50 ); 2290 knotexamined[knotoffset]++; 2294 for( i = 0; i < nnodes; i++ ) 2296 if( i % 100 == 0 && *elimins == 0 && SCIPgetTotalTime(scip) - redstarttime > stalltime) 2299 if( !g-> mark[i] || g-> grad[i] == 0 ) 2318 compute_sd(scip, g, i, cost, randarr, heap, state, &count, sddist, sdtrans, sdrand); 2328 assert(g-> tail[e] == i); 2332 if( SCIPisLT(scip, g-> cost[e], FARAWAY) && SCIPisLT(scip, sddist[g-> head[e]], cost[e]) 2333 && SCIPisLT(scip, sddist[g-> head[e]] - sdrand[g-> head[e]], cost[e] - randarr[e]) ) 2343 SCIPdebugMessage( "%d Edges deleted\n", *elimins * 2); 2356 SCIP_RETCODE sd_reduction_dir( 2361 double** sd_outdist, 2362 double** sd_outtran, 2371 int outtermcount = 0; 2381 assert(sd_indist != NULL); 2382 assert(sd_intran != NULL); 2383 assert(sd_outdist != NULL); 2384 assert(sd_outtran != NULL); 2385 assert(cost != NULL); 2386 assert(heap != NULL); 2387 assert(state != NULL); 2388 assert(elimins != NULL); 2391 SCIPdebugMessage( "SD-Reduktion: "); 2394 assert(outterms != NULL); 2396 sourceadj = malloc(( size_t)g-> knots * sizeof( int)); 2398 for(i = 0; i < g-> knots; i++) 2400 assert(sd_indist[i] != NULL); 2401 assert(sd_intran[i] != NULL); 2402 assert(sd_outdist[i] != NULL); 2403 assert(sd_outtran[i] != NULL); 2411 outterms[outtermcount] = i; 2429 for(i = 0; i < g-> edges; i++) 2430 cost[i] = g-> cost[i] * 1000.0 + ( double)(rand() % 512); 2432 for( i = 0; i < outtermcount; i++ ) 2434 compute_sd_dir(g, outterms[i], cost, heap, state, &count, sd_indist[i], sd_intran[i], TRUE); 2435 compute_sd_dir(g, outterms[i], cost, heap, state, &count, sd_outdist[i], sd_outtran[i], FALSE); 2438 for(i = 0; i < g-> knots; i++) 2442 SCIPdebug(fputc( '.', stdout)); 2443 SCIPdebug(fflush(stdout)); 2446 if (g-> grad[i] == 0) 2460 assert(g-> tail[e] == i); 2473 for( k = 0; k < outtermcount; k++ ) 2475 assert(l >= 0 && l < g->knots); 2477 if( outterms[k] == g-> source[0] ) 2482 tempsd = sd_outdist[k][i]; 2483 else if( ! LT(sd_outdist[k][i], FARAWAY) ) 2484 tempsd = sd_indist[k][i]; 2485 else if( GT(sd_indist[k][i], sd_outdist[k][i]) ) 2486 tempsd = sd_indist[k][i]; 2488 tempsd = sd_outdist[k][i]; 2491 if( GT(sd_outdist[k][l], tempsd) ) 2492 tempsd = sd_outdist[k][l]; 2499 tempsd = sd_indist[k][i]; 2501 if( GT(sd_outdist[k][l], tempsd) ) 2502 tempsd = sd_outdist[k][l]; 2506 if( LT(tempsd, specialdist) ) 2507 specialdist = tempsd; 2510 if ( LT(cost[e], FARAWAY) && LT(specialdist, cost[e])) 2528 SCIPdebugMessage( "%d Edges deleted\n", *elimins * 2); 2544 SCIP_Real* mstsdist, 2545 SCIP_Real* termdist1, 2546 SCIP_Real* termdist2, 2576 assert(netgraph != NULL); 2577 assert(netmst != NULL); 2580 SCIP_CALL( SCIPallocBufferArray(scip, &mst, 5) ); 2581 SCIP_CALL( graph_init(scip, &auxg, 5, 40, 1, 0) ); 2583 for( k = 0; k < 4; k++ ) 2585 for( k = 0; k < 4; k++ ) 2586 for( k2 = k + 1; k2 < 4; k2++ ) 2593 SCIP_CALL( SCIPallocBufferArray(scip, &sd, 4) ); 2594 SCIP_CALL( SCIPallocBufferArray(scip, &ancestors, 4) ); 2595 SCIP_CALL( SCIPallocBufferArray(scip, &revancestors, 4) ); 2596 SCIP_CALL( SCIPallocBufferArray(scip, &ecost, 4) ); 2597 SCIP_CALL( SCIPallocBufferArray(scip, &adjvert, 4) ); 2598 SCIP_CALL( SCIPallocBufferArray(scip, &reinsert, 4) ); 2599 SCIP_CALL( SCIPallocBufferArray(scip, &incedge, 4) ); 2601 SCIPdebugMessage( "BD3-R Reduction: "); 2606 for( i = 0; i < 4; i++ ) 2609 ancestors[i] = NULL; 2610 revancestors[i] = NULL; 2613 for( i = 0; i < nnodes; i++ ) 2616 for( i = 0; i < nnodes; i++ ) 2625 ecost[k] = g-> cost[e]; 2626 adjvert[k++] = g-> head[e]; 2631 if( g-> grad[i] == 3 ) 2635 csum = ecost[0] + ecost[1] + ecost[2]; 2637 sd[0] = getRSD(scip, g, netgraph, netmst, vnoi, mstsdist, termdist1, termdist2, vbase, nodesid, neighbterms1, neighbterms2, adjvert[0], adjvert[1], 300); 2638 sd[1] = getRSD(scip, g, netgraph, netmst, vnoi, mstsdist, termdist1, termdist2, vbase, nodesid, neighbterms1, neighbterms2, adjvert[1], adjvert[2], 300); 2639 sd[2] = getRSD(scip, g, netgraph, netmst, vnoi, mstsdist, termdist1, termdist2, vbase, nodesid, neighbterms1, neighbterms2, adjvert[2], adjvert[0], 300); 2641 if( SCIPisLE(scip, sd[0] + sd[1], csum) || SCIPisLE(scip, sd[0] + sd[2], csum) || SCIPisLE(scip, sd[1] + sd[2], csum) ) 2643 SCIPdebugMessage( "BD3-R Reduction: %f %f %f csum: %f\n ", sd[0], sd[1], sd[2], csum); 2646 for( k = 0; k < 3; k++ ) 2654 for( k = 0; k < 3; k++ ) 2658 if( SCIPisLT(scip, sd[k], ecost[k] + ecost[k2]) ) 2663 SCIP_CALL( graph_edge_reinsert(scip, g, incedge[k], adjvert[k], adjvert[k2], ecost[k] + ecost[k2], ancestors[k], ancestors[k2], revancestors[k], revancestors[k2]) ); 2666 assert(g-> grad[i] == 0); 2670 else if( g-> grad[i] == 4 ) 2674 for( k = 0; k < 4; k++ ) 2682 auxg-> cost[e] = getRSD(scip, g, netgraph, netmst, vnoi, mstsdist, termdist1, termdist2, vbase, nodesid, neighbterms1, neighbterms2, adjvert[k], adjvert[k2], 200); 2688 for( l = 0; l < 4; l++ ) 2693 for( l = 1; l < 4; l++ ) 2694 assert(mst[l].dist != UNKNOWN); 2695 for( l = 1; l < 4; l++ ) 2696 mstcost += mst[l].dist; 2699 csum = ecost[0] + ecost[1] + ecost[2] + ecost[3]; 2701 if( SCIPisGE(scip, csum, mstcost) ) 2704 for( k = 0; k < 4; k++ ) 2712 for( l = 1; l < 4; l++ ) 2714 mstcost += mst[l]. dist; 2719 for( l = 2; l < 4; l++ ) 2720 mstcost += mst[l].dist; 2726 if( SCIPisLT(scip, csum, mstcost) ) 2736 for( k = 0; k < 4; k++ ) 2743 if( SCIPisGE(scip, auxg-> cost[e], ecost[k] + ecost[k2]) ) 2755 (*nelims) += g-> grad[i] - l; 2758 for( k = 0; k < 4; k++ ) 2766 for( k = 0; k < l; k++ ) 2769 tail = auxg-> tail[e]; 2770 head = auxg-> head[e]; 2771 SCIP_CALL( graph_edge_reinsert(scip, g, incedge[k], adjvert[tail], adjvert[head], ecost[tail] + ecost[head], ancestors[tail], ancestors[head], revancestors[tail], revancestors[head]) ); 2775 while( g-> outbeg[i] >= 0 ) 2778 assert(g-> grad[i] == 0); 2784 for( k = 0; k < 4; k++ ) 2791 SCIPfreeBufferArray(scip, &incedge); 2792 SCIPfreeBufferArray(scip, &reinsert); 2793 SCIPfreeBufferArray(scip, &adjvert); 2794 SCIPfreeBufferArray(scip, &ecost); 2795 SCIPfreeBufferArray(scip, &revancestors); 2796 SCIPfreeBufferArray(scip, &ancestors); 2797 SCIPfreeBufferArray(scip, &sd); 2801 SCIPfreeBufferArray(scip, &mst); 2854 SCIPdebugMessage( "BD3-Reduction: "); 2857 assert(heap != NULL); 2858 assert(nelims != NULL); 2861 SCIP_CALL( SCIPallocBufferArray(scip, &mst, 5) ); 2862 SCIP_CALL( graph_init(scip, &auxg, 5, 40, 1, 0) ); 2864 for( k = 0; k < 4; k++ ) 2866 for( k = 0; k < 4; k++ ) 2867 for( k2 = k + 1; k2 < 4; k2++ ) 2874 SCIP_CALL( SCIPallocBufferArray(scip, &sd, 4) ); 2875 SCIP_CALL( SCIPallocBufferArray(scip, &ancestors, 4) ); 2876 SCIP_CALL( SCIPallocBufferArray(scip, &revancestors, 4) ); 2877 SCIP_CALL( SCIPallocBufferArray(scip, &ecost, 4) ); 2878 SCIP_CALL( SCIPallocBufferArray(scip, &adjvert, 4) ); 2879 SCIP_CALL( SCIPallocBufferArray(scip, &reinsert, 4) ); 2880 SCIP_CALL( SCIPallocBufferArray(scip, &incedge, 4) ); 2886 for( i = 0; i < 4; i++ ) 2889 ancestors[i] = NULL; 2890 revancestors[i] = NULL; 2893 for( i = 0; i < nnodes; i++ ) 2895 for( i = 0; i < nnodes; i++ ) 2905 for( i = 0; i < nnodes; i++ ) 2914 ecost[k] = g-> cost[e]; 2915 adjvert[k++] = g-> head[e]; 2920 if( g-> grad[i] == 3 ) 2924 csum = ecost[0] + ecost[1] + ecost[2]; 2926 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &(sd[0]), csum, heap, statetail, statehead, memlbltail, memlblhead, adjvert[0], adjvert[1], limit, pc, FALSE) ); 2927 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &(sd[1]), csum, heap, statetail, statehead, memlbltail, memlblhead, adjvert[1], adjvert[2], limit, pc, FALSE) ); 2928 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &(sd[2]), csum, heap, statetail, statehead, memlbltail, memlblhead, adjvert[2], adjvert[0], limit, pc, FALSE) ); 2930 if( SCIPisLE(scip, sd[0] + sd[1], csum) || SCIPisLE(scip, sd[0] + sd[2], csum) || SCIPisLE(scip, sd[1] + sd[2], csum) ) 2935 for( k = 0; k < 3; k++ ) 2943 for( k = 0; k < 3; k++ ) 2947 if( SCIPisLT(scip, sd[k], ecost[k] + ecost[k2]) ) 2952 SCIP_CALL( graph_edge_reinsert(scip, g, incedge[k], adjvert[k], adjvert[k2], ecost[k] + ecost[k2], ancestors[k], ancestors[k2], revancestors[k], revancestors[k2]) ); 2955 if( SCIPisLE(scip, s1, ecost[0] + ecost[1]) ) 2958 SCIP_CALL( graph_edge_reinsert(scip, g, incedge[0], adjvert[0], adjvert[1], ecost[0] + ecost[1], ancestors[0], ancestors[1], revancestors[0], revancestors[1]) ); 2960 if( SCIPisLE(scip, s2, ecost[1] + ecost[2]) ) 2963 SCIP_CALL( graph_edge_reinsert(scip, g, incedge[1], adjvert[1], adjvert[2], ecost[1] + ecost[2], ancestors[1], ancestors[2], revancestors[1], revancestors[2]) ); 2965 if( SCIPisLE(scip, s3, ecost[0] + ecost[2]) ) 2968 SCIP_CALL( graph_edge_reinsert(scip, g, incedge[2], adjvert[2], adjvert[0], ecost[2] + ecost[0], ancestors[2], ancestors[0], revancestors[2], revancestors[0]) ); 2985 assert(g-> grad[i] == 0); 2990 else if( g-> grad[i] == 4 ) 2993 csum = ecost[0] + ecost[1] + ecost[2] + ecost[3]; 2995 for( k = 0; k < 4; k++ ) 3003 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &(s1), csum, heap, statetail, statehead, memlbltail, memlblhead, adjvert[k], adjvert[k2], limit, pc, FALSE) ); 3010 for( l = 0; l < 4; l++ ) 3015 for( l = 1; l < 4; l++ ) 3016 assert(mst[l].dist != UNKNOWN); 3017 for( l = 1; l < 4; l++ ) 3018 mstcost += mst[l].dist; 3021 if( SCIPisGE(scip, csum, mstcost) ) 3024 for( k = 0; k < 4; k++ ) 3032 for( l = 1; l < 4; l++ ) 3034 mstcost += mst[l]. dist; 3039 for( l = 2; l < 4; l++ ) 3040 mstcost += mst[l].dist; 3046 if( SCIPisLT(scip, csum, mstcost) ) 3056 for( k = 0; k < 4; k++ ) 3063 if( SCIPisGE(scip, auxg-> cost[e], ecost[k] + ecost[k2]) ) 3076 SCIPdebugMessage( "npv4Reduction delete: %d\n", i); 3077 (*nelims) += g-> grad[i] - l; 3080 for( k = 0; k < 4; k++ ) 3088 for( k = 0; k < l; k++ ) 3091 tail = auxg-> tail[e]; 3092 head = auxg-> head[e]; 3093 SCIP_CALL( graph_edge_reinsert(scip, g, incedge[k], adjvert[tail], adjvert[head], ecost[tail] + ecost[head], ancestors[tail], ancestors[head], revancestors[tail], revancestors[head]) ); 3097 while( g-> outbeg[i] >= 0 ) 3100 assert(g-> grad[i] == 0); 3106 for( k = 0; k < 4; k++ ) 3113 SCIPfreeBufferArray(scip, &incedge); 3114 SCIPfreeBufferArray(scip, &reinsert); 3115 SCIPfreeBufferArray(scip, &adjvert); 3116 SCIPfreeBufferArray(scip, &ecost); 3117 SCIPfreeBufferArray(scip, &revancestors); 3118 SCIPfreeBufferArray(scip, &ancestors); 3119 SCIPfreeBufferArray(scip, &sd); 3123 SCIPfreeBufferArray(scip, &mst); 3125 SCIPdebugMessage( "bd3: %d Knots deleted\n", *nelims); 3131 inline static double mst_cost( 3139 for(i = 0; i < g-> knots; i++) 3140 if ((e = mst[i].edge) >= 0) 3154 SCIP_RETCODE nsv_reduction( 3162 SCIP_Real redstarttime; 3163 SCIP_Real timelimit; 3164 SCIP_Real stalltime; 3177 SCIPdebugMessage( "NSV-Reduction: "); 3184 path = malloc(( size_t)g-> knots * sizeof( PATH*)); 3186 assert(path != NULL); 3188 mst1 = malloc(( size_t)g-> knots * sizeof( PATH)); 3189 mst2 = malloc(( size_t)g-> knots * sizeof( PATH)); 3191 assert(mst1 != NULL); 3192 assert(mst2 != NULL); 3193 assert(cost != NULL); 3195 redstarttime = SCIPgetTotalTime(scip); 3196 SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) ); 3197 stalltime = timelimit*0.1; 3201 for(i = 0; i < g-> edges; i++) 3202 cost[i] = g-> cost[i]; 3204 for(i = 0; i < g->knots; i++) 3212 for(i = 0; i < g-> knots; i++) 3214 if( i % 100 == 0 && SCIPgetTotalTime(scip) > timelimit ) 3217 if( i % 100 == 0 && (*nelims) == 0 && SCIPgetTotalTime(scip) - redstarttime > stalltime) 3222 SCIPdebug(fputc( '.', stdout)); 3223 SCIPdebug(fflush(stdout)); 3230 cost1 = mst_cost(g, mst1); 3234 assert(g-> tail[e] == i); 3246 cost2 = mst_cost(g, mst2); 3248 cost[e] = g-> cost[e]; 3251 assert( GE(cost2, cost1)); 3253 if ( LE(cost2 - cost1, 2.0)) 3265 for(j = 0; j < g-> knots; j++) 3270 assert(path[j] != NULL); 3272 if ( LT(path[j][i].dist, min1) && LT(path[j][i].dist, path[j][k].dist)) 3273 min1 = path[j][i]. dist; 3275 if ( LT(path[j][k].dist, min2) && LT(path[j][k].dist, path[j][i].dist)) 3276 min2 = path[j][k]. dist; 3286 if ( LT(cost1 + min1 + min2, cost2)) 3292 *fixed += g-> cost[e]; 3300 for(j = 0; j < g-> edges; j++) 3301 cost[j] = g-> cost[j]; 3304 for(i = 0; i < g-> knots; i++) 3306 if (path[i] != NULL) 3319 SCIPdebugMessage( " %d Knots deleted\n", *nelims); 3356 SCIP_RETCODE nv_reduction_optimal( 3365 PATH* pathfromsource; 3386 char antiedgeexists; 3389 SCIPdebugMessage( "NSV-Reduction: "); 3394 path = malloc(( size_t)g-> knots * sizeof( PATH*)); 3396 assert(path != NULL); 3398 pathfromterm = malloc(( size_t)g-> knots * sizeof( PATH)); 3399 pathfromsource = malloc(( size_t)g-> knots * sizeof( PATH)); 3401 assert(pathfromterm != NULL); 3402 assert(pathfromsource != NULL); 3404 pathhops = malloc(( size_t)g-> knots * sizeof( PATH)); 3406 assert(pathhops != NULL); 3408 distance = malloc(( size_t)g-> knots * sizeof( double)); 3409 radius = malloc(( size_t)g-> knots * sizeof( double)); 3411 assert(distance != NULL); 3412 assert(radius != NULL); 3414 hopscost = malloc(( size_t)g-> edges * sizeof( double)); 3416 assert(hopscost != NULL); 3418 vregion = malloc(( size_t)g-> knots * sizeof( int)); 3420 assert(vregion != NULL); 3422 heap = malloc(( size_t)g-> knots * sizeof( int)); 3423 state = malloc(( size_t)g-> knots * sizeof( int)); 3425 assert(heap != NULL); 3426 assert(state != NULL); 3429 pred = malloc(( size_t)g-> edges * sizeof( int)); 3430 minArc1 = malloc(( size_t)g-> knots * sizeof( int)); 3431 minArc2 = malloc(( size_t)g-> knots * sizeof( int)); 3432 terms = malloc(( size_t)g-> terms * sizeof( int)); 3435 for(i = 0; i < g-> knots; i++) 3439 terms[termcount] = i; 3461 assert(g-> source[0] >= 0); 3464 voronoi_term(g, g-> cost, distance, radius, pathfromterm, vregion, heap, state, pred, 1); 3476 for(i = 0; i < g-> knots; i++) 3497 antiedgeexists = FALSE; 3511 if (g-> cost[e] < min1) 3514 shortarctail = g-> tail[e]; 3520 if( LT(pathfromsource[g-> tail[e]].hops, minhops) ) 3521 minhops = pathfromsource[g-> tail[e]].hops; 3524 antiedgeexists = TRUE; 3531 if ( LT(min1, FARAWAY) && LE(pathfromsource[shortarctail].dist + min1, min2)) 3533 assert(shortarc >= 0); 3534 assert(shortarctail >= 0); 3543 if( antiedgeexists == TRUE ) 3589 if( vregion[i] != vregion[j] ) 3591 if( minArc1[vregion[i]] < 0 ) 3592 minArc1[vregion[i]] = e; 3593 else if( g-> cost[e] < g-> cost[minArc1[vregion[i]]] ) 3595 minArc2[vregion[i]] = minArc1[vregion[i]]; 3596 minArc1[vregion[i]] = e; 3605 for( k = 0; k < termcount; k++ ) 3607 assert(terms[k] >= 0 && terms[k] < g-> knots); 3609 if( minArc1[terms[k]] >= 0 && minArc2[terms[k]] >= 0 && pathfromsource[g-> tail[minArc1[terms[k]]]]. dist 3610 + g-> cost[minArc1[terms[k]]] + pathfromterm[g-> head[minArc1[terms[k]]]]. dist < g-> cost[minArc2[terms[k]]] ) 3612 e = minArc1[terms[k]]; 3623 *fixed += g-> cost[e]; 3644 free(pathfromsource); 3649 SCIPdebugMessage( " %d Knots deleted\n", *elimins); 3697 assert(vnoi != NULL); 3698 assert(heap != NULL); 3699 assert(state != NULL); 3700 assert(vbase != NULL); 3701 assert(vrnodes != NULL); 3702 assert(visited != NULL); 3709 SCIP_CALL( SCIPallocBufferArray(scip, &forbidden, nnodes) ); 3712 for( i = 0; i < nnodes; i++ ) 3717 SCIP_CALL( SCIPqueueCreate(&queue, nnodes, 2.0) ); 3718 for( j = 0; j < nnodes; j++ ) 3720 forbidden[j] = FALSE; 3723 for( i = 0; i < nnodes; i++ ) 3729 assert(SCIPqueueIsEmpty(queue)); 3731 SCIP_CALL( SCIPqueueInsert(queue, &t) ); 3742 while( !SCIPqueueIsEmpty(queue) ) 3744 qnode = (SCIPqueueRemove(queue)); 3755 if( !visited[j] && k == i ) 3758 vrnodes[vrcount++] = j; 3759 SCIP_CALL( SCIPqueueInsert(queue, &(g-> head[e])) ); 3769 else if( SCIPisLE(scip, cost, g-> cost[minedge]) ) 3771 mincost3 = mincost2; 3772 mincost2 = g-> cost[minedge]; 3778 else if( SCIPisLE(scip, cost, mincost2) ) 3783 mincost3 = mincost2; 3784 mincost2 = g-> cost[e]; 3786 else if( SCIPisLT(scip, cost, mincost3) ) 3788 mincost3 = g-> cost[e]; 3793 for( j = 0; j < vrcount; j++ ) 3794 visited[vrnodes[j]] = FALSE; 3800 assert(vbase[tail] == i); 3804 if( SCIPisGE(scip, mincost2, cost) ) 3812 t = g-> head[minedge2]; 3814 if( e2 != flipedge(minedge2) && SCIPisLT(scip, g-> cost[e2], cost) && vbase[g-> head[e2]] != i ) 3830 if( root != vbase[head] && !SCIPisLE(scip, g-> cost[e] + vnoi[tail]. dist + vnoi[head]. dist, g-> prize[vbase[head]]) ) 3834 if( root != i && !SCIPisLE(scip, vnoi[tail].dist + g-> cost[e], g-> prize[i]) ) 3839 if( root != i && !SCIPisLT(scip, vnoi[tail].dist + g-> cost[e], g-> prize[i]) ) 3848 *fixed += g-> cost[e]; 3849 assert(g-> mark[tail] && g-> mark[head]); 3875 assert(old - g-> grad[j] - g-> grad[k] > 0); 3876 (*nelims) += old - g-> grad[j] - g-> grad[k]; 3877 forbidden[vbase[j]] = TRUE; 3878 forbidden[vbase[k]] = TRUE; 3884 SCIPqueueFree(&queue); 3885 SCIPfreeBufferArray(scip, &forbidden); 3904 SCIP_Real* distance; 3926 assert(vnoi != NULL); 3927 assert(heap != NULL); 3928 assert(state != NULL); 3929 assert(vbase != NULL); 3940 SCIP_CALL( SCIPallocBufferArray(scip, &term, nterms) ); 3941 SCIP_CALL( SCIPallocBufferArray(scip, &minedge1, nterms) ); 3942 SCIP_CALL( SCIPallocBufferArray(scip, &distance, nnodes) ); 3952 SCIP_CALL( SCIPallocBufferArray(scip, &distnode, nnodes) ); 3958 for( i = 0; i < nnodes; i++ ) 3962 for( i = 0; i < nnodes; i++ ) 3968 if( g-> grad[i] >= 1 ) 3976 if( SCIPisLE(scip, g-> cost[e], min1) ) 3983 minedge1[termcount] = edge1; 3984 term[termcount++] = i; 3989 SCIP_CALL( voronoi_dist(scip, g, g-> cost, distance, edgearrint, vbase, minedge1, heap, state, distnode, vnoi) ); 3991 for( l = 0; l < termcount; l++ ) 3996 if( g-> grad[i] < mingrad ) 3999 assert(minedge1[l] != UNKNOWN); 4008 if( SCIPisLE(scip, g-> cost[e], min1) ) 4014 else if( SCIPisLE(scip, g-> cost[e], min2) ) 4021 assert(i == g-> tail[edge1]); 4032 ttdist = g-> cost[edge1] + vnoi[k]. dist; 4036 if( distnode != NULL ) 4038 ttdist = distance[i]; 4053 if( SCIPisGE(scip, min2, ttdist) 4054 && (!pc || (SCIPisLE(scip, g-> cost[edge1], pi) && SCIPisLE(scip, ttdist, pt))) ) 4057 *fixed += g-> cost[edge1]; 4068 assert(old - g-> grad[i] - g-> grad[k] > 0); 4069 (*nelims) += old - g-> grad[i] - g-> grad[k]; 4073 SCIPfreeBufferArrayNull(scip, &distnode); 4074 SCIPfreeBufferArray(scip, &distance); 4075 SCIPfreeBufferArray(scip, &minedge1); 4076 SCIPfreeBufferArray(scip, &term); 4087 SCIP_Real* distance, 4121 assert(neighb != NULL); 4122 assert(vnoi != NULL); 4123 assert(heap != NULL); 4124 assert(state != NULL); 4125 assert(vbase != NULL); 4137 SCIP_CALL( SCIPallocBufferArray(scip, &term, nterms) ); 4138 SCIP_CALL( SCIPallocBufferArray(scip, &minedge1, nterms) ); 4148 assert(distnode != NULL); 4153 for( i = 0; i < nnodes; i++ ) 4158 for( i = 0; i < nnodes; i++ ) 4165 if( g-> grad[i] >= 1 ) 4171 if( g-> mark[g-> head[e]] && SCIPisLE(scip, g-> cost[e], min1) ) 4179 minedge1[termcount] = edge1; 4180 term[termcount++] = i; 4185 SCIP_CALL( voronoi_dist(scip, g, g-> cost, distance, edgearrint, vbase, minedge1, heap, state, distnode, vnoi) ); 4189 printf( "rootmarked?: %d \n", g-> mark[g-> source[0]]); 4190 printf( "vbase 187?: %d \n", vbase[187]); 4198 SCIP_CALL( SCIPqueueCreate(&queue, nnodes + 1, 2.0) ); 4199 for( k = 0; k < nnodes; k++ ) 4202 SCIP_CALL( SCIPqueueInsert(queue, &(g-> tail[g-> outbeg[v]])) ); 4204 while( !SCIPqueueIsEmpty(queue) ) 4206 pnode = (SCIPqueueRemove(queue)); 4213 if( !g-> mark[h] && h != 0 ) 4215 printf( "goto: %d->%d \n", *pnode, h); 4219 printf( "hit: %d \n", h); 4225 SCIP_CALL( SCIPqueueInsert(queue, &(g-> head[a])) ); 4234 for( l = 0; l < termcount; l++ ) 4239 if( g-> grad[i] < mingrad ) 4242 assert(minedge1[l] != UNKNOWN); 4258 if( SCIPisLE(scip, g-> cost[e], min1) ) 4267 else if( SCIPisLE(scip, g-> cost[e], min2) ) 4274 else if( SCIPisLE(scip, g-> cost[e], min3) ) 4281 assert(i == g-> tail[edge1]); 4285 printf( "root: %d \n", g-> source[0]); 4286 printf( "edge: %d->%d\n", g-> tail[edge1], g-> head[edge1]); 4287 printf( "i: %d distance: %f \n", i, distance[0]); 4298 ttdist = g-> cost[edge1] + vnoi[k]. dist; 4304 assert(distnode != NULL); 4307 ttdist = distance[i]; 4318 else if( t != g-> source[0] ) 4326 if( SCIPisGE(scip, min2, ttdist) ) 4334 if( e != flipedge(edge2) && SCIPisLT(scip, g-> cost[e], ttdist) ) 4347 if( contract && (!pc || (SCIPisLE(scip, g-> cost[edge1], pi) && SCIPisLE(scip, ttdist, pt))) ) 4350 *fixed += g-> cost[edge1]; 4364 SCIPfreeBufferArray(scip, &minedge1); 4365 SCIPfreeBufferArray(scip, &term); 4401 assert(vnoi != NULL); 4402 assert(heap != NULL); 4403 assert(state != NULL); 4404 assert(vbase != NULL); 4412 for( k = 0; k < nnodes; k++ ) 4422 SCIP_CALL( SCIPallocBufferArray(scip, &blocked, nedges / 2) ); 4423 SCIP_CALL( SCIPallocBufferArray(scip, &edgeorg, nedges / 2) ); 4427 if( nedges >= (nterms - 1) * nterms ) 4428 maxnedges = (nterms - 1) * nterms; 4432 SCIP_CALL( SCIPallocBufferArray(scip, &nodesid, nnodes) ); 4435 SCIP_CALL( graph_init(scip, &netgraph, nterms, maxnedges, 1, 0) ); 4438 for( k = 0; k < nnodes; k++ ) 4454 netnnodes = netgraph-> knots; 4455 assert(netnnodes == e); 4456 assert(netnnodes == nterms); 4458 for( e = 0; e < nedges / 2; e++ ) 4464 for( k = 0; k < nnodes; k++ ) 4469 assert(k == g-> tail[e]); 4471 if( v1 != vbase[g-> head[e]] ) 4473 v2 = vbase[g-> head[e]]; 4476 assert(nodesid[v1] >= 0); 4477 assert(nodesid[v2] >= 0); 4480 if( netgraph-> head[ne] == nodesid[v2] ) 4488 assert(netgraph-> head[ne] == nodesid[v2]); 4489 assert(netgraph-> tail[ne] == nodesid[v1]); 4490 if( SCIPisGT(scip, netgraph-> cost[ne], cost) ) 4492 netgraph-> cost[ne] = cost; 4494 edgeorg[ne / 2] = e; 4495 assert(ne <= maxnedges); 4500 edgeorg[netgraph-> edges / 2] = e; 4501 graph_edge_add(scip, netgraph, nodesid[v1], nodesid[v2], cost, cost); 4502 assert(netgraph-> edges <= maxnedges); 4511 for( k = 0; k < netnnodes; k++ ) 4515 SCIP_CALL( SCIPallocBufferArray(scip, &mst, netnnodes) ); 4520 assert(mst[0].edge == -1); 4522 for( k = 1; k < netnnodes; k++ ) 4527 cost = netgraph-> cost[e]; 4528 if( SCIPisGT(scip, cost, maxcost) ) 4531 ne = edgeorg[e / 2]; 4532 blocked[ne / 2] = TRUE; 4533 for( v1 = g-> head[ne]; v1 != vbase[v1]; v1 = g-> tail[vnoi[v1]. edge] ) 4536 for( v1 = g-> tail[ne]; v1 != vbase[v1]; v1 = g-> tail[vnoi[v1].edge] ) 4537 blocked[vnoi[v1].edge / 2] = TRUE; 4541 for( k = 0; k < nnodes; k++ ) 4547 if( SCIPisGE(scip, g-> cost[e], maxcost) && !blocked[e / 2] ) 4568 SCIPfreeBufferArray(scip, &mst); 4569 SCIPfreeBufferArray(scip, &nodesid); 4570 SCIPfreeBufferArray(scip, &edgeorg); 4571 SCIPfreeBufferArray(scip, &blocked); 4595 assert(scip != NULL); 4597 assert(fixed != NULL); 4598 assert(count != NULL); 4599 assert(marked != NULL); 4606 for( k = 0; k < nnodes; k++ ) 4610 for( k = 0; k < nnodes; k++ ) 4620 if( SCIPisLT(scip, g-> prize[k], 0.0) ) 4625 maxgrad = g-> grad[k]; 4632 if( !g-> mark[k] || k == k2 ) 4640 if( g-> grad[j] <= maxgrad && g-> mark[j] && SCIPisLE(scip, g-> prize[j], min) ) 4643 if( !marked[g-> head[e2]] ) 4665 for( j = 0; j < nnodes; j++ ) 4666 assert(marked[j] == FALSE); 4699 assert(scip != NULL); 4701 assert(count != NULL); 4702 assert(marked != NULL); 4710 SCIP_CALL( SCIPallocBufferArray(scip, &neighbarr, CNSNN + 1) ); 4711 SCIP_CALL( SCIPallocBufferArray(scip, &neighbarr2, CNSNN + 1) ); 4714 for( k = 0; k < nnodes; k++ ) 4718 for( run = 0; run < 2; run++ ) 4721 for( k = 0; k < nnodes; k++ ) 4723 if( (!(g-> mark[k])) || (g-> grad[k] < 2) ) 4731 kprize = g-> prize[k]; 4732 maxgrad = g-> grad[k]; 4742 if( SCIPisGE(scip, g-> prize[j], 0.0) && nn < CNSNN - 1 ) 4744 neighbarr[nn++] = j; 4747 else if( (run == 1) && 4748 ((SCIPisGT(scip, g-> prize[j], kprize) && nn2 < CNSNN) || (SCIPisGE(scip, g-> prize[j], kprize) && j > k && nn2 < 3)) ) 4750 neighbarr2[nn2++] = j; 4760 for( l = 0; l < nn; l++ ) 4767 if( run == 1 && SCIPisGT(scip, g-> prize[j], kprize) && nn2 < CNSNN ) 4769 neighbarr2[nn2++] = j; 4772 else if( marked[j] == 0 ) 4777 maxgrad += g-> grad[neighbarr[l]]; 4788 for( l = 0; l < nn2 + 1 - run; l++ ) 4795 marked[g-> head[e]] = 1; 4796 min += g-> prize[k2]; 4797 k2grad = g-> grad[k2]; 4799 assert(SCIPisLE(scip, g-> prize[k2], 0.0)); 4804 for( j = 0; j < nnodes; j++ ) 4811 if( g-> grad[j] <= maxgrad && SCIPisLE(scip, g-> prize[j], min) ) 4814 if( marked[g-> head[e2]] == 0 ) 4836 marked[g-> head[e]] = 0; 4837 min -= g-> prize[k2]; 4843 marked[g-> head[e]] = 0; 4847 for( l = 0; l < nn; l++ ) 4849 marked[g-> head[e]] = 0; 4854 for( l = 0; l < nnodes; l++ ) 4855 assert(marked[l] == 0); 4860 SCIPfreeBufferArray(scip, &neighbarr2); 4861 SCIPfreeBufferArray(scip, &neighbarr); 4887 assert(scip != NULL); 4889 assert(fixed != NULL); 4890 assert(count != NULL); 4891 assert(marked != NULL); 4897 SCIP_CALL( SCIPallocBufferArray(scip, &neighbarr, CNSNN) ); 4900 for( k = 0; k < nnodes; k++ ) 4904 for( k = 0; k < nnodes; k++ ) 4917 if( SCIPisGT(scip, g-> prize[j], 0.0) && nn < CNSNN ) 4918 neighbarr[nn++] = j; 4923 maxgrad = g-> grad[k]; 4924 for( l = 0; l < nn; l++ ) 4928 maxgrad += g-> grad[neighbarr[l]]; 4931 assert(SCIPisLE(scip, g-> prize[k], 0.0)); 4940 for( j = 0; j < nnodes; j++ ) 4951 if( g-> grad[j] <= maxgrad && g-> mark[j] && SCIPisLE(scip, g-> prize[j], min) ) 4954 if( !marked[g-> head[e2]] ) 4975 for( l = 0; l < nn; l++ ) 4981 for( k2 = 0; k2 < nnodes; k2++ ) 4982 assert(marked[k2] == FALSE); 4985 SCIPfreeBufferArray(scip, &neighbarr); 5013 assert(scip != NULL); 5015 assert(fixed != NULL); 5016 assert(count != NULL); 5017 assert(marked != NULL); 5023 SCIP_CALL( SCIPallocBufferArray(scip, &neighbarr, CNSNN + 1) ); 5026 for( k = 0; k < nnodes; k++ ) 5029 for( run = 0; run < 2; run++ ) 5032 for( k = 0; k < nnodes; k++ ) 5039 maxgrad = g-> grad[k]; 5040 maxprize = g-> prize[k]; 5047 if( SCIPisGT(scip, g-> prize[j], 0.0) && nn < CNSNN - 1 ) 5049 neighbarr[nn++] = j; 5051 else if( SCIPisGT(scip, g-> prize[j], maxprize) && g-> mark[j] ) 5053 maxprize = g-> prize[j]; 5060 if( run == 0 && k2 != UNKNOWN ) 5061 neighbarr[nn++] = k2; 5063 for( l = 0; l < nn; l++ ) 5070 maxprize = g-> prize[j]; 5075 maxgrad += g-> grad[neighbarr[l]]; 5078 if( run == 1 && k2 != UNKNOWN ) 5080 maxgrad += g-> grad[k2]; 5081 neighbarr[nn++] = k2; 5087 assert(SCIPisLE(scip, g-> prize[k], 0.0)); 5091 min += g-> prize[k2]; 5105 if( g-> grad[j] <= maxgrad && g-> mark[j] && SCIPisLE(scip, g-> prize[j], min) && k2 != j ) 5108 if( !marked[g-> head[e2]] ) 5129 for( l = 0; l < nn; l++ ) 5135 for( k2 = 0; k2 < nnodes; k2++ ) 5136 assert(marked[k2] == FALSE); 5140 SCIPfreeBufferArray(scip, &neighbarr); 5176 assert(scip != NULL); 5177 assert(pathtail != NULL); 5178 assert(pathhead != NULL); 5179 assert(heap != NULL); 5180 assert(statetail != NULL); 5181 assert(statehead != NULL); 5182 assert(memlbltail != NULL); 5183 assert(memlblhead != NULL); 5184 assert(nelims != NULL); 5186 SCIP_CALL( SCIPallocBufferArray(scip, &adjverts, 5) ); 5192 for( i = 0; i < nnodes; i++ ) 5206 for( i = 0; i < nnodes; i++ ) 5208 assert(g-> grad[i] >= 0); 5215 adjverts[k++] = g-> head[e]; 5220 prize = g-> prize[i]; 5221 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &sdist0, -prize, heap, statetail, statehead, memlbltail, memlblhead, adjverts[0], adjverts[1], limit, FALSE, TRUE) ); 5222 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &sdist1, -prize, heap, statetail, statehead, memlbltail, memlblhead, adjverts[1], adjverts[2], limit, FALSE, TRUE) ); 5223 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &sdist2, -prize, heap, statetail, statehead, memlbltail, memlblhead, adjverts[2], adjverts[0], limit, FALSE, TRUE) ); 5226 if( (SCIPisGE(scip, -sdist0 - sdist1, prize) && SCIPisGE(scip, -sdist2, prize)) 5227 || (SCIPisGE(scip, -sdist1 - sdist2, prize) && SCIPisGE(scip, -sdist0, prize)) 5228 || (SCIPisGE(scip, -sdist2 - sdist0, prize) && SCIPisGE(scip, -sdist1, prize)) 5231 SCIPdebugMessage( "npv3Reduction delete: %d (prize: %f) \n", i, g-> prize[i]); 5232 (*nelims) += g-> grad[i]; 5246 SCIP_CALL( SCIPallocBufferArray(scip, &mst, 5) ); 5247 SCIP_CALL( graph_init(scip, &auxg, 5, 40, 1, 0) ); 5249 for( k = 0; k < 4; k++ ) 5251 for( k = 0; k < 4; k++ ) 5252 for( k2 = k + 1; k2 < 4; k2++ ) 5258 for( i = 0; i < nnodes; i++ ) 5267 adjverts[k++] = g-> head[e]; 5272 prize = g-> prize[i]; 5275 for( k = 0; k < 4; k++ ) 5283 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &(sdist0), -prize, heap, statetail, statehead, memlbltail, memlblhead, adjverts[k], adjverts[k2], limit, FALSE, TRUE) ); 5284 auxg-> cost[e] = sdist0; 5285 if( SCIPisGT(scip, prize, -auxg-> cost[e]) ) 5303 for( l = 1; l < 4; l++ ) 5304 sdist0 += mst[l].dist; 5306 if( SCIPisLE(scip, prize, -sdist0) ) 5309 for( k = 0; k < 4; k++ ) 5316 for( l = 1; l < 4; l++ ) 5318 sdist0 += mst[l]. dist; 5323 for( l = 2; l < 4; l++ ) 5324 sdist0 += mst[l].dist; 5327 if( SCIPisGT(scip, prize, -sdist0) ) 5336 SCIPdebugMessage( "npv4Reduction delete: %d (prize: %f) \n", i, g-> prize[i]); 5337 (*nelims) += g-> grad[i]; 5351 for( k = 0; k < 4; k++ ) 5357 for( i = 0; i < nnodes; i++ ) 5366 adjverts[k++] = g-> head[e]; 5371 prize = g-> prize[i]; 5373 for( k = 0; k < 5; k++ ) 5381 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &(sdist0), -prize, heap, statetail, statehead, memlbltail, memlblhead, adjverts[k], adjverts[k2], limit, FALSE, TRUE) ); 5382 auxg-> cost[e] = sdist0; 5383 if( SCIPisGT(scip, prize, -auxg-> cost[e]) ) 5398 for( l = 1; l < 5; l++ ) 5399 sdist0 += mst[l].dist; 5401 if( SCIPisLE(scip, prize, -sdist0) ) 5403 for( k = 0; k < 5; k++ ) 5410 for( l = 1; l < 5; l++ ) 5412 sdist0 += mst[l]. dist; 5417 for( l = 2; l < 5; l++ ) 5418 sdist0 += mst[l].dist; 5421 if( SCIPisLE(scip, prize, -sdist0) ) 5423 for( k2 = k + 1; k2 < 5; k2++ ) 5429 if( k2 != 0 && k != 0) 5432 for( l = 1; l < 5; l++ ) 5434 sdist0 += mst[l]. dist; 5438 if( k != 1 && k2 != 1 ) 5443 for( l = 0; l < 5; l++ ) 5444 if( auxg-> mark[l] && l != s ) 5445 sdist0 += mst[l]. dist; 5448 if( SCIPisGT(scip, prize, -sdist0) ) 5461 SCIPdebugMessage( " \n npv5Reduction delete: %d (prize: %f) \n", i, g-> prize[i]); 5462 (*nelims) += g-> grad[i]; 5476 SCIPfreeBufferArray(scip, &mst); 5477 SCIPfreeBufferArray(scip, &adjverts); 5507 assert(scip != NULL); 5508 assert(pathtail != NULL); 5509 assert(pathhead != NULL); 5510 assert(heap != NULL); 5511 assert(statetail != NULL); 5512 assert(statehead != NULL); 5513 assert(memlbltail != NULL); 5514 assert(memlblhead != NULL); 5515 assert(nelims != NULL); 5521 for( i = 0; i < nnodes; i++ ) 5531 for( i = 0; i < nnodes; i++ ) 5533 assert(g-> grad[i] >= 0); 5545 assert(g-> mark[i1]); 5546 assert(g-> mark[i2]); 5548 SCIP_CALL( getSD(scip, g, pathtail, pathhead, &sdist, -(g-> prize[i]), heap, statetail, statehead, memlbltail, memlblhead, i1, i2, limit, FALSE, TRUE) ); 5549 if( SCIPisGE(scip, -sdist, g-> prize[i]) ) 5551 SCIPdebugMessage( "delete : %d prize: %f sd: %f \n", i, g-> prize[i], -sdist ); 5591 assert(scip != NULL); 5593 assert(fixed != NULL); 5594 assert(count != NULL); 5595 assert(mem != NULL); 5596 assert(positive != NULL); 5597 assert(visited != NULL); 5598 assert(marked != NULL); 5605 for( i = 0; i < nnodes; i++ ) 5607 if( g-> mark[i] && SCIPisGE(scip, g-> prize[i], 0.0) ) 5610 positive[i] = FALSE; 5615 SCIP_CALL( SCIPqueueCreate(&queue, nnodes, 2.0) ); 5617 for( i = 0; i < nnodes; i++ ) 5634 assert(SCIPqueueIsEmpty(queue)); 5636 SCIP_CALL( SCIPqueueInsert(queue, &g-> head[g-> inpbeg[i]]) ); 5638 mem[nvisited1++] = i; 5641 while( !SCIPqueueIsEmpty(queue) ) 5643 pnode = SCIPqueueRemove(queue); 5649 if( iterations++ >= maxniter || k == j ) 5653 SCIPqueueClear(queue); 5657 if( positive[k] && !marked[k] ) 5660 assert(nvisited1 < nnodes); 5661 mem[nvisited1++] = k; 5662 SCIP_CALL( SCIPqueueInsert(queue, &g-> head[e2]) ); 5671 assert(SCIPqueueIsEmpty(queue)); 5672 SCIP_CALL( SCIPqueueInsert(queue, &j) ); 5674 assert(nvisited2 + nvisited1 < nnodes); 5675 mem[nvisited1 + nvisited2++] = j; 5679 while( !SCIPqueueIsEmpty(queue) ) 5681 pnode = (SCIPqueueRemove(queue)); 5688 if( iterations++ >= maxniter || marked[k] ) 5692 SCIPqueueClear(queue); 5696 if( positive[k] && !visited[k] ) 5699 assert(nvisited2 + nvisited1 < nnodes); 5700 mem[nvisited1 + nvisited2++] = k; 5701 SCIP_CALL( SCIPqueueInsert(queue, &g-> head[e2]) ); 5712 for( j = 0; j < nvisited1; j++ ) 5713 marked[mem[j]] = FALSE; 5715 for( j = nvisited1; j < nvisited1 + nvisited2; j++ ) 5716 visited[mem[j]] = FALSE; 5718 for( j = 0; j < nnodes; j++ ) 5720 assert(marked[j] == FALSE); 5721 assert(visited[j] == FALSE); 5727 SCIPqueueFree(&queue); SCIP_RETCODE graph_path_init(SCIP *, GRAPH *)
SCIP_RETCODE sd_reduction(SCIP *scip, GRAPH *g, SCIP_Real *sddist, SCIP_Real *sdtrans, SCIP_Real *sdrand, SCIP_Real *cost, SCIP_Real *randarr, int *heap, int *state, int *knotexamined, int *elimins, int runnum, unsigned int *seed)
static int getcloseterms(SCIP *scip, PATH *vnoi, SCIP_Real *termdist, SCIP_Real ecost, int *vbase, int *neighbterms, int i, int nnodes)
int graph_valid(const GRAPH *)
static int getlecloseterms(SCIP *scip, PATH *vnoi, SCIP_Real *termdist, SCIP_Real ecost, int *vbase, int *neighbterms, int i, int nnodes)
static void compute_sd(SCIP *scip, const GRAPH *p, int start, const double *cost, const double *randarr, int *heap, int *state, int *count, double *pathdist, double *pathtran, double *pathrand)
SCIP_RETCODE sdsp_reduction(SCIP *scip, GRAPH *g, PATH *pathtail, PATH *pathhead, int *heap, int *statetail, int *statehead, int *memlbltail, int *memlblhead, int *nelims, int limit)
SCIP_RETCODE bd3_reduction(SCIP *scip, GRAPH *g, PATH *pathtail, PATH *pathhead, int *heap, int *statetail, int *statehead, int *memlbltail, int *memlblhead, int *nelims, int limit)
void getnext4tterms(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 *)
void sdpaths(SCIP *, const GRAPH *, PATH *, SCIP_Real *, SCIP_Real, int *, int *, int *, int *, int, int, int)
SCIP_RETCODE ansadvReduction(SCIP *scip, GRAPH *g, SCIP_Real *fixed, int *marked, int *count)
SCIP_RETCODE nv_reductionAdv(SCIP *scip, GRAPH *g, PATH *vnoi, SCIP_Real *distance, double *fixed, int *edgearrint, int *heap, int *state, int *vbase, int *neighb, int *distnode, int *nelims)
Problem data for stp problem.
SCIP_RETCODE graph_knot_contract(SCIP *, GRAPH *, int, int)
static SCIP_Bool sddeltable(SCIP *scip, GRAPH *g, PATH *path, int *vbase, int *forbidden, int tpos, int hpos, int tail, int head, int edge, int nnodes)
void graph_path_exit(SCIP *, GRAPH *)
SCIP_RETCODE sdsp_sap_reduction(SCIP *scip, GRAPH *g, PATH *pathtail, PATH *pathhead, int *heap, int *statetail, int *statehead, int *memlbltail, int *memlblhead, int *nelims, int limit)
static void correct(SCIP *scip, int *heap, int *state, int *count, double *pathdist, double *pathtran, int l)
static SCIP_Bool maxprize(SCIP *scip, GRAPH *g, int i)
SCIP_RETCODE sd_red(SCIP *scip, GRAPH *g, PATH *vnoi, SCIP_Real *edgepreds, SCIP_Real *mstsdist, int *heap, int *state, int *vbase, int *nodesid, int *nodesorg, int *forbidden, int *nelims)
void graph_free(SCIP *, GRAPH *, SCIP_Bool)
int graph_edge_redirect(SCIP *, GRAPH *, int, int, int, SCIP_Real)
void graph_knot_chg(GRAPH *, int, int)
SCIP_RETCODE ledge_reduction(SCIP *scip, GRAPH *g, PATH *vnoi, int *heap, int *state, int *vbase, int *nelims)
SCIP_RETCODE nnpReduction(SCIP *scip, GRAPH *g, SCIP_Real *fixed, int *mem, int *marked, int *visited, int *count, int maxniter, char *positive)
static int nearest(SCIP *scip, int *heap, int *state, int *count, const double *pathdist, const double *pathtran)
void SCIPintListNodeFree(SCIP *scip, IDX **node)
void graph_path_execX(SCIP *, const GRAPH *, int, SCIP_Real *, SCIP_Real *, int *)
SCIP_RETCODE ansReduction(SCIP *scip, GRAPH *g, SCIP_Real *fixed, int *marked, int *count)
SCIP_RETCODE npvReduction(SCIP *scip, GRAPH *g, PATH *pathtail, PATH *pathhead, int *heap, int *statetail, int *statehead, int *memlbltail, int *memlblhead, int *nelims, int limit)
#define STP_MAX_NODE_WEIGHT
SCIP_RETCODE SCIPprobdataPrintGraph2(const GRAPH *graph, const char *filename, SCIP_Bool *edgemark)
void voronoi_terms(SCIP *, const GRAPH *, SCIP_Real *, PATH *, int *, int *, int *)
SCIP_RETCODE nv_reduction(SCIP *scip, GRAPH *g, PATH *vnoi, double *fixed, int *edgearrint, int *heap, int *state, int *vbase, int *nelims)
void getnext4terms(SCIP *, const GRAPH *, SCIP_Real *, SCIP_Real *, PATH *, int *, int *, int *)
static int islarger(SCIP *scip, const double *pathdist, const double *pathtran, int a, int b)
SCIP_RETCODE bdr_reduction(SCIP *scip, GRAPH *g, GRAPH *netgraph, PATH *netmst, PATH *vnoi, SCIP_Real *mstsdist, SCIP_Real *termdist1, SCIP_Real *termdist2, int *vbase, int *nodesid, int *neighbterms1, int *neighbterms2, int *nelims)
void voronoi_term(const GRAPH *, double *, double *, double *, PATH *, int *, int *, int *, int *, int)
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)
void level0(SCIP *, GRAPH *)
SCIP_RETCODE sd2_reduction(SCIP *scip, GRAPH *g, SCIP_Real *nodecost, int *nelims, int *adjacent)
SCIP_RETCODE getSD(SCIP *scip, GRAPH *g, PATH *pathtail, PATH *pathhead, SCIP_Real *sdist, SCIP_Real distlimit, int *heap, int *statetail, int *statehead, int *memlbltail, int *memlblhead, int i, int i2, int limit, SCIP_Bool pc, SCIP_Bool mw)
includes various files containing graph methods used for Steiner problems
SCIP_RETCODE sl_reduction(SCIP *scip, GRAPH *g, PATH *vnoi, double *fixed, int *heap, int *state, int *vbase, int *vrnodes, char *visited, int *nelims)
SCIP_RETCODE ansadv2Reduction(SCIP *scip, GRAPH *g, SCIP_Real *fixed, int *marked, int *count)
static int issmaller(SCIP *scip, const double *pathdist, const double *pathtran, int a, int b)
#define STP_ROOTED_PRIZE_COLLECTING
SCIP_RETCODE cnsAdvReduction(SCIP *scip, GRAPH *g, int *marked, int *count)
SCIP_RETCODE graph_knot_contractpc(SCIP *, GRAPH *, int, int, int)
void graph_knot_add(GRAPH *, int)
static SCIP_Real getRSD(SCIP *scip, GRAPH *g, GRAPH *netgraph, PATH *mst, PATH *vnoi, SCIP_Real *mstsdist, SCIP_Real *termdist1, SCIP_Real *termdist2, int *vbase, int *nodesid, int *neighbterms1, int *neighbterms2, int i, int i2, int limit)
void graph_edge_add(SCIP *, GRAPH *, int, int, double, double)
void graph_path_exec(SCIP *, const GRAPH *, int, int, SCIP_Real *, PATH *)
SCIP_RETCODE sdpc_reduction(SCIP *scip, GRAPH *g, PATH *vnoi, SCIP_Real *boundedges, int *heap, int *state, int *vbase, int *nodesid, int *nodesorg, int *nelims)
SCIP_RETCODE voronoi_dist(SCIP *, const GRAPH *, SCIP_Real *, double *, int *, int *, int *, int *, int *, int *, PATH *)
SCIP_RETCODE chain2Reduction(SCIP *scip, GRAPH *g, PATH *pathtail, PATH *pathhead, int *heap, int *statetail, int *statehead, int *memlbltail, int *memlblhead, int *nelims, int limit)
|