37 #include "scip/misc.h" 39 #define HEUR_NAME "TM" 40 #define HEUR_DESC "takahashi matsuyama primal heuristic for steiner trees" 41 #define HEUR_DISPCHAR '+' 42 #define HEUR_PRIORITY 10000000 44 #define HEUR_FREQOFS 0 45 #define HEUR_MAXDEPTH -1 46 #define HEUR_TIMING (SCIP_HEURTIMING_BEFORENODE | SCIP_HEURTIMING_DURINGLPLOOP | SCIP_HEURTIMING_AFTERLPLOOP | SCIP_HEURTIMING_AFTERNODE) 47 #define HEUR_USESSUBSCIP FALSE 49 #define DEFAULT_EVALRUNS 15 50 #define DEFAULT_INITRUNS 100 51 #define DEFAULT_LEAFRUNS 15 52 #define DEFAULT_ROOTRUNS 50 53 #define DEFAULT_DURINGLPFREQ 10 54 #define DEFAULT_TYPE 0 55 #define DEFAULT_RANDSEED 0 100 SCIP_HEURDATA* heurdata;
103 newrandseed = SCIPparamGetInt(param);
105 heurdata = (SCIP_HEURDATA*)SCIPparamGetData(param);
106 assert(heurdata != NULL);
108 heurdata->randseed = (
unsigned int)newrandseed;
117 SCIP_RETCODE printGraph(
120 const char* filename,
124 char label[SCIP_MAXSTRLEN];
130 SCIP_CALL( SCIPallocBufferArray(scip, &stnodes, graph->
knots ) );
132 assert(graph != NULL);
133 file = fopen((filename != NULL) ? filename :
"graphX.gml",
"w");
135 for( e = 0; e < graph->
knots; e++ )
139 for( e = 0; e < graph->
edges; e++ )
149 SCIPgmlWriteOpening(file,
FALSE);
154 for( n = 0; n < graph->
knots; ++n )
158 if( n == graph->
source[0] )
160 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN,
"(%d) Root", n);
161 SCIPgmlWriteNode(file, (
unsigned int)n, label,
"rectangle",
"#666666", NULL);
164 else if( graph->
term[n] == 0 )
166 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN,
"(%d) Terminal %d", n, e + 1);
167 SCIPgmlWriteNode(file, (
unsigned int)n, label,
"circle",
"#ff0000", NULL);
172 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN,
"(%d) Node %d", n, n + 1 - e - m);
173 SCIPgmlWriteNode(file, (
unsigned int)n, label,
"circle",
"#336699", NULL);
179 for( e = 0; e < graph->
edges; e ++ )
183 (void)SCIPsnprintf(label, SCIP_MAXSTRLEN,
"%8.2f", graph->
cost[e]);
185 SCIPgmlWriteEdge(file, (
unsigned int)graph->
tail[e], (
unsigned int)graph->
head[e], label,
"#ff0000");
188 SCIPfreeBufferArray(scip, &stnodes);
190 SCIPgmlWriteClosing(file);
218 for( i = 0; i < nnodes; i++ )
249 assert(connected[i]);
260 assert(root < nnodes);
262 SCIP_CALL( SCIPallocBufferArray(scip, &mst, nnodes) );
265 for( i = 0; i < nnodes; i++ )
267 if( g->
mark[i] && (mst[i].
edge != -1) )
271 assert(result[mst[i].edge] == -1);
277 for( i = 0; i < nnodes; i++ )
305 else if( k1 == g->
source[0] )
309 else if( k2 == g->
source[0] )
326 char varname[SCIP_MAXSTRLEN];
327 (void)SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"A%d.gml", 0);
328 SCIP_CALL( printGraph(scip, g, varname, result) );
334 SCIPdebug(fputc(
'C', stdout));
335 SCIPdebug(fflush(stdout));
339 for( i = 0; i < nnodes; i++ )
363 connected[i] =
FALSE;
374 SCIPfreeBufferArray(scip, &mst);
396 SCIP_CALL( SCIPallocBufferArray(scip, &mst, nnodes) );
401 for( i = 0; i < nnodes; i++ )
405 g->
mark[i] = connected[i];
411 for( i = 0 ; i < g->
edges; i++ )
413 SCIPfreeBufferArray(scip, &mst);
418 assert(g->
source[layer] >= 0);
419 assert(g->
source[layer] < nnodes);
420 assert(j >= g->
terms);
423 for( i = 0; i < nnodes; i++ )
425 if( connected[i] && (mst[i].edge != -1) )
428 assert(result[mst[i].edge] == -1);
429 result[mst[i].
edge] = layer;
436 SCIPdebug(fputc(
'C', stdout));
437 SCIPdebug(fflush(stdout));
441 for( i = 0; i < nnodes; i++ )
446 if( g->
term[i] == layer )
450 if( result[j] == layer )
459 if( result[j] == layer )
463 connected[i] =
FALSE;
472 printf(
"prune isolated: %d\n", i);
474 char varname[SCIP_MAXSTRLEN];
475 (void)SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"AAAA%d.gml", 0);
476 SCIP_CALL( printGraph(scip, g, varname, result) );
491 SCIPfreeBufferArray(scip, &mst);
511 for( e = 0; e < nedges; e++ )
512 if( SCIPisLT(scip, cost[e],
BLOCKED) )
513 cost[e] = g->
cost[e];
520 for( e = 0; e < nedges; e++ )
541 assert(scip != NULL);
543 assert(result != NULL);
544 assert(connected != NULL);
549 SCIP_CALL( SCIPqueueCreate(&queue, nnodes, 2.0) );
551 SCIP_CALL( SCIPqueueInsert(queue, &(g->
source[0])) );
553 for( i = 0; i < nnodes; i++ )
554 connected[i] =
FALSE;
557 while( !SCIPqueueIsEmpty(queue) )
559 pnode = (SCIPqueueRemove(queue));
568 SCIP_CALL( SCIPqueueInsert(queue, &(g->
head[e])) );
573 SCIPqueueFree(&queue);
578 SCIPdebug(fputc(
'C', stdout));
579 SCIPdebug(fflush(stdout));
583 for( i = 0; i < nnodes; i++ )
604 connected[i] =
FALSE;
637 for( k = 0; k < nnodes; k++ )
639 graph_path_st(scip, g, cost, dijkdist, dijkedge, start, randseed, connected);
641 SCIP_CALL(
prune(scip, g, cost, costrev, result, connected) );
653 SCIP_Real** pathdist,
676 assert(scip != NULL);
678 assert(result != NULL);
679 assert(connected != NULL);
680 assert(cost != NULL);
681 assert(costrev != NULL);
682 assert(pathdist != NULL);
683 assert(pathedge != NULL);
684 assert(cluster != NULL);
685 assert(perm != NULL);
690 assert(0 <= start && start < nnodes);
692 SCIPdebugMessage(
"Heuristic: Start=%5d ", start);
694 cluster[csize++] = start;
697 for( i = 0; i < nnodes; i++ )
700 connected[i] =
FALSE;
704 connected[start] =
TRUE;
705 SCIPpermuteIntArray(perm, 0, nnodes - 1, randseed);
719 if( SCIPisStopped(scip) )
723 for( l = 0; l < nnodes; l++ )
730 z = SCIPgetRandomInt(0, nnodes - 1, randseed);
732 for( k = 0; k < csize; k++ )
734 j = cluster[(k + z) % csize];
736 assert(connected[j]);
738 if( SCIPisLT(scip, pathdist[i][j], min) )
740 min = pathdist[i][j];
754 assert(pathdist[newval] != NULL);
755 assert(pathdist[newval][old] <
FARAWAY);
756 assert(g->
term[newval] == 0);
757 assert(!connected[newval]);
758 assert(connected[old]);
760 SCIPdebug(fputc(
'R', stdout));
761 SCIPdebug(fflush(stdout));
769 e = pathedge[newval][k];
775 cluster[csize++] = k;
781 SCIP_CALL(
prune(scip, g, cost, costrev, result, connected) );
794 SCIP_Real** pathdist,
827 assert(scip != NULL);
829 assert(g->
maxdeg != NULL);
830 assert(result != NULL);
831 assert(connected != NULL);
832 assert(cost != NULL);
833 assert(costrev != NULL);
834 assert(pathdist != NULL);
835 assert(pathedge != NULL);
836 assert(cluster != NULL);
837 assert(perm != NULL);
845 SCIPdebugMessage(
"Heuristic: Start=%5d ", start);
847 SCIP_CALL( SCIPallocBufferArray(scip, °s, nnodes) );
849 cluster[csize++] = start;
851 for( i = 0; i < nnodes; i++ )
855 connected[i] =
FALSE;
859 for( e = 0; e < g->
edges; e++ )
861 assert(SCIPisGT(scip, cost[e], 0.0));
864 connected[start] =
TRUE;
865 tldegcount = MIN(g->
grad[start], maxdegs[start]);
866 SCIPpermuteIntArray(perm, 0, nnodes - 1, randseed);
873 for( n = 0; n < nnodes; n++ )
878 if( tldegcount <= 1 && termcount < nterms - 1)
884 for( t = 0; t < nnodes; t++ )
890 z = SCIPgetRandomInt(0, nnodes - 1, randseed);
892 for( k = 0; k < csize; k++ )
894 j = cluster[(k + z) % csize];
896 assert(connected[j]);
898 if( SCIPisLE(scip, pathdist[i][j], min) && degs[j] < maxdegs[j])
904 u = g->
tail[pathedge[i][u]];
907 if( (MIN(g->
grad[u], maxdegs[u]) < 2 ||
Is_term(g->
term[u])) && u != i )
912 degcount += MIN(g->
grad[u] - 2, maxdegs[u] - 2);
917 l = g->
tail[pathedge[i][u]];
918 if( !connected[l] && degs[u] >= maxdegs[u] )
925 if( degcount >= degmax || (degcount >= mindegsum && SCIPisLT(scip, pathdist[i][j], min)) )
928 min = pathdist[i][j];
939 for( k = 0; k < csize; k++ )
941 j = cluster[(k + z) % csize];
942 if( degs[j] < maxdegs[j] )
954 if( !
Is_term(g->
term[u]) && !connected[u] && SCIPisGE(scip, min, cost[e]) )
966 connected[newval] =
TRUE;
967 cluster[csize++] = newval;
968 tldegcount += MIN(maxdegs[newval], g->
grad[newval]) - 2;
974 tldegcount += degmax - 1;
982 assert(pathdist[newval] != NULL);
983 assert(g->
term[newval] == 0);
984 assert(!connected[newval]);
985 assert(connected[old]);
987 SCIPdebug(fputc(
'R', stdout));
988 SCIPdebug(fflush(stdout));
998 e = pathedge[newval][k];
1008 connected[k] =
TRUE;
1009 cluster[csize++] = k;
1014 if( termcount == nterms )
1016 assert(degs[newval] == 1);
1021 for( i = 0; i < nnodes; i++ )
1035 for( t = 0; t < nnodes; t++ )
1036 if( degs[t] > maxdegs[t] )
1040 SCIPfreeBufferArray(scip, °s);
1049 SCIP_PQUEUE* pqueue,
1053 SCIP_Real** node_dist,
1073 assert(scip != NULL);
1075 assert(result != NULL);
1076 assert(connected != NULL);
1077 assert(cost != NULL);
1078 assert(costrev != NULL);
1082 SCIPdebugMessage(
"TM_Polzin Heuristic: Start=%5d ", start);
1105 for( i = 0; i < nnodes; i++ )
1109 SCIP_CALL( SCIPallocBufferArray(scip, &terms, nterms) );
1110 SCIP_CALL( SCIPallocBufferArray(scip, &termsmark, nnodes) );
1111 SCIP_CALL( SCIPallocBufferArray(scip, &vnoi, nnodes) );
1112 SCIP_CALL( SCIPallocBufferArray(scip, &visited, nnodes) );
1113 SCIP_CALL( SCIPallocBufferArray(scip, &reachednodes, nnodes) );
1114 SCIP_CALL( SCIPallocBufferArray(scip, &vbase, nnodes) );
1115 SCIP_CALL( SCIPallocBufferArray(scip, &tovisit, nnodes) );
1116 SCIP_CALL( SCIPallocBufferArray(scip, &vcost, nnodes) );
1119 for( i = 0; i < nnodes; i++ )
1124 termsmark[i] =
TRUE;
1129 termsmark[i] =
FALSE;
1133 for( e = 0; e < g->
edges; e++)
1135 assert(SCIPisGE(scip, cost[e], 0.0));
1136 assert(SCIPisGE(scip, costrev[e], 0.0));
1139 assert(j == nterms);
1140 voronoi(scip, g, cost, costrev, termsmark, vbase, vnoi);
1143 for( i = 0; i < nnodes; i++ )
1145 assert(vbase[i] == i);
1147 for( k = 0; k < nnodes; k++ )
1149 connected[k] =
FALSE;
1154 node_dist[k][0] = vnoi[k].
dist;
1155 node_edge[k][0] = vnoi[k].
edge;
1156 node_base[k][0] = vbase[k];
1163 termsmark[k] =
FALSE;
1166 vcost[k] = vnoi[k].
dist;
1171 for( i = 0; i < nterms; i++ )
1177 for( k = 0; k < nnodes; k++ )
1178 assert(termsmark[k] ==
FALSE);
1182 visited[term] =
TRUE;
1184 while( ntovisit > 0 )
1187 old = tovisit[--ntovisit];
1194 if( vbase[k] == term )
1199 assert(nnodes - (nneighbnodes + 1) > ntovisit);
1200 tovisit[ntovisit++] = k;
1202 reachednodes[nreachednodes++] = k;
1210 vnoi[k].
dist = vcost[old] + ((vbase[k] == root)? cost[oedge] : costrev[oedge]);
1211 vnoi[k].
edge = oedge;
1213 if( termsmark[vbase[k]] ==
FALSE )
1215 termsmark[vbase[k]] =
TRUE;
1218 assert(nnodes - (nneighbnodes + 1) > ntovisit - 1);
1219 tovisit[nnodes - (++nneighbnodes)] = k;
1224 if( SCIPisGT(scip, vnoi[k].dist, vcost[old] + ((vbase[k] == root)? cost[oedge] : costrev[oedge])) )
1226 vnoi[k].
dist = vcost[old] + ((vbase[k] == root)? cost[oedge] : costrev[oedge]);
1227 vnoi[k].
edge = oedge;
1235 for( j = 0; j < nneighbnodes; j++ )
1237 assert(termsmark[vbase[tovisit[nnodes - j - 1]]]);
1240 SCIP_CALL(
voronoi_extend2(scip, g, ((term == root)? cost : costrev), vnoi, node_dist, node_base, node_edge, termsmark, reachednodes, &nreachednodes, nodenterms,
1241 nneighbterms, term, nneighbnodes) );
1243 reachednodes[nreachednodes++] = term;
1245 for( j = 0; j < nreachednodes; j++ )
1248 state[reachednodes[j]] =
UNKNOWN;
1249 visited[reachednodes[j]] =
FALSE;
1252 for( j = 0; j < nneighbnodes; j++ )
1255 state[tovisit[nnodes - j - 1]] =
UNKNOWN;
1256 visited[tovisit[nnodes - j - 1]] =
FALSE;
1261 for( i = 0; i < nnodes && !SCIPisStopped(scip); i++ )
1262 SCIPsortRealIntInt(node_dist[i], node_base[i], node_edge[i], nodenterms[i]);
1265 SCIPfreeBufferArray(scip, &vcost);
1266 SCIPfreeBufferArray(scip, &tovisit);
1267 SCIPfreeBufferArray(scip, &vbase);
1268 SCIPfreeBufferArray(scip, &reachednodes);
1269 SCIPfreeBufferArray(scip, &visited);
1270 SCIPfreeBufferArray(scip, &vnoi);
1271 SCIPfreeBufferArray(scip, &termsmark);
1272 SCIPfreeBufferArray(scip, &terms);
1278 for( k = 0; k < nnodes; k++ )
1280 connected[k] =
FALSE;
1285 connected[start] =
TRUE;
1286 gnodearr[start]->
dist = node_dist[start][0];
1287 SCIP_CALL( SCIPpqueueInsert(pqueue, gnodearr[start]) );
1289 while( SCIPpqueueNElems(pqueue) > 0 && !SCIPisStopped(scip) )
1291 best = ((
GNODE*) SCIPpqueueRemove(pqueue))->number;
1293 term = node_base[best][vcount[best]];
1296 if( !connected[term] )
1299 k = g->
tail[node_edge[best][vcount[best]]];
1304 while( node_base[k][vcount[k] + j] != term )
1307 assert(vcount[k] + j < nodenterms[k]);
1311 assert(vcount[k] == 0);
1313 connected[k] =
TRUE;
1314 while( vcount[k] < nodenterms[k] && connected[node_base[k][vcount[k]]] )
1320 if( vcount[k] < nodenterms[k] )
1322 gnodearr[k]->
dist = node_dist[k][vcount[k]];
1323 SCIP_CALL( SCIPpqueueInsert(pqueue, gnodearr[k]) );
1327 assert( vcount[k] + j < nodenterms[k] );
1328 assert(node_base[k][vcount[k] + j] == term);
1329 k = g->
tail[node_edge[k][vcount[k] + j]];
1333 assert( k == term );
1334 assert( !connected[k] );
1335 connected[k] =
TRUE;
1337 assert( vcount[k] == 0 );
1338 while( vcount[k] < nodenterms[k] && connected[node_base[k][vcount[k]]] )
1342 if( vcount[k] < nodenterms[k] )
1344 gnodearr[k]->
dist = node_dist[k][vcount[k]];
1345 SCIP_CALL( SCIPpqueueInsert(pqueue, gnodearr[k]) );
1349 while( vcount[best] + 1 < nodenterms[best] )
1351 if( !connected[node_base[best][++vcount[best]]] )
1353 gnodearr[best]->
dist = node_dist[best][vcount[best]];
1354 SCIP_CALL( SCIPpqueueInsert(pqueue, gnodearr[best]) );
1361 SCIP_CALL(
prune(scip, g, cost, costrev, result, connected) );
1374 double maxcost = -1;
1380 assert(graph != NULL);
1381 assert(best_result != NULL);
1389 if( SCIPisLT(scip, maxcost, graph->
cost[e]) )
1391 maxcost = graph->
cost[e];
1397 assert(maxedge >= 0);
1398 maxterm = graph->
head[maxedge];
1401 if( graph->
tail[e] != root )
1410 if( graph->
tail[e] == root )
1413 best_result[maxedge] =
UNKNOWN;
1421 SCIP_HEURDATA* heurdata,
1431 SCIP_Real* nodepriority,
1436 SCIP_PQUEUE* pqueue = NULL;
1440 SCIP_Real* dijkdist = NULL;
1441 SCIP_Real** pathdist = NULL;
1442 SCIP_Real** node_dist = NULL;
1444 GNODE** gnodearr = NULL;
1458 int* cluster = NULL;
1459 int* dijkedge = NULL;
1460 int* nodenterms = NULL;
1461 int** pathedge = NULL;
1462 int** node_base = NULL;
1463 int** node_edge = NULL;
1466 best = bestincstart;
1467 for( e = 0; e < graph->
edges; e++)
1469 assert(SCIPisGE(scip, cost[e], 0.0));
1470 assert(SCIPisGE(scip, costrev[e], 0.0));
1473 assert(scip != NULL);
1474 assert(cost != NULL);
1475 assert(graph != NULL);
1476 assert(costrev != NULL);
1477 assert(heurdata != NULL);
1478 assert(best_result != NULL);
1481 nnodes = graph->
knots;
1482 nedges = graph->
edges;
1483 nterms = graph->
terms;
1484 nexecs = heurdata->nexecs;
1489 if( SCIPisStopped(scip) )
1499 assert(nexecs >= 0);
1500 assert(graph->
layers == 1);
1503 SCIP_CALL( SCIPallocBufferArray(scip, &connected, nnodes) );
1504 SCIP_CALL( SCIPallocBufferArray(scip, &start, MIN(runs, nnodes)) );
1505 SCIP_CALL( SCIPallocBufferArray(scip, &result, nedges) );
1508 mode = heurdata->type;
1534 if( 2 * nterms < nnodes )
1538 else if( mode ==
AUTO )
1548 SCIP_CALL( SCIPallocBufferArray(scip, &dijkdist, nnodes) );
1549 SCIP_CALL( SCIPallocBufferArray(scip, &dijkedge, nnodes) );
1553 SCIP_CALL( SCIPallocBufferArray(scip, &nodenterms, nnodes) );
1554 SCIP_CALL( SCIPallocBufferArray(scip, &gnodearr, nnodes) );
1555 SCIP_CALL( SCIPallocBufferArray(scip, &node_base, nnodes) );
1556 SCIP_CALL( SCIPallocBufferArray(scip, &node_dist, nnodes) );
1557 SCIP_CALL( SCIPallocBufferArray(scip, &node_edge, nnodes) );
1559 for( k = 0; k < nnodes; k++ )
1561 SCIP_CALL( SCIPallocBuffer(scip, &gnodearr[k]) );
1562 SCIP_CALL( SCIPallocBufferArray(scip, &node_base[k], nterms) );
1563 SCIP_CALL( SCIPallocBufferArray(scip, &node_dist[k], nterms) );
1564 SCIP_CALL( SCIPallocBufferArray(scip, &node_edge[k], nterms) );
1567 SCIP_CALL( SCIPallocBufferArray(scip, &vcount, nnodes) );
1568 SCIP_CALL( SCIPpqueueCreate( &pqueue, nnodes, 2.0,
GNODECmpByDist) );
1572 SCIP_CALL( SCIPallocBufferArray(scip, &pathdist, nnodes) );
1573 SCIP_CALL( SCIPallocBufferArray(scip, &pathedge, nnodes) );
1574 BMSclearMemoryArray(pathdist, nnodes);
1575 BMSclearMemoryArray(pathedge, nnodes);
1577 for( k = 0; k < nnodes; k++ )
1579 graph->
mark[k] = (graph->
grad[k] > 0);
1583 SCIP_CALL( SCIPallocBufferArray(scip, &(pathdist[k]), nnodes) );
1584 SCIP_CALL( SCIPallocBufferArray(scip, &(pathedge[k]), nnodes) );
1588 SCIP_CALL( SCIPallocBufferArray(scip, &cluster, nnodes) );
1589 SCIP_CALL( SCIPallocBufferArray(scip, &perm, nnodes) );
1595 if( runs > (nterms - 1) )
1598 else if( starts != NULL )
1600 for( k = 0; k < MIN(runs, nnodes); k++ )
1601 start[k] = starts[k];
1611 int randint = SCIPgetRandomInt(0, 5, &(heurdata->randseed));
1614 else if( randint == 3 )
1623 SCIP_CALL( SCIPallocBufferArray(scip, &perm, nnodes) );
1626 if( nodepriority == NULL )
1628 for( k = 0; k < nnodes; k++ )
1630 SCIPpermuteIntArray(perm, 0, nnodes, &(heurdata->randseed));
1633 for( k = 0; k < nnodes; k++ )
1635 if( r >= runs || r >= nterms )
1639 start[r++] = perm[k];
1643 for( k = 0; k < nnodes && r < runs; k++ )
1647 assert(dijkdist != NULL);
1648 if( SCIPisGE(scip, dijkdist[perm[k]],
BLOCKED) )
1652 start[r++] = perm[k];
1657 SCIP_Real max = 0.0;
1658 int bbound = runs - runs / 3;
1660 for( k = 0; k < nnodes; k++ )
1663 if( SCIPisLT(scip, max, nodepriority[k]) &&
Is_term(graph->
term[k]) )
1664 max = nodepriority[k];
1666 for( k = 0; k < nnodes; k++ )
1670 nodepriority[k] += SCIPgetRandomReal(0.0, max, &(heurdata->randseed));
1672 else if( SCIPisLE(scip, 1.0, nodepriority[k]) )
1674 nodepriority[k] = nodepriority[k] * SCIPgetRandomReal(1.0, 2.0, &(heurdata->randseed));
1678 SCIPsortRealInt(nodepriority, perm, nnodes);
1680 for( k = nnodes - 1; k >= 0; k-- )
1682 if( r >= nterms || r >= bbound )
1687 start[r++] = perm[k];
1693 for( k = nnodes - 1; k >= 0 && r < runs; k-- )
1699 assert(dijkdist != NULL);
1700 if( SCIPisGE(scip, dijkdist[perm[k]],
BLOCKED) )
1703 if( graph->
mark[k] )
1704 start[r++] = perm[k];
1714 for( r = 0; r < runs; r++ )
1715 if( start[r] == best )
1719 if( r == runs && runs > 0 )
1720 start[nexecs % runs] = best;
1726 for( k = 0; k < nnodes; k++ )
1733 SCIP_Real* terminalprio;
1747 SCIP_CALL( SCIPallocBufferArray(scip, &(rootedges_t), nterms - 1) );
1748 SCIP_CALL( SCIPallocBufferArray(scip, &(rootedges_z), nterms - 1) );
1749 SCIP_CALL( SCIPallocBufferArray(scip, &(edges_tz), nterms - 1) );
1750 SCIP_CALL( SCIPallocBufferArray(scip, &terminalperm, nterms - 1) );
1751 SCIP_CALL( SCIPallocBufferArray(scip, &terminalprio, nterms - 1) );
1754 for( k = 0; k < nterms - 1; k++ )
1759 terminalperm[k] = k;
1762 for( k = 0; k < nnodes; k++ )
1767 assert(graph->
grad[k] > 0);
1770 if( graph->
head[e] == root )
1776 if( SCIPisEQ(scip, costrev[e], 0.0) )
1778 assert(costrev[e] == 0);
1793 if( graph->
head[e] == root )
1803 assert(rootedges_t[z] !=
UNKNOWN);
1807 assert(z == nterms - 1);
1808 if( runs > nzterms )
1810 else if( runs < nzterms )
1813 for( t = 0; t < nterms - 1; t++ )
1814 if( rootedges_t[t] !=
UNKNOWN && SCIPisGT(scip, minp, graph->
cost[
flipedge(rootedges_t[t])]) )
1818 if( nodepriority == NULL )
1820 for( t = 0; t < nterms - 1; t++ )
1821 if( rootedges_z[t] ==
UNKNOWN )
1822 terminalprio[t] = 0.0;
1824 terminalprio[t] = SCIPgetRandomReal(minp, graph->
cost[
flipedge(rootedges_t[t])], &(heurdata->randseed));
1828 SCIP_Real max = 0.0;
1829 for( t = 0; t < nterms - 1; t++ )
1830 if( rootedges_z[t] !=
UNKNOWN && SCIPisLT(scip, max, nodepriority[graph->
tail[rootedges_z[t]]]) )
1831 max = nodepriority[graph->
tail[rootedges_z[t]]];
1832 for( t = 0; t < nterms - 1; t++ )
1833 if( rootedges_z[t] ==
UNKNOWN )
1834 terminalprio[t] = 0.0;
1836 terminalprio[t] = nodepriority[graph->
tail[rootedges_z[t]]] + SCIPgetRandomReal(0.0, max, &(heurdata->randseed));
1838 SCIPsortRealInt(terminalprio, terminalperm, nterms - 1);
1841 if( best >= 0 && best < nterms && SCIPgetRandomInt(0, 2, &(heurdata->randseed)) == 1 )
1842 terminalperm[runs - 1] = best;
1846 for( r = 0; r < runs; r++ )
1848 while( rootedges_z[terminalperm[z]] ==
UNKNOWN )
1854 if( edges_tz[terminalperm[z]] ==
UNKNOWN )
1858 rootedge = rootedges_z[terminalperm[z]];
1861 costrev[rootedge] = 0.0;
1864 for( e = 0; e < nedges; e++ )
1869 assert(pathdist != NULL);
1870 assert(pathedge != NULL);
1873 for( k = 0; k < nterms - 1; k++ )
1879 pathedge[graph->
tail[e]][root] = e;
1881 k = graph->
tail[edges_tz[terminalperm[z]]];
1882 pathdist[k][root] = 0.0;
1883 pathedge[k][root] = rootedge;
1887 for( k = 0; k < nnodes; k++ )
1891 assert(pathdist[k] != NULL);
1892 assert(pathedge[k] != NULL);
1900 SCIP_CALL(
computeSteinerTree(scip, graph, cost, costrev, pathdist, graph->
tail[rootedge], perm, result, cluster, pathedge, connected, &(heurdata->randseed)) );
1906 SCIP_CALL(
computeSteinerTreeDijk(scip, graph, cost, costrev, dijkdist, result, dijkedge, root, &(heurdata->randseed), connected) );
1908 if( SCIPisStopped(scip) )
1913 for( e = 0; e < nedges; e++)
1915 obj += graph->
cost[e];
1917 if( SCIPisLT(scip, obj, min) )
1919 *bestnewstart = terminalperm[z];
1922 printf(
" Obj(run: %d, ncall: %d)=%.12e\n", r, (
int) nexecs, obj);
1924 for( e = 0; e < nedges; e++ )
1925 best_result[e] = result[e];
1934 for( r = 0; r < nterms - 1 && !SCIPisStopped(scip); r++ )
1936 rootedge = rootedges_z[r];
1939 SCIPdebugMessage(
"rootedge: %d %d \n", graph->
tail[rootedge],graph->
head[rootedge] );
1940 assert(costrev[rootedge] ==
FARAWAY);
1941 costrev[rootedge] = 0.0;
1947 SCIPfreeBufferArray(scip, &terminalprio);
1948 SCIPfreeBufferArray(scip, &terminalperm);
1949 SCIPfreeBufferArray(scip, &edges_tz);
1950 SCIPfreeBufferArray(scip, &rootedges_z);
1951 SCIPfreeBufferArray(scip, &rootedges_t);
1955 SCIP_Real* orgcost = NULL;
1957 char solfound =
FALSE;
1958 assert(SCIPisGT(scip, (*hopfactor), 0.0));
1959 if( SCIPisLE(scip, maxcost, 0.0) )
1964 SCIP_Real bestfactor = -1;
1965 SCIP_CALL( SCIPallocBufferArray(scip, &orgcost, nedges) );
1966 BMScopyMemoryArray(orgcost, cost, nedges);
1969 for( r = 0; r < 10; r++ )
1971 for( e = 0; e < nedges; e++ )
1973 if( (SCIPisLT(scip, cost[e],
BLOCKED )) )
1974 cost[e] = 1.0 + orgcost[e] / ((*hopfactor) * maxcost);
1978 SCIP_CALL(
computeSteinerTreeDijk(scip, graph, cost, costrev, dijkdist, result, dijkedge, root, &(heurdata->randseed), connected) );
1983 for( e = 0; e < nedges; e++)
1987 obj += graph->
cost[e];
1992 if( SCIPisLT(scip, obj, min) && edgecount <= graph->hoplimit )
1995 *bestnewstart = root;
1997 for( e = 0; e < nedges; e++ )
1998 best_result[e] = result[e];
2001 bestfactor = (*hopfactor);
2004 if( !lsuccess || SCIPisGT(scip, fabs((
double) edgecount - graph->
hoplimit) / (
double) graph->
hoplimit, 0.05) )
2010 (*hopfactor) = (*hopfactor) * (1.0 + fabs((
double) edgecount - graph->
hoplimit) / (double) graph->
hoplimit);
2014 (*hopfactor) = (*hopfactor) * (1.0 + 3 * fabs((
double) edgecount - graph->
hoplimit) / (double) graph->
hoplimit);
2015 bestfactor = (*hopfactor);
2020 (*hopfactor) = (*hopfactor) / (1.0 + fabs((
double) edgecount - graph->
hoplimit) / (double) graph->
hoplimit);
2023 assert(SCIPisGT(scip, (*hopfactor), 0.0));
2030 (*hopfactor) = bestfactor;
2032 for( e = 0; e < nedges; e++ )
2033 if( (SCIPisLT(scip, cost[e],
BLOCKED )) )
2034 cost[e] = 1.0 + orgcost[e] / ((*hopfactor) * maxcost);
2035 for( e = 0; e < nedges; e++)
2038 for( r = 0; r < runs; r++ )
2040 for( e = 0; e < nedges; e++ )
2043 assert(start[r] >= 0);
2044 assert(start[r] < nnodes);
2047 if( SCIPisStopped(scip) )
2053 SCIP_CALL(
computeSteinerTreeDijk(scip, graph, cost, costrev, dijkdist, result, dijkedge, start[r], &(heurdata->randseed), connected) );
2061 assert(pathdist != NULL);
2062 assert(pathedge != NULL);
2063 for( i = 0; i < nnodes; i++ )
2064 graph->
mark[i] = (graph->
grad[i] > 0);
2067 for( k = 0; k < nnodes; ++k )
2079 SCIP_CALL(
computeDegConsTree(scip, graph, cost, costrev, pathdist, start[r], perm, result, cluster, pathedge, &(heurdata->randseed), connected, &solfound) );
2081 else if( mode ==
TM_SP )
2086 assert(pathdist != NULL);
2087 assert(pathedge != NULL);
2088 for( i = 0; i < nnodes; i++ )
2089 graph->
mark[i] = (graph->
grad[i] > 0);
2092 for( k = 0; k < nnodes; ++k )
2103 SCIP_CALL(
computeSteinerTree(scip, graph, cost, costrev, pathdist, start[r], perm, result, cluster, pathedge, connected, &(heurdata->randseed)) );
2107 SCIP_CALL(
computeSteinerTreeVnoi(scip, graph, pqueue, gnodearr, cost, costrev, node_dist, start[r], result, vcount,
2108 nodenterms, node_base, node_edge, (r == 0), connected) );
2114 for( e = 0; e < nedges; e++)
2118 obj += graph->
cost[e];
2123 SCIPdebugMessage(
" Obj=%.12e\n", obj);
2125 if( SCIPisLT(scip, obj, min) && (graph->
stp_type !=
STP_DEG_CONS || solfound) && !SCIPisStopped(scip) && r < runs )
2130 *bestnewstart = start[r];
2132 for( e = 0; e < nedges; e++ )
2133 best_result[e] = result[e];
2141 assert(orgcost != NULL);
2142 for( e = 0; e < nedges; e++ )
2144 cost[e] = orgcost[e];
2147 SCIPfreeBufferArray(scip, &orgcost);
2152 SCIPfreeBufferArrayNull(scip, &perm);
2155 assert(pathedge != NULL);
2156 assert(pathdist != NULL);
2157 SCIPfreeBufferArray(scip, &cluster);
2158 for( k = nnodes - 1; k >= 0; k-- )
2160 SCIPfreeBufferArrayNull(scip, &(pathedge[k]));
2161 SCIPfreeBufferArrayNull(scip, &(pathdist[k]));
2164 SCIPfreeBufferArray(scip, &pathedge);
2165 SCIPfreeBufferArray(scip, &pathdist);
2169 SCIPpqueueFree(&pqueue);
2171 SCIPfreeBufferArray(scip, &vcount);
2172 assert(node_edge != NULL);
2173 assert(node_dist != NULL);
2174 assert(node_base != NULL);
2175 assert(gnodearr != NULL);
2176 for( k = nnodes - 1; k >= 0; k-- )
2178 SCIPfreeBufferArray(scip, &node_edge[k]);
2179 SCIPfreeBufferArray(scip, &node_dist[k]);
2180 SCIPfreeBufferArray(scip, &node_base[k]);
2181 SCIPfreeBuffer(scip, &gnodearr[k]);
2183 SCIPfreeBufferArray(scip, &node_edge);
2184 SCIPfreeBufferArray(scip, &node_dist);
2185 SCIPfreeBufferArray(scip, &node_base);
2186 SCIPfreeBufferArray(scip, &gnodearr);
2187 SCIPfreeBufferArray(scip, &nodenterms);
2191 SCIPfreeBufferArray(scip, &dijkedge);
2192 SCIPfreeBufferArray(scip, &dijkdist);
2195 SCIPfreeBufferArray(scip, &result);
2196 SCIPfreeBufferArray(scip, &start);
2197 SCIPfreeBufferArray(scip, &connected);
2210 assert(scip != NULL);
2211 assert(heur != NULL);
2212 assert(strcmp(SCIPheurGetName(heur),
HEUR_NAME) == 0);
2224 SCIP_HEURDATA* heurdata;
2226 assert(heur != NULL);
2227 assert(strcmp(SCIPheurGetName(heur),
HEUR_NAME) == 0);
2228 assert(scip != NULL);
2230 heurdata = SCIPheurGetData(heur);
2231 assert(heurdata != NULL);
2234 SCIPfreeMemory(scip, &heurdata);
2235 SCIPheurSetData(heur, NULL);
2245 SCIP_HEURDATA* heurdata;
2246 SCIP_PROBDATA* probdata;
2249 assert(strcmp(SCIPheurGetName(heur),
HEUR_NAME) == 0);
2251 heurdata = SCIPheurGetData(heur);
2252 assert(heurdata != NULL);
2254 probdata = SCIPgetProbData(scip);
2255 assert(probdata != NULL);
2263 heurdata->stp_type = graph->
stp_type;
2264 heurdata->beststartnode = -1;
2265 heurdata->ncalls = 0;
2266 heurdata->nlpiterations = -1;
2267 heurdata->nexecs = 0;
2270 heurdata->randseed += getUgRank();
2272 heurdata->randseed = 0;
2283 SCIP_PROBDATA* probdata;
2284 SCIP_HEURDATA* heurdata;
2293 SCIP_Real oldtimelimit = 0.0;
2295 SCIP_Real* nodepriority;
2304 SCIP_Real pctrivialbound =
FARAWAY;
2305 SCIP_Bool success =
FALSE;
2307 assert(scip != NULL);
2308 assert(strcmp(SCIPheurGetName(heur),
HEUR_NAME) == 0);
2309 assert(scip != NULL);
2310 assert(result != NULL);
2312 *result = SCIP_DELAYED;
2313 *result = SCIP_DIDNOTRUN;
2316 heurdata = SCIPheurGetData(heur);
2317 assert(heurdata != NULL);
2319 probdata = SCIPgetProbData(scip);
2320 assert(probdata != NULL);
2323 assert(graph != NULL);
2326 nedges = graph->
edges;
2327 nnodes = graph->
knots;
2329 nodepriority = NULL;
2337 if( heurtiming & SCIP_HEURTIMING_BEFORENODE )
2339 if( SCIPgetDepth(scip) > 0 )
2342 runs = heurdata->initruns;
2344 else if( ((heurtiming & SCIP_HEURTIMING_DURINGLPLOOP) && (heurdata->ncalls % heurdata->duringlpfreq == 0)) || (heurtiming & SCIP_HEURTIMING_AFTERLPLOOP) )
2347 runs = 2 * heurdata->evalruns;
2349 runs = heurdata->evalruns;
2351 else if( heurtiming & SCIP_HEURTIMING_AFTERNODE )
2353 if( SCIPgetDepth(scip) == 0 )
2354 runs = heurdata->rootruns;
2356 runs = heurdata->leafruns;
2366 SCIPdebugMessage(
"Heuristic Start\n");
2368 if( heurtiming & SCIP_HEURTIMING_BEFORENODE )
2370 SCIP_CALL( SCIPgetRealParam(scip,
"limits/time", &oldtimelimit) );
2371 SCIP_CALL( SCIPsetRealParam(scip,
"limits/time", 0.95 * oldtimelimit) );
2380 assert(vars[0] != NULL);
2383 SCIP_CALL( SCIPallocBufferArray(scip, &cost, nedges) );
2384 SCIP_CALL( SCIPallocBufferArray(scip, &costrev, nedges) );
2385 SCIP_CALL( SCIPallocBufferArray(scip, &results, nedges) );
2386 SCIP_CALL( SCIPallocBufferArray(scip, &nval, nvars) );
2388 *result = SCIP_DIDNOTFIND;
2391 if( !SCIPhasCurrentNodeLP(scip) || SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
2398 SCIP_CALL( SCIPcreateSol(scip, &sol, heur) );
2401 SCIP_CALL( SCIPlinkLPSol(scip, sol) );
2405 SCIP_CALL( SCIPfreeSol(scip, &sol) );
2409 for( e = 0; e < nedges; e++ )
2420 SCIP_Real randupper;
2421 SCIP_Real randlower;
2422 randupper = SCIPgetRandomReal(1.1, 2.5, &(heurdata->randseed));
2423 randlower = SCIPgetRandomReal(1.1, randupper, &(heurdata->randseed));
2425 for( layer = 0; layer < 1; layer++ )
2429 BMScopyMemoryArray(cost, graph->
cost, nedges);
2434 for( e = 0; e < nedges; e++)
2436 if( SCIPvarGetUbGlobal(vars[e] ) < 0.5 )
2438 else if( SCIPisGT(scip, cost[e], maxcost) && SCIPisLT(scip, cost[e],
FARAWAY) )
2441 for( e = 0; e < nedges; e++)
2448 SCIP_CALL( SCIPallocBufferArray(scip, &nodepriority, nnodes) );
2449 for( e = 0; e < nnodes; e++)
2452 nodepriority[e] = (double) graph->
grad[e];
2454 nodepriority[e] = SCIPgetRandomReal(0.0, 1.0, &(heurdata->randseed));
2458 for( e = 0; e < nedges; e += 2)
2460 if( SCIPvarGetUbGlobal(vars[layer * nedges + e + 1]) < 0.5 )
2467 costrev[e] = cost[e + 1];
2470 if( SCIPvarGetUbGlobal(vars[layer * nedges + e]) < 0.5 )
2477 costrev[e + 1] = cost[e];
2484 SCIP_Bool partrand =
FALSE;
2485 SCIP_Bool totalrand =
FALSE;
2486 SCIP_CALL( SCIPallocBufferArray(scip, &nodepriority, nnodes) );
2487 for( e = 0; e < nnodes; e++)
2488 nodepriority[e] = 0.0;
2489 if( (heurdata->nlpiterations == SCIPgetNLPIterations(scip) && SCIPgetRandomInt(0, 3, &(heurdata->randseed)) != 1)
2490 || SCIPgetRandomInt(0, 10, &(heurdata->randseed)) == 5 )
2493 if( !partrand && (heurdata->nlpiterations == SCIPgetNLPIterations(scip) || SCIPgetRandomInt(0, 25, &(heurdata->randseed)) == 10) )
2495 else if( graph->
stp_type ==
STP_DEG_CONS && heurdata->ncalls != 1 && SCIPgetRandomInt(0, 1, &(heurdata->randseed)) == 1 && (graph->
maxdeg[graph->
source[0]] == 1 ||
2496 SCIPgetRandomInt(0, 5, &(heurdata->randseed)) == 5) )
2505 for( e = 0; e < nedges; e++)
2507 nodepriority[graph->
head[e]] += xval[e];
2508 nodepriority[graph->
tail[e]] += xval[e];
2513 for( e = 0; e < nedges; e++ )
2515 if( SCIPvarGetUbGlobal(vars[e] ) < 0.5 )
2523 randval = SCIPgetRandomReal(randlower, randupper, &(heurdata->randseed));
2524 cost[e] = graph->
cost[e] * randval;
2528 cost[e] = ((1.0 - xval[e]) * graph->
cost[e]);
2533 randval = SCIPgetRandomReal(randlower, randupper, &(heurdata->randseed));
2534 cost[e] = cost[e] * randval;
2536 if( SCIPisLT(scip, cost[e],
BLOCKED) && SCIPisGT(scip, cost[e], maxcost) )
2538 assert(SCIPisGE(scip, cost[e], 0.0));
2540 for( e = 0; e < nedges; e++)
2546 for( e = 0; e < nedges; e += 2)
2548 randval = SCIPgetRandomReal(randlower, randupper, &(heurdata->randseed));
2550 if( SCIPvarGetUbLocal(vars[layer * nedges + e + 1]) < 0.5 )
2558 costrev[e] = graph->
cost[e + 1] * randval;
2560 costrev[e] = ((1.0 - xval[layer * nedges + e + 1]) * graph->
cost[e + 1]);
2563 costrev[e] = costrev[e] * randval;
2565 cost[e + 1] = costrev[e];
2568 if( SCIPvarGetUbLocal(vars[layer * nedges + e]) < 0.5 )
2576 costrev[e + 1] = graph->
cost[e] * randval;
2578 costrev[e + 1] = ((1.0 - xval[layer * nedges + e]) * graph->
cost[e]);
2581 costrev[e + 1] = costrev[e + 1] * randval;
2582 cost[e] = costrev[e + 1];
2584 assert(SCIPisGE(scip, cost[e], 0.0));
2585 assert(SCIPisGE(scip, costrev[e], 0.0));
2588 if( SCIPisLT(scip, cost[e],
BLOCKED) && SCIPisLT(scip, cost[e + 1],
BLOCKED) )
2590 if( SCIPisLT(scip, cost[e], cost[e + 1]) )
2592 cost[e + 1] = cost[e];
2593 costrev[e] = cost[e];
2594 costrev[e + 1] = cost[e];
2598 cost[e] = cost[e + 1];
2599 costrev[e] = cost[e + 1];
2600 costrev[e + 1] = cost[e + 1];
2609 for( e = 0; e < nedges; e++ )
2611 if( SCIPisZero(scip, cost[e]) )
2613 cost[e] = SCIPepsilon(scip) * 2;
2614 assert(!SCIPisZero(scip, cost[e]));
2615 assert(SCIPisZero(scip, costrev[
flipedge(e)]));
2623 cost, costrev, &(heurdata->hopfactor), nodepriority, maxcost, &success) );
2628 for( v = 0; v < nvars; v++ )
2629 nval[v] = (results[v % nedges] == (v / nedges)) ? 1.0 : 0.0;
2636 for( e = 0; e < nedges; e++ )
2638 pobj += graph->
cost[e];
2640 if( SCIPisLE(scip, pobj, SCIPgetPrimalbound(scip)) )
2642 heurdata->beststartnode = best_start;
2647 *result = SCIP_FOUNDSOL;
2653 if( !success || SCIPisGT(scip, fabs(edgecount - graph->
hoplimit)/(
double) graph->
hoplimit, 0.2) )
2655 SCIP_Real
hopfactor = heurdata->hopfactor;
2657 hopfactor = hopfactor * (1.0 + fabs(edgecount - graph->
hoplimit) / (double) graph->
hoplimit);
2659 hopfactor = hopfactor / (1.0 + fabs(edgecount - graph->
hoplimit) / (double) graph->
hoplimit);
2660 if( SCIPisLE(scip, hopfactor, 0.0) )
2666 heurdata->nlpiterations = SCIPgetNLPIterations(scip);
2667 SCIPfreeBufferArrayNull(scip, &nodepriority);
2668 SCIPfreeBufferArray(scip, &nval);
2669 SCIPfreeBufferArray(scip, &results);
2670 SCIPfreeBufferArray(scip, &costrev);
2671 SCIPfreeBufferArray(scip, &cost);
2674 if( heurtiming & SCIP_HEURTIMING_BEFORENODE )
2676 SCIP_CALL( SCIPsetRealParam(scip,
"limits/time", oldtimelimit) );
2691 SCIP_HEURDATA* heurdata;
2693 char paramdesc[SCIP_MAXSTRLEN];
2696 SCIP_CALL( SCIPallocMemory(scip, &heurdata) );
2700 SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
2704 assert(heur != NULL);
2707 SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyTM) );
2708 SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeTM) );
2709 SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitTM) );
2710 heurdata->ncalls = 0;
2711 heurdata->nlpiterations = -1;
2712 heurdata->nexecs = 0;
2715 heurdata->randseed += getUgRank();
2717 heurdata->randseed = 0;
2720 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/evalruns",
2721 "number of runs for eval",
2723 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/randseed",
2724 "random seed for heuristic",
2726 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/initruns",
2727 "number of runs for init",
2729 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/leafruns",
2730 "number of runs for leaf",
2732 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/rootruns",
2733 "number of runs for root",
2735 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/duringlpfreq",
2736 "frequency for calling heuristic during LP loop",
2738 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/type",
2739 "Heuristic: 0 automatic, 1 TM_SP, 2 TM_VORONOI, 3 TM_DIJKSTRA",
2743 (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN,
"timing when heuristc should be called (%u:BEFORENODE, %u:DURINGLPLOOP, %u:AFTERLPLOOP, %u:AFTERNODE)", SCIP_HEURTIMING_BEFORENODE, SCIP_HEURTIMING_DURINGLPLOOP, SCIP_HEURTIMING_AFTERLPLOOP, SCIP_HEURTIMING_AFTERNODE);
2744 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/timing", paramdesc,
2745 (
int*) &heurdata->timing,
TRUE, (
int)
HEUR_TIMING, (
int) SCIP_HEURTIMING_BEFORENODE, 2 * (
int) SCIP_HEURTIMING_AFTERPSEUDONODE - 1, NULL, NULL) );
static SCIP_DECL_HEURFREE(heurFreeTM)
SCIP_RETCODE SCIPheurPruneSteinerTree(SCIP *scip, const GRAPH *g, SCIP_Real *cost, int layer, int *result, char *connected)
SCIP_RETCODE SCIPheurPrunePCSteinerTree(SCIP *scip, const GRAPH *g, SCIP_Real *cost, int *result, char *connected)
#define DEFAULT_HOPFACTOR
SCIP_RETCODE SCIPincludeHeurTM(SCIP *scip)
SCIP_RETCODE SCIPvalidateStpSol(SCIP *, const GRAPH *, const double *, SCIP_Bool *)
SCIP_VAR ** SCIPprobdataGetVars(SCIP *scip)
static SCIP_DECL_HEURINIT(heurInitTM)
static SCIP_RETCODE computeSteinerTree(SCIP *scip, const GRAPH *g, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real **pathdist, int start, int *perm, int *result, int *cluster, int **pathedge, char *connected, unsigned int *randseed)
static SCIP_DECL_HEUREXEC(heurExecTM)
SCIP_RETCODE SCIPheurPruneDegConsSteinerTree(SCIP *scip, const GRAPH *g, int *result, char *connected)
Problem data for stp problem.
int SCIPprobdataGetNVars(SCIP *scip)
SCIP_Longint nlpiterations
static SCIP_RETCODE computeDegConsTree(SCIP *scip, const GRAPH *g, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real **pathdist, int start, int *perm, int *result, int *cluster, int **pathedge, unsigned int *randseed, char *connected, char *solfound)
GRAPH * SCIPprobdataGetGraph(SCIP_PROBDATA *probdata)
static SCIP_DECL_PARAMCHGD(paramChgdRandomseed)
static SCIP_RETCODE computeSteinerTreeDijk(SCIP *scip, const GRAPH *g, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real *dijkdist, int *result, int *dijkedge, int start, unsigned int *randseed, char *connected)
void voronoi(SCIP *scip, const GRAPH *, SCIP_Real *, SCIP_Real *, char *, int *, PATH *)
void graph_path_execX(SCIP *, const GRAPH *, int, SCIP_Real *, SCIP_Real *, int *)
SCIP_RETCODE voronoi_extend2(SCIP *, const GRAPH *, SCIP_Real *, PATH *, SCIP_Real **, int **, int **, char *, int *, int *, int *, int, int, int)
void heap_add(int *, int *, int *, int, PATH *)
#define DEFAULT_DURINGLPFREQ
SCIP_RETCODE SCIPprobdataAddNewSol(SCIP *scip, SCIP_Real *nval, SCIP_SOL *sol, SCIP_HEUR *heur, SCIP_Bool *success)
SCIP_Real SCIPprobdataGetOffset(SCIP *scip)
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)
static SCIP_DECL_HEURCOPY(heurCopyTM)
#define STP_MAX_NODE_WEIGHT
static SCIP_RETCODE prune(SCIP *scip, const GRAPH *g, SCIP_Real *cost, SCIP_Real *costrev, int *result, char *connected)
int GNODECmpByDist(void *first_arg, void *second_arg)
SCIP_Bool graph_sol_valid(SCIP *, const GRAPH *, int *)
void graph_path_st(SCIP *, const GRAPH *, SCIP_Real *, SCIP_Real *, int *, int, unsigned int *, char *)
static void do_prizecoll_trivial(SCIP *scip, const GRAPH *graph, int *best_result)
#define STP_PRIZE_COLLECTING
static SCIP_RETCODE computeSteinerTreeVnoi(SCIP *scip, const GRAPH *g, SCIP_PQUEUE *pqueue, GNODE **gnodearr, SCIP_Real *cost, SCIP_Real *costrev, SCIP_Real **node_dist, int start, int *result, int *vcount, int *nodenterms, int **node_base, int **node_edge, char firstrun, char *connected)
#define STP_ROOTED_PRIZE_COLLECTING
SCIP_Real * SCIPprobdataGetXval(SCIP *scip, SCIP_SOL *sol)
shortest paths based primal heuristics for Steiner problems
void graph_path_exec(SCIP *, const GRAPH *, int, int, SCIP_Real *, PATH *)