reduce_sdgraph.c
Go to the documentation of this file.
20 * This file implements methods for Steiner tree problem special distance (bottleneck Steiner distance) graph.
28 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
91 SCIP_Real* lcatree_costs; /**< cost per node of binary tree used for LCA computation; of size 2|T| - 3 */
92 int* termToLcatreeNode; /**< node mapping from terminals (SD graph nodes) to binary LCA tree nodes */
93 int* lcatreeNodeToInds; /**< mapping from binary LCA tree nodes to RMQ/Full indices; of size |T| - 1 */
138 assert(termToLcatreeNode && lcatree && lcatree_costs && lcabuilder->lcatree && lcabuilder->termToLcatreeNode);
467 sdqueryRmqDfs(bnode.child1, lcatree, lcatree_costs, rmq_edgecosts, lcatreeNodeToRmq, rmq_count);
475 sdqueryRmqDfs(bnode.child2, lcatree, lcatree_costs, rmq_edgecosts, lcatreeNodeToRmq, rmq_count);
628 SCIP_CALL( SCIPallocMemoryArray(scip, &(sdgraph->rmq_sparseTable), (logrmqlength + 1) * rmqlength) );
731 SCIPdebugMessage("start indices: %d, %d \n", rmqindex_min, (rmqindex_max - (int) (1 << msbit)));
811 sdqueryFullDfs(bnode.child1, lcatree, nlcanodes, lcatree_costs, nodes_isVisited, uf, fullq_dists);
821 sdqueryFullDfs(bnode.child2, lcatree, nlcanodes, lcatree_costs, nodes_isVisited, uf, fullq_dists);
1082 const SCIP_Real profit_tail = reduce_sdprofitGetProfit(sdprofit, tail, vbase_head, vbase_tail);
1083 const SCIP_Real profit_head = reduce_sdprofitGetProfit(sdprofit, head, vbase_head, vbase_tail);
1110 const SCIP_Real profit_tail = reduce_sdprofitGetProfit(sdprofit, tail, vbase_head, vbase_tail);
1111 const SCIP_Real profit_head = reduce_sdprofitGetProfit(sdprofit, head, vbase_head, vbase_tail);
1151 graph_tpathsGet3CloseTerms(g, tpaths, tail, FARAWAY, terms_tail, NULL, dists_tail, &nterms_tail);
1152 graph_tpathsGet3CloseTerms(g, tpaths, head, FARAWAY, terms_head, NULL, dists_head, &nterms_head);
1161 distgraphGetBoundaryEdgeDist2(tail, head, terms_tail[i], terms_head[j], edgecost, dists_tail[i], dists_head[j], sdprofit);
1281 distgraphGetBoundaryEdgeDist(tail, head, vbase_tail, vbase_head, g->cost[e], nodes_vdist, sdprofit)
1285 // printf("distance: %f < %f \n", distance, g->cost[e] + nodes_vdist[tail] + nodes_vdist[head]);
1423 distgraphGetBoundaryEdgeDist2(tail, head, vbase_tail, vbase_head, g->cost[e], dist_tail, dist_head, sdprofit)
1429 distgraphInsertEdge(scip, distnodes_id[vbase_tail], distnodes_id[vbase_head], distance, -1, NULL, distgraph, &success);
1541 distance = distgraphGetBoundaryEdgeDistBest(g, tpaths, tail, head, g->cost[e], sdprofit, &vbase_tail, &vbase_head);
1543 /* NOTE: we should not take the fast query method here, because sdgraphGetSd at least partly reflects
1579 //SCIPdebugMessage("add biased MST edge %d->%d (%f<%f) \n", vbase_tail, vbase_head, distance, sdgraphGetSd(vbase_tail, vbase_head, g_sd));
1581 distgraphInsertEdge(scip, distnodes_id[vbase_tail], distnodes_id[vbase_head], distance, -1, NULL, distgraph, &success);
1856 /* NOTE probably we never need that...for extending reductions we anyway should only take biased paths */
2026 distgraphInsertEdge(scip, sdnode1, sdnode2, edgecost, edgeid, edgeorg, sdgraph->distgraph, success);
static SCIP_Real sdqueryFullGetSd(int term1, int term2, const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:749
static void sdqueryBuildRmq(SDGRAPH *sdgraph, LCABUILDER *lcabuilder)
Definition: reduce_sdgraph.c:539
SCIP_RETCODE SCIPStpunionfindInit(SCIP *scip, UF *uf, int length)
Definition: misc_stp.c:817
Definition: graphdefs.h:184
static SCIP_RETCODE sdqueryRmqInit(SCIP *scip, const GRAPH *g, SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:604
void reduce_sdgraphInitOrderedMstCosts(SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:1938
Definition: struct_scip.h:59
static SCIP_RETCODE sdqueryLcaBuilderInit(SCIP *scip, const SDGRAPH *sdgraph, LCABUILDER **lcabuilder)
Definition: reduce_sdgraph.c:272
struct lowest_common_ancestor_tree_builder LCABUILDER
void graph_tpathsGetClosestTerm(const GRAPH *, const TPATHS *, int, int *RESTRICT, int *RESTRICT, SCIP_Real *RESTRICT)
SCIP_RETCODE reduce_sdgraphMstBuild(SCIP *scip, const GRAPH *g, SDGRAPH *g_sd)
Definition: reduce_sdgraph.c:2032
void graph_path_exec(SCIP *, const GRAPH *, int, int, const SCIP_Real *, PATH *)
Definition: graph_path.c:541
SCIP_Real reduce_sdgraphGetMaxCost(const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:1867
static SCIP_RETCODE sdgraphUpdateDistgraphFromTpaths(SCIP *scip, const GRAPH *g, const SDPROFIT *sdprofit, const TPATHS *tpaths, SDGRAPH *g_sd)
Definition: reduce_sdgraph.c:1506
Definition: misc_stp.h:78
SCIP_Bool reduce_sdgraphHasOrderedMstCosts(const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:1924
const int * reduce_sdgraphGetOrgnodesToSdMap(const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:2001
Definition: graphdefs.h:326
Definition: graphdefs.h:284
void graph_tpathsGet3CloseTerms(const GRAPH *, const TPATHS *, int, SCIP_Real, int *RESTRICT, int *RESTRICT, SCIP_Real *RESTRICT, int *RESTRICT)
static void sdgraphMstMarkOrgEdges(const GRAPH *g, const VNOI *vnoi, const int *distedge2org, SDGRAPH *g_sd)
Definition: reduce_sdgraph.c:1644
static SCIP_Real distgraphGetBoundaryEdgeDistBest(const GRAPH *g, const TPATHS *tpaths, int tail, int head, SCIP_Real edgecost, const SDPROFIT *sdprofit, int *base_tail, int *base_head)
Definition: reduce_sdgraph.c:1127
static void sdqueryRmqDfs(int root, const BINARYNODE *lcatree, const SCIP_Real *lcatree_costs, SCIP_Real *rmq_edgecosts, int *lcatreeNodeToRmq, int *rmq_count)
Definition: reduce_sdgraph.c:444
void SCIPsortDownRealInt(SCIP_Real *realarray, int *intarray, int len)
static void sdgraphSetDefaults(const GRAPH *g, SDGRAPH *g_sd)
Definition: reduce_sdgraph.c:1304
SCIP_Real miscstp_maxReal(const SCIP_Real *realarr, unsigned nreals)
Definition: misc_stp.c:142
static int sdqueryGetRmqLength(const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:259
SCIP_RETCODE graph_vnoiCompute(SCIP *, const GRAPH *, VNOI *)
Definition: graph_vnoi.c:1302
struct binary_tree_node BINARYNODE
#define SCIPallocCleanBufferArray(scip, ptr, num)
Definition: scip_mem.h:133
void reduce_sdgraphInsertEdge(SCIP *scip, int sdnode1, int sdnode2, SCIP_Real edgecost, int edgeid, int *RESTRICT edgeorg, SDGRAPH *sdgraph, SCIP_Bool *success)
Definition: reduce_sdgraph.c:2015
static void sdgraphFinalize(SCIP *scip, VNOI **vnoi, int **edgeorg)
Definition: reduce_sdgraph.c:1747
Definition: reduce_sdgraph.c:80
Definition: reducedefs.h:135
miscellaneous methods used for solving Steiner problems
void graph_tpathsGetProfitNodes(SCIP *, const GRAPH *, const TPATHS *, const SDPROFIT *, int, int, STP_Vectype(int))
Definition: graph_tpath.c:1842
static SCIP_Real sdgraphGetSd(int term1, int term2, SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:165
static SCIP_RETCODE sdqueryInit(SCIP *scip, const GRAPH *g, SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:962
void reduce_sdgraphFreeFromDistGraph(SCIP *scip, SDGRAPH **sdgraph)
Definition: reduce_sdgraph.c:2080
static void sdqueryAttachBinaryTreeNode(const GRAPH *distgraph, int parentposition, int graphnode, LCABUILDER *lcabuilder, UF *uf)
Definition: reduce_sdgraph.c:333
SCIP_RETCODE reduce_sdgraphInitFromDistGraph(SCIP *scip, const GRAPH *g, GRAPH *distgraph, int *node2dist, SDGRAPH **sdgraph)
Definition: reduce_sdgraph.c:1788
static SCIP_Real distgraphGetBoundaryEdgeDist2(int tail, int head, int vbase_tail, int vbase_head, SCIP_Real edgecost, SCIP_Real dist_tail, SCIP_Real dist_head, const SDPROFIT *sdprofit)
Definition: reduce_sdgraph.c:1099
void graph_edge_add(SCIP *, GRAPH *, int, int, double, double)
static SCIP_RETCODE sdgraphBuildDistgraph(SCIP *scip, const GRAPH *g, const SDPROFIT *sdprofit, SDGRAPH *g_sd, VNOI **vnoi, int **distedge2org)
Definition: reduce_sdgraph.c:1439
static SCIP_RETCODE sdgraphMstBuild(SCIP *scip, const GRAPH *g, SDGRAPH *g_sd)
Definition: reduce_sdgraph.c:1691
Definition: type_retcode.h:33
void SCIPStpunionfindUnion(UF *uf, int p, int q, SCIP_Bool compress)
Definition: misc_stp.c:912
SCIP_RETCODE reduce_sdgraphInit(SCIP *scip, const GRAPH *g, SDGRAPH **sdgraph)
Definition: reduce_sdgraph.c:1764
SCIP_Real * lcatree_costs
Definition: reduce_sdgraph.c:91
Definition: reduce_sdgraph.c:46
static void distgraphAddNodes(const GRAPH *g, int *RESTRICT distnodes_id, GRAPH *distgraph)
Definition: reduce_sdgraph.c:1039
static void sdqueryLcaBuilderFree(SCIP *scip, LCABUILDER **lcabuilder)
Definition: reduce_sdgraph.c:315
static SCIP_Real reduce_sdprofitGetProfit(const SDPROFIT *sdprofit, int node, int nonsource1, int nonsource2)
Definition: reducedefs.h:178
static SCIP_RETCODE sdqueryBuildBinaryTree(SCIP *scip, SDGRAPH *sdgraph, LCABUILDER *lcabuilder)
Definition: reduce_sdgraph.c:379
static void sdqueryBuildRmqSparseTable(SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:482
static SCIP_RETCODE sdgraphAlloc(SCIP *scip, const GRAPH *g, SDGRAPH **sdgraph)
Definition: reduce_sdgraph.c:1336
static SCIP_RETCODE sdqueryFullBuild(SCIP *scip, SDGRAPH *sdgraph, LCABUILDER *lcabuilder)
Definition: reduce_sdgraph.c:876
static SCIP_RETCODE sdgraphAllocRestricted(SCIP *scip, const GRAPH *g, SDGRAPH **sdgraph)
Definition: reduce_sdgraph.c:1365
static void distgraphInsertEdge(SCIP *scip, int sdnode1, int sdnode2, SCIP_Real edgecost, int edgeid, int *RESTRICT edgeorg, GRAPH *distgraph, SCIP_Bool *success)
Definition: reduce_sdgraph.c:1179
SCIP_Real reduce_sdgraphGetSd(int term1, int term2, SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:1958
const SCIP_Real * reduce_sdgraphGetOrderedMstCosts(const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:1989
SCIP_RETCODE graph_vnoiInit(SCIP *, const GRAPH *, SCIP_Bool, VNOI **)
Definition: graph_vnoi.c:1265
static void sdqueryBuildNodesToRmqMap(const GRAPH *g, const LCABUILDER *lcabuilder, SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:568
int * termToLcatreeNode
Definition: reduce_sdgraph.c:92
static SCIP_RETCODE sdgraphBuildDistgraphFromTpaths(SCIP *scip, const GRAPH *g, const SDPROFIT *sdprofit, const TPATHS *tpaths, SDGRAPH *g_sd)
Definition: reduce_sdgraph.c:1479
Portable definitions.
const STP_Bool * reduce_sdgraphGetMstHalfMark(const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:1879
SCIP_Bool reduce_sdgraphHasMstHalfMark(const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:1891
static void sdqueryBuildNodesToFullMap(const GRAPH *g, const LCABUILDER *lcabuilder, SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:650
void reduce_sdgraphFree(SCIP *scip, SDGRAPH **sdgraph)
Definition: reduce_sdgraph.c:2055
SCIP_Bool reduce_sdgraphEdgeIsInMst(const SDGRAPH *sdgraph, int edge)
Definition: reduce_sdgraph.c:1909
static SCIP_RETCODE sdqueryFullInit(SCIP *scip, const GRAPH *g, SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:919
void reduce_sdgraphMstSortCosts(SDGRAPH *g_sd)
Definition: reduce_sdgraph.c:2046
static void sdqueryFullDfs(int root, const BINARYNODE *lcatree, int nlcanodes, const SCIP_Real *lcatree_costs, SCIP_Bool *RESTRICT nodes_isVisited, UF *uf, SCIP_Real *RESTRICT fullq_dists)
Definition: reduce_sdgraph.c:787
int * lcatreeNodeToInds
Definition: reduce_sdgraph.c:93
SCIP_RETCODE reduce_sdgraphInitBiasedFromTpaths(SCIP *scip, GRAPH *g, const SDPROFIT *sdprofit, const TPATHS *tpaths, SDGRAPH **sdgraph)
Definition: reduce_sdgraph.c:1836
static void distgraphAddEdgesFromTpaths(SCIP *scip, const GRAPH *g, const int *distnodes_id, const SDPROFIT *sdprofit, const TPATHS *tpaths, GRAPH *distgraph)
Definition: reduce_sdgraph.c:1392
SCIP_RETCODE graph_vnoiComputeImplied(SCIP *, const GRAPH *, const SDPROFIT *, VNOI *)
Definition: graph_vnoi.c:1323
static SCIP_Real distgraphGetBoundaryEdgeDist(int tail, int head, int vbase_tail, int vbase_head, SCIP_Real edgecost, const SCIP_Real *nodes_vdist, const SDPROFIT *sdprofit)
Definition: reduce_sdgraph.c:1072
static SCIP_Real sdqueryGetSd(int term1, int term2, const SDGRAPH *sdgraph)
Definition: reduce_sdgraph.c:686
Definition: objbenders.h:33
void SCIPStpunionfindFreeMembers(SCIP *scip, UF *uf)
Definition: misc_stp.c:955
includes various reduction methods for Steiner tree problems
void SCIPsortDownReal(SCIP_Real *realarray, int len)
static void distgraphAddEdges(SCIP *scip, const GRAPH *g, const int *distnodes_id, const VNOI *vnoi, const SDPROFIT *sdprofit, int *RESTRICT edgeorg, GRAPH *distgraph)
Definition: reduce_sdgraph.c:1246
SCIP_RETCODE reduce_sdgraphInitBiased(SCIP *scip, const GRAPH *g, const SDPROFIT *sdprofit, SDGRAPH **sdgraph)
Definition: reduce_sdgraph.c:1811
Definition: graph_tpath.c:61