65 path[l].dist = (mode ==
MST_MODE) ? cost : (path[k].dist + cost);
78 while( (j > 1) && path[heap[c]].dist > path[heap[j]].dist )
108 heap[1] = heap[(*count)--];
112 if (
LT(path[heap[3]].dist, path[heap[2]].dist))
115 while((c <= (*count)) &&
GT(path[heap[j]].dist, path[heap[c]].dist))
125 if ((c + 1) <= (*count))
126 if (
LT(path[heap[c + 1]].dist, path[heap[c]].dist))
146 path[node].dist = 0.0;
148 heap[++(*count)] = node;
149 state[node] = (*count);
155 while( (j > 1) &&
GT(path[heap[c]].dist, path[heap[j]].dist) )
188 assert(pathedge[k] != -1);
191 for(
int node = g->
tail[pathedge[k]]; !connected[node]; node = g->
tail[pathedge[node]] )
193 connected[node] =
TRUE;
202 assert(pathedge[node] != -1);
221 for(
int k = 0; k <
nnodes; k++ )
227 connected[k] =
FALSE;
234 *npseudoterms = ntermspos;
256 for(
int k = 0; k <
nnodes; k++ )
261 connected[k] =
FALSE;
272 *nrealterms = nrterms;
288 assert(!connected[term]);
290 assert(deg_free[term] >= 0);
292 if( deg_free[term] == 0 )
294 SCIPdebugMessage(
"failed to add %d-path because free degree 0 end \n", term);
299 for( node = g->
tail[pathedge[term]]; !connected[node]; node = g->
tail[pathedge[node]] )
301 assert(pathedge[node] != -1);
303 assert(deg_free[node] >= 0);
305 if( deg_free[node] <= 1 )
307 SCIPdebugMessage(
"failed to add %d-path due to node %d (free degree: %d) \n", term, node, deg_free[node]);
312 assert(connected[node]);
314 if( deg_free[node] == 0 )
316 SCIPdebugMessage(
"failed to add %d-path because free degree 0 start \n", node);
344 assert(*heapsize > 0);
345 assert(*soldegfree > 0);
348 while( *heapsize > 0 )
350 const int k =
nearestX(heap, state, heapsize, pathdist);
360 assert(pathedge[k] >= 0);
361 assert(nodedeg_free[k] >= 1);
363 nodedeg_free[k] -= 1;
371 for( node = g->
tail[pathedge[k]]; !connected[node]; node = g->
tail[pathedge[node]] )
373 assert(pathedge[node] != -1);
375 assert(nodedeg_free[node] >= 2);
379 pathdeg_free[node] = 0;
380 nodedeg_free[node] -= 2;
381 connected[node] =
TRUE;
382 result[pathedge[node]] =
CONNECT;
383 resetX(pathdist, heap, state, heapsize, node, 0.0);
386 assert(nodedeg_free[node] >= 1);
387 nodedeg_free[node] -= 1;
390 if( ++(*nsolterms) == g->
terms )
395 assert((*nsolterms) < g->
terms);
400 if( nodedeg_free[k] <= 1 )
407 else if( nodedeg_free[k] == 0 )
415 const int m = g->
head[e];
422 if(
GT(pathdist[m], (pathdist[k] + cost[e]))
423 || (
EQ(pathdist[m], (pathdist[k] + cost[e])) && (pathdeg_free[k] + nodedeg_free[m] - 2 > pathdeg_free[m]) )
426 assert(nodedeg_free[m] > 0);
427 correctX(heap, state, heapsize, pathdist, pathedge, m, k, e, cost[e]);
429 pathdeg_free[m] = pathdeg_free[k] + nodedeg_free[m] - 2;
453 heap[++(*count)] = node;
454 state[node] = (*count);
460 while((j > 1) &&
GT(path[heap[c]].dist, path[heap[j]].dist))
462 const int t = heap[c];
556 assert(start < g->knots);
560 assert(path !=
NULL);
561 assert(cost !=
NULL);
562 assert(g->
mark[start]);
565 for(
int i = 0; i <
nnodes; i++ )
572 path[start].
dist = 0.0;
578 heap[nheapElems] = start;
579 state[start] = nheapElems;
581 while( nheapElems > 0 )
589 for(
int e = g->
outbeg[k]; e >= 0; e = g->
oeat[e] )
591 const int m = g->
head[e];
598 if( path[m].dist > ((mode ==
MST_MODE) ? cost[e] : (path[k].dist + cost[e])) && g->
mark[m] )
600 pathheapCorrect(heap, state, &nheapElems, path, m, k, e, cost[e], mode);
620 int* RESTRICT visitlist = dijkdata->
visitlist;
626 assert(nodes_dist && visitlist && visited && dheap && edges_cost && nodes_abort && abortdistance);
627 assert(dheap->
size == 0);
631 for(
int k = 0; k < g->
knots; k++ )
633 assert(nodes_dist[k] ==
FARAWAY);
639 nodes_dist[startnode] = 0.0;
640 visitlist[(nvisits)++] = startnode;
641 visited[startnode] =
TRUE;
644 while( dheap->
size > 0 )
651 *abortdistance = nodes_dist[k];
655 for(
int e = g->
inpbeg[k]; e >= 0; e = g->
ieat[e] )
657 const int m = g->
tail[e];
661 const SCIP_Real distnew = nodes_dist[k] + edges_cost[e];
665 assert(nvisits < g->knots);
666 visitlist[(nvisits)++] = m;
670 if(
LT(distnew, nodes_dist[m]) )
672 nodes_dist[m] = distnew;
700 const int limit1 = limit / 2;
704 assert(heap !=
NULL);
705 assert(path !=
NULL);
706 assert(cost !=
NULL);
707 assert(nlbl !=
NULL);
708 assert(memlbl !=
NULL);
713 if( g->
grad[tail] == 0 || g->
grad[head] == 0 )
716 assert(g->
mark[head] && g->
mark[tail]);
720 path[tail].
dist = 0.0;
722 memlbl[(*nlbl)++] = tail;
728 for(
int e = g->
outbeg[tail]; e >= 0; e = g->
oeat[e] )
730 const int m = g->
head[e];
732 if( g->
mark[m] && (
GE(distlimit, cost[e])) )
737 assert(
GT(path[m].dist, path[tail].dist + cost[e]));
740 memlbl[(*nlbl)++] = m;
743 if( nchecks++ > limit1 )
750 while( count > 0 && nchecks <= limit )
759 if(
GT(path[k].dist, distlimit) )
769 for(
int e = g->
outbeg[k]; e >= 0; e = g->
oeat[e] )
771 const int m = g->
head[e];
773 if( state[m] && g->
mark[m] &&
GE(distlimit, cost[e]) && (
GT(path[m].dist, path[k].dist + cost[e])) )
777 memlbl[(*nlbl)++] = m;
780 if( nchecks++ > limit )
805 const int limit1 = limit / 2;
812 assert(heap !=
NULL);
813 assert(path !=
NULL);
814 assert(cost !=
NULL);
815 assert(nlbl !=
NULL);
816 assert(memlbl !=
NULL);
818 assert(pathmaxnode !=
NULL);
822 if( g->
grad[tail] == 0 || g->
grad[head] == 0 )
825 assert(g->
mark[head] && g->
mark[tail]);
829 path[tail].
dist = 0.0;
831 memlbl[(*nlbl)++] = tail;
838 const int m = g->
head[e];
842 assert(
SCIPisGT(scip, path[m].dist, path[tail].dist + cost[e]));
845 memlbl[(*nlbl)++] = m;
848 if( nchecks++ > limit1 )
859 SCIP_Real maxweight = pathmaxnode[k] >= 0 ? g->
prize[pathmaxnode[k]] : 0.0;
862 assert(maxweight >= 0);
863 assert(
SCIPisLE(scip, path[k].dist - maxweight, distlimit));
875 maxweight = g->
prize[k];
879 if( block && stateblock[k] ==
CONNECT )
885 const int m = g->
head[e];
887 if( state[m] && g->
mark[m] && path[m].
dist > (path[k].
dist + cost[e])
888 && distlimit >= (path[k].
dist + cost[e] - maxweight) )
891 memlbl[(*nlbl)++] = m;
893 pathmaxnode[m] = pathmaxnode[k];
896 if( nchecks++ > limit )
924 assert(start < g->knots);
927 assert(pathdist !=
NULL);
928 assert(pathedge !=
NULL);
929 assert(cost !=
NULL);
939 for( i = nnodes - 1; i >= 0; --i )
957 k =
nearestX(heap, state, &count, pathdist);
965 if( state[m] && g->
mark[m] &&
SCIPisGT(scip, pathdist[m], (pathdist[k] + cost[i])) )
966 correctX(heap, state, &count, pathdist, pathedge, m, k, i, cost[i]);
993 assert(start < g->knots);
996 assert(pathdist !=
NULL);
997 assert(pathedge !=
NULL);
998 assert(cost !=
NULL);
1009 for( i = nnodes - 1; i >= 0; --i )
1029 k =
nearestX(heap, state, &count, pathdist);
1034 rootdist = pathdist[k];
1035 else if(
SCIPisGT(scip, pathdist[k], rootdist) )
1042 if( state[m] && g->
mark[m] &&
SCIPisGT(scip, pathdist[m], (pathdist[k] + cost[i])) )
1043 correctX(heap, state, &count, pathdist, pathedge, m, k, i, cost[i]);
1063 int*
const state = dheap->
position;
1065 const int*
const start_csr = csr->
start;
1066 const int*
const head_csr = csr->
head;
1072 assert(csr && g && dist && dheap && pred && connected && connected_out);
1075 assert(!connected[start]);
1078 outermaxprize = 0.0;
1080 for(
int k = 0; k <
nnodes; k++ )
1084 connected_out[k] =
FALSE;
1089 if( !connected[k] &&
Is_term(g->
term[k]) && g->
prize[k] > outermaxprize && k != start )
1090 outermaxprize = g->
prize[k];
1097 connected_out[start] =
TRUE;
1098 outerprofit = g->
prize[start];
1100 for(
int rounds = 0; rounds < 2 && *success ==
FALSE; rounds++ )
1108 if( dheap->
size > 0 )
1111 assert(dheap->
size == 0);
1114 for(
int k = 0; k <
nnodes; k++ )
1116 if( connected_out[k] )
1126 while( dheap->
size > 0 )
1130 const int k_start = start_csr[k];
1131 const int k_end = start_csr[k + 1];
1135 if( (connected[k] &&
SCIPisGT(scip, outerprofit, dist[k]))
1139 assert(pred[k] != -1);
1140 assert(!connected_out[k] || !connected[k]);
1142 outerprofit += g->
prize[k] - dist[k];
1143 connected_out[k] =
TRUE;
1146 assert(
SCIPisGE(scip, outerprofit, g->
prize[start]) || connected[k]);
1149 for(
int node = pred[k]; !connected_out[node]; node = pred[node] )
1151 connected_out[node] =
TRUE;
1156 outerprofit += g->
prize[node];
1158 assert(state[node]);
1159 assert(pred[node] >= 0);
1168 else if( outerprofit + outermaxprize < dist[k] )
1170 assert(*success ==
FALSE);
1175 for(
int e = k_start; e < k_end; e++ )
1177 const int m = head_csr[e];
1178 const SCIP_Real distnew = dist[k] + cost_csr[e];
1180 if( distnew < dist[m] )
1192 for(
int k = 0; k <
nnodes; k++ )
1193 if( connected_out[k] )
1194 connected[k] =
TRUE;
1213 assert(pathdist !=
NULL);
1214 assert(pathedge !=
NULL);
1217 assert(start < g->knots);
1218 assert(cost !=
NULL);
1219 assert(connected !=
NULL);
1227 for(
int k = 0; k <
nnodes; k++ )
1232 connected[k] =
FALSE;
1235 pathdist[start] = 0.0;
1236 connected[start] =
TRUE;
1247 heap[count] = start;
1248 state[start] = count;
1254 const int k =
nearestX(heap, state, &count, pathdist);
1260 assert(pathedge[k] >= 0 && !connected[k]);
1262 connected[k] =
TRUE;
1266 for(
int node = g->
tail[pathedge[k]]; !connected[node]; node = g->
tail[pathedge[node]] )
1268 assert(pathedge[node] != -1);
1271 connected[node] =
TRUE;
1272 resetX(pathdist, heap, state, &count, node, 0.0);
1276 if( ++nterms == g->
terms )
1283 const int m = g->
head[e];
1288 if( !connected[m] && pathdist[m] > (pathdist[k] + cost[e]) && g->
mark[m] )
1289 correctX(heap, state, &count, pathdist, pathedge, m, k, e, cost[e]);
1318 assert(cost && pathdist && pathedge && connected && result && solFound);
1319 assert(heap && state);
1331 for(
int e = 0; e < nedges; e++ )
1334 for(
int k = 0; k <
nnodes; k++ )
1336 pathdeg_free[k] = -1;
1340 connected[k] =
FALSE;
1343 pathdist[start] = 0.0;
1344 connected[start] =
TRUE;
1357 printf(
"TM start=%d \n", start);
1361 soldegfree = nodedeg_free[start];
1365 heap[heapsize] = start;
1366 state[start] = heapsize;
1367 pathdeg_free[start] = 0;
1375 nsolterms_old = nsolterms;
1376 sdDcExtendTree(g, cost, &heapsize, pathdeg_free, nodedeg_free, pathdist, pathedge, connected, result, &soldegfree, &nsolterms);
1378 assert(nsolterms <= g->terms);
1379 assert(nsolterms >= nsolterms_old);
1382 if( nsolterms_old != nsolterms && nsolterms != g->
terms && soldegfree > 0 )
1386 for(
int k = 0; k <
nnodes; k++ )
1390 heap[++heapsize] = k;
1391 state[k] = heapsize;
1392 assert(pathdeg_free[k] == 0);
1396 pathdeg_free[k] = 0;
1403 assert(heapsize > 0);
1407 if( nsolterms == g->
terms )
1410 }
while( nsolterms_old != nsolterms && soldegfree > 0 );
1413 *solFound = (g->
terms == nsolterms);
1433 int* orderedprizes_id,
1444 int*
const RESTRICT heap = g->
path_heap;
1448 .maxoutprize = -
FARAWAY, .maxoutprize_idx = -1};
1450 assert(g && cost && prize && pathdist && pathedge && connected);
1452 assert(start < g->knots);
1457 stPcmwInit(g, pathdist, pathedge, connected, &ntermspos);
1459 assert(g->
mark[start]);
1460 assert(ntermspos >= 0);
1462 pathdist[start] = 0.0;
1463 connected[start] =
TRUE;
1480 heap[count] = start;
1481 state[start] = count;
1487 const int k =
nearestX(heap, state, &count, pathdist);
1493 connectK = (prize[k] >= pathdist[k]);
1501 for(
int node = g->
tail[pathedge[k]]; !connected[node]; node = g->
tail[pathedge[node]] )
1505 prizesum += prize[node];
1509 prizesum += prize[node];
1513 assert(prizesum >= 0.0 &&
LT(prizesum,
FARAWAY));
1515 connectK = (prize[k] + prizesum >= pathdist[k]);
1520 stPcmwConnectNode(k, g, &spaths_pc, pathdist, pathedge, connected, &count, &nterms);
1522 assert(nterms <= ntermspos);
1525 if( nterms == ntermspos )
1533 if( !connectK && pathdist[k] > spaths_pc.
maxoutprize )
1539 for(
int e = g->
outbeg[k]; e >= 0; e = g->
oeat[e] )
1541 const int m = g->
head[e];
1546 if( g->
mark[m] && !connected[m] && pathdist[m] > (pathdist[k] + cost[e]) )
1547 correctX(heap, state, &count, pathdist, pathedge, m, k, e, cost[e]);
1566 assert(tmpnodeweight !=
NULL);
1567 assert(result !=
NULL);
1570 assert(start < g->knots);
1571 assert(cost !=
NULL);
1572 assert(connected !=
NULL);
1578 const int head = g->
head[e];
1585 assert(connected[head]);
1587 if(
SCIPisGE(scip, cost[e], tmpnodeweight[head]) )
1589 connected[head] =
FALSE;
1594 tmpnodeweight[start] += tmpnodeweight[head] - cost[e];
1622 assert(start >= 0 && start < g->knots);
1631 pathdist[start] = 0.0;
1632 connected[start] =
TRUE;
1640 heap[heapsize] = start;
1641 state[start] = heapsize;
1647 while( heapsize > 0 )
1650 const int k =
nearestX(heap, state, &heapsize, pathdist);
1656 connected[k] =
TRUE;
1660 assert(pathedge[k] != -1);
1662 for(
int node = g->
tail[pathedge[k]]; !connected[node]; node = g->
tail[pathedge[node]] )
1664 connected[node] =
TRUE;
1665 resetX(pathdist, heap, state, &heapsize, node, 0.0);
1668 assert(pathedge[node] != -1);
1672 if( ++termscount == nterms )
1679 for(
int e = g->
outbeg[k]; e >= 0; e = g->
oeat[e] )
1681 const int m = g->
head[e];
1686 if( !connected[m] && g->
mark[m] &&
GT(pathdist[m], (pathdist[k] + cost[e])) )
1687 correctX(heap, state, &heapsize, pathdist, pathedge, m, k, e, cost[e]);
1695 for(
int k = 0; k <
nnodes; k++ )
1698 assert(connected[k]);
1724 assert(path !=
NULL);
1726 assert(cost !=
NULL);
1727 assert(connected !=
NULL);
1736 *extensions =
FALSE;
1740 for(
int k = 0; k <
nnodes; k++ )
1743 if( connected[k] && g->
mark[k] )
1762 if( g->
prize[k] > maxprize )
1764 maxprize = g->
prize[k];
1795 connected[k] =
TRUE;
1798 assert(path[k].edge >= 0);
1801 while( !connected[node] )
1803 assert(path[node].edge !=
UNKNOWN);
1804 connected[node] =
TRUE;
1806 assert(state[node]);
1814 assert(path[node].dist == 0.0);
1815 assert(nterms <= outerterms);
1818 if( nterms == outerterms )
1821 else if( breakearly &&
SCIPisGT(scip, path[k].dist, maxprize) )
1827 for(
int e = g->
outbeg[k]; e >= 0; e = g->
oeat[e] )
1829 const int m = g->
head[e];
1836 if( !connected[m] && path[m].dist > (path[k].dist + cost[e]) && g->
mark[m] )
1863 assert(path !=
NULL);
1865 assert(cost !=
NULL);
1866 assert(connected !=
NULL);
1874 *extensions =
FALSE;
1881 for(
int k = 0; k <
nnodes; k++ )
1905 if( prize[k] > maxprize )
1906 maxprize = prize[k];
1912 if( nnodes > 1 && nstnodes > 0 )
1932 connected[k] =
TRUE;
1935 assert(path[k].edge >= 0);
1938 while( !connected[node] )
1940 assert(g->
mark[node]);
1941 assert(path[node].edge >= 0);
1942 connected[node] =
TRUE;
1944 assert(state[node]);
1952 assert(path[k].dist == 0.0);
1954 assert(nterms <= outermscount);
1957 if( nterms == outermscount )
1960 else if( path[k].dist > maxprize )
1966 for(
int e = g->
outbeg[k]; e >= 0; e = g->
oeat[e] )
1968 const int m = g->
head[e];
1975 if( path[m].dist > (path[k].dist + cost[e]) && g->
mark[m] )
1991 int* orderedprizes_id,
2005 .maxoutprize = -
FARAWAY, .maxoutprize_idx = -1};
2007 assert(g && cost && prize && pathdist && pathedge && connected);
2009 assert(start < g->knots);
2013 stRpcmwInit(g, pathdist, pathedge, connected, &nrterms);
2015 assert(nrterms >= 1);
2016 pathdist[start] = 0.0;
2017 connected[start] =
TRUE;
2024 int rtermscount = 0;
2030 heap[count] = start;
2031 state[start] = count;
2050 const int k =
nearestX(heap, state, &count, pathdist);
2060 assert(pathedge[k] != -1);
2077 connected[k] =
TRUE;
2082 while( !connected[node = g->
tail[pathedge[node]]] )
2084 assert(pathedge[node] != -1);
2087 assert(g->
mark[node]);
2089 connected[node] =
TRUE;
2090 resetX(pathdist, heap, state, &count, node, 0.0);
2099 assert(termscount <= nterms);
2102 if( termscount == nterms )
2108 else if( rtermscount >= nrterms && pathdist[k] > spaths_pc.
maxoutprize )
2112 assert(rtermscount == nrterms);
2117 for(
int e = g->
outbeg[k]; e >= 0; e = g->
oeat[e] )
2119 const int head = g->
head[e];
2121 assert(state[head]);
2124 if( !connected[head] && g->
mark[head] && pathdist[head] > (pathdist[k] + cost[e]) )
2125 correctX(heap, state, &count, pathdist, pathedge, head, k, e, cost[e]);
2131 for(
int k = 0; k <
nnodes; k++ )
2135 assert(connected[k]);
2168 int numberTerminals;
2172 double smallestWeight;
2182 int* alreadyContained;
2190 assert( pathdist !=
NULL );
2191 assert( pathedge !=
NULL );
2192 assert( g !=
NULL );
2193 assert( start >= 0 );
2194 assert( start < g->knots );
2195 assert( prize !=
NULL );
2196 assert( connected !=
NULL );
2197 assert( g->
mark[start] );
2204 numberTerminals = g->
terms;
2205 newBudget = budget - nodebudget[start];
2206 smallestWeight = 1.0;
2208 for(
int k = 0; k <
nnodes; k++ )
2211 if( (nodebudget[k] < 0.0) && g->
mark[k] )
2213 printf(
"all costs have to be non-negativ! \n");
2220 if( (nodeweight[k] < 0) && g->
mark[k] )
2221 smallestWeight = smallestWeight + ((-1.0) * nodeweight[k]);
2225 connected[start] =
TRUE;
2232 while( ( (alpha >= 0.0) && (numberTerminals > 0) ) || ( (alpha >= 0.0) && (newBudget >= 0.0) ) )
2242 if( numberTerminals > 0 )
2243 numberTerminals = g->
terms;
2247 for(
int k = 0; k <
nnodes; k++ )
2249 if( (k != start) && (numberTerminals > 0) )
2250 connected[k] =
FALSE;
2252 alreadyContained[k] =
FALSE;
2254 if( !g->
mark[k] && (numberTerminals > 0) )
2260 if( connected[k] && (numberTerminals <= 0) )
2271 if( g->
mark[start] &&
Is_term( g->
term[start] ) && (numberTerminals > 0) )
2276 for(
int k = 0; k <
nnodes; k++ )
2285 resetX(pathdist, heap, state, &count, k, 0.0 );
2288 if(
Is_term( g->
term[k] ) && (numberTerminals > 0) ){
2292 my[k] = nodeweight[k];
2295 if( numberTerminals <= 0 ){
2296 resetX(pathdist, heap, state, &count, k, pathdist[k] );
2312 lookNeighbour =
TRUE;
2318 int k =
nearestX( heap, state, &count, pathdist );
2319 alreadyContained[k] =
TRUE;
2322 lookNeighbour =
TRUE;
2329 if( ( numberTerminals > 0 ) && !connected[k] &&
Is_term( g->
term[k] ) && g->
mark[k] )
2332 lookNeighbour =
FALSE;
2336 if( ( newBudget - pi[k] ) < 0.0 )
2338 alpha = alpha - 0.1;
2359 newBudget = newBudget - pi[k];
2361 while( !connected[v] )
2363 connected[v] =
TRUE;
2366 if( pathedge[v] != -1 )
2367 v = g->
tail[pathedge[v]];
2372 numberTerminals = numberTerminals - 1;
2381 for(
int n = 0; n <
nnodes; n++ )
2385 alreadyContained[n] =
FALSE;
2390 resetX(pathdist, heap, state, &count, n, 0.0);
2401 my[n] = nodeweight[n];
2408 if( numberTerminals == 0 )
2416 const int head = g->
head[e];
2417 assert( state[head] );
2424 if( g->
mark[head] && !connected[head] && ( ( numberTerminals > 0 && pathedge[head]==-1 ) || !alreadyContained[head] ) )
2427 int isConnected =
TRUE;
2429 double possibleUtility;
2430 if(
Is_term( g->
term[head] ) && (numberTerminals > 0) )
2434 possibleUtility = ( 1.0 - alpha ) * ( pi[k] + nodebudget[head] ) + ( alpha * ( pi[k] + nodebudget[head] ) /( my[k] + 1.0 ) );
2437 possibleUtility = ( 1.0 - alpha ) * ( pi[k] + nodebudget[head] ) + ( alpha * ( pi[k] + nodebudget[head] ) / ( ( my[k] + smallestWeight ) / smallestWeight ) );
2441 if( ( my[k] + nodeweight[head] ) >= 0.0 )
2443 possibleUtility = ( 1.0 - alpha ) * ( pi[k] + nodebudget[head] )
2444 + ( alpha * ( pi[k] + nodebudget[head] ) / ( my[k] + nodeweight[head] + 1.0 ) );
2447 possibleUtility = ( 1.0 - alpha ) * ( pi[k] + nodebudget[head] )
2448 + ( alpha * ( pi[k] + nodebudget[head] ) / ( ( my[k] + nodeweight[head] + smallestWeight ) / smallestWeight ) );
2452 while( !connected[j] && isConnected && ( pathedge[j] != -1 ) )
2455 isConnected =
FALSE;
2457 if( pathedge[j] != -1 )
2458 j = g->
tail[pathedge[j]];
2463 if( ( pathdist[head] > possibleUtility ) && isConnected )
2465 pi[head] = pi[k] + nodebudget[head];
2474 my[head] = my[k] + nodeweight[head];
2476 correctX( heap, state, &count, pathdist, pathedge, head, k, e, (-1.0) * pathdist[k] + possibleUtility );
2483 if( numberTerminals <= 0 && lookNeighbour )
2485 int foundVertex =
FALSE;
2488 for(
int n = 0; n <
nnodes; n++ )
2490 if( !connected[n] && g->
mark[n] )
2491 resetX(pathdist, heap, state, &count, n, pathdist[n]);
2495 while( count > 0 && !foundVertex )
2498 int n =
nearestX( heap, state, &count, pathdist );
2503 if( g->
mark[n] && ( newBudget - pi[n] >= 0.0 ) && ( my[n] > 0.0 ) )
2509 newBudget = newBudget - pi[n];
2512 while( !connected[v] )
2515 connected[v] =
TRUE;
2516 if( pathedge[v] != -1 )
2517 v = g->
tail[ pathedge[v] ];
2523 alpha = alpha - 0.1;
int graph_get_nEdges(const GRAPH *)
static volatile int nterms
SCIP_Bool graph_pc_isMw(const GRAPH *)
SCIP_Bool graph_pc_isRootedPcMw(const GRAPH *)
#define SCIPfreeMemoryArrayNull(scip, ptr)
Shortest path based algorithms for Steiner problems.
#define SCIPallocMemoryArray(scip, ptr, num)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
includes methods for Steiner tree problem solutions
void graph_knot_printInfo(const GRAPH *, int)
SCIP_RETCODE graph_path_init(SCIP *scip, GRAPH *g)
void graph_path_exec(SCIP *scip, const GRAPH *g, int mode, int start, const SCIP_Real *cost, PATH *path)
enum SCIP_Retcode SCIP_RETCODE
includes various files containing graph methods used for Steiner tree problems
void graph_heap_clean(SCIP_Bool, DHEAP *)
static int nearestX(int *RESTRICT heap, int *RESTRICT state, int *RESTRICT count, const SCIP_Real *pathdist)
#define SCIPfreeBufferArray(scip, ptr)
static void correctX(int *RESTRICT heap, int *RESTRICT state, int *RESTRICT count, SCIP_Real *RESTRICT pathdist, int *RESTRICT pathedge, int l, int k, int e, SCIP_Real cost)
SCIP_Real * node_distance
void graph_path_execX(SCIP *scip, const GRAPH *g, int start, const SCIP_Real *cost, SCIP_Real *pathdist, int *pathedge)
static void stPcmwConnectNode(int k, const GRAPH *g, SPATHSPC *spaths_pc, SCIP_Real *pathdist, int *pathedge, STP_Bool *connected, int *count, int *nterms)
void graph_path_st_pcmw_extendOut(SCIP *scip, const GRAPH *g, int start, STP_Bool *connected, SCIP_Real *dist, int *pred, STP_Bool *connected_out, DHEAP *dheap, SCIP_Bool *success)
static void stRpcmwInit(GRAPH *g, SCIP_Real *pathdist, int *pathedge, STP_Bool *connected, int *nrealterms)
void graph_path_st_pcmw_reduce(SCIP *scip, const GRAPH *g, const SCIP_Real *cost, SCIP_Real *tmpnodeweight, int *result, int start, STP_Bool *connected)
void shortestpath_pcReset(SPATHSPC *sppc)
SCIP_Bool graph_path_exists(const GRAPH *g)
static int pathheapGetNearest(int *RESTRICT heap, int *RESTRICT state, int *RESTRICT count, const PATH *path)
void graph_path_exit(SCIP *scip, GRAPH *g)
SCIP_Real * orderedprizes
static void stPcmwInit(GRAPH *g, SCIP_Real *pathdist, int *pathedge, STP_Bool *connected, int *npseudoterms)
SCIP_RETCODE graph_path_st_dc(SCIP *scip, const GRAPH *g, const SCIP_Real *cost, SCIP_Real *pathdist, int *pathedge, int start, STP_Bool *connected, int *result, STP_Bool *solFound)
void graph_path_st_pcmw_extendBiased(SCIP *scip, GRAPH *g, const SCIP_Real *cost, const SCIP_Real *prize, PATH *path, STP_Bool *connected, SCIP_Bool *extensions)
#define SCIPallocBufferArray(scip, ptr, num)
#define BMScopyMemoryArray(ptr, source, num)
void graph_pc_markOrgGraph(GRAPH *)
static void sdDcExtendTree(const GRAPH *g, const SCIP_Real *cost, int *heapsize, int *pathdeg_free, int *nodedeg_free, SCIP_Real *pathdist, int *pathedge, STP_Bool *connected, int *result, int *soldegfree, int *nsolterms)
SCIP_Bool graph_pc_knotIsNonLeafTerm(const GRAPH *, int)
SCIP_Bool graph_pc_isPc(const GRAPH *)
SCIP_Bool graph_typeIsUndirected(const GRAPH *)
void graph_path_st_pcmw_extend(SCIP *scip, const GRAPH *g, const SCIP_Real *cost, SCIP_Bool breakearly, PATH *path, STP_Bool *connected, SCIP_Bool *extensions)
static SCIP_Bool stDcTermIsConnectable(const GRAPH *g, int term, const int *deg_free, const int *pathedge, const STP_Bool *connected)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool graph_pc_knotIsDummyTerm(const GRAPH *, int)
SCIP_Bool graph_pc_knotIsFixedTerm(const GRAPH *, int)
void graph_path_st_rpcmw(GRAPH *g, SCIP_Real *orderedprizes, int *orderedprizes_id, const SCIP_Real *cost, const SCIP_Real *prize, SCIP_Real *pathdist, int *pathedge, int start, STP_Bool *connected)
void graph_path_PcMwSd(SCIP *scip, const GRAPH *g, PATH *path, SCIP_Real *cost, SCIP_Real distlimit, int *pathmaxnode, int *heap, int *state, int *stateblock, int *memlbl, int *nlbl, int tail, int head, int limit)
SCIP_Bool graph_pc_isPcMw(const GRAPH *)
int graph_heap_deleteMinReturnNode(DHEAP *)
void graph_path_st_pcmw_full(GRAPH *g, const SCIP_Real *cost, SCIP_Real *pathdist, int *pathedge, int start, STP_Bool *connected)
void graph_path_st_pcmw(GRAPH *g, SCIP_Real *orderedprizes, int *orderedprizes_id, const SCIP_Real *cost, const SCIP_Real *prize, SCIP_Bool costIsBiased, SCIP_Real *pathdist, int *pathedge, int start, STP_Bool *connected)
void graph_sdPaths(const GRAPH *g, PATH *path, const SCIP_Real *cost, SCIP_Real distlimit, int *heap, int *state, int *memlbl, int *nlbl, int tail, int head, int limit)
int graph_get_nNodes(const GRAPH *)
void shortestpath_pcConnectNode(const GRAPH *g, const STP_Bool *connected, int node_connected, SPATHSPC *sppc)
SCIP_Bool graph_knot_isInRange(const GRAPH *, int)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static void pathheapCorrect(int *RESTRICT heap, int *RESTRICT state, int *RESTRICT count, PATH *RESTRICT path, int l, int k, int edge, SCIP_Real cost, int mode)
includes (inline) graph heap methods used for Steiner tree problems
void graph_pathInLimitedExec(const GRAPH *g, const SCIP_Real *edges_cost, const SCIP_Bool *nodes_abort, int startnode, DIJK *dijkdata, SCIP_Real *abortdistance)
static void resetX(SCIP_Real *RESTRICT pathdist, int *RESTRICT heap, int *RESTRICT state, int *RESTRICT count, int node, SCIP_Real distnew)
void graph_path_invroot(SCIP *scip, const GRAPH *g, int start, const SCIP_Real *cost, SCIP_Real *pathdist, int *pathedge)
void graph_pathHeapAdd(const PATH *path, int node, int *RESTRICT heap, int *RESTRICT state, int *count)
SCIP_RETCODE graph_path_st_brmwcs(SCIP *scip, GRAPH *g, const SCIP_Real *prize, SCIP_Real *pathdist, int *pathedge, int start, STP_Bool *connected, SCIP_Bool *solfound)
void graph_path_st(const GRAPH *g, const SCIP_Real *cost, SCIP_Real *pathdist, int *pathedge, int start, STP_Bool *connected)
void graph_heap_correct(int, SCIP_Real, DHEAP *)
static void pathheapReset(PATH *RESTRICT path, int *RESTRICT heap, int *RESTRICT state, int *RESTRICT count, int node)