Scippy

SCIP

Solving Constraint Integer Programs

reduce_sdutil.c File Reference

Detailed Description

utility methods for Steiner tree reductions

Author
Daniel Rehfeldt

This file implements utility methods for Steiner tree problem special distance reduction techniques.

A list of all interface methods can be found in reduce.h.

Definition in file reduce_sdutil.c.

#include "reduce.h"
#include "portab.h"

Go to the source code of this file.

Data Structures

struct  special_distance_neighbors
 

Macros

#define STP_SDN_NCLOSETERMS   4
 
#define STP_SDN_MAXDEGREE   4
 
#define STP_SDN_MAXNVISITS   4
 

Functions

static void sdgraphInsertEdge (SCIP *scip, int term1, int term2, SCIP_Real edgecost, SDGRAPH *sdgraph)
 
static SCIP_RETCODE sdprofitAlloc (SCIP *scip, const GRAPH *g, SCIP_Bool useSecond, SDPROFIT **sdprofit)
 
static void sdprofitBuild (const GRAPH *g, SDPROFIT *sdprofit)
 
static void sdprofitBuild1stOnly (const GRAPH *g, const SCIP_Real *edgecosts, SDPROFIT *sdprofit)
 
static void sdprofitUpdateNode (const GRAPH *g, int node, int sourceterm, SCIP_Real edgecost, SCIP_Real bdist, SCIP_Bool blctree_isUpdated, SDPROFIT *sdprofit)
 
static SCIP_RETCODE sdneighborMarkCloseNodes (SCIP *scip, const GRAPH *g, int sourcenode, SD *sddata)
 
static SCIP_RETCODE sdneighborUpdateInit (SCIP *scip, GRAPH *g, SDN *sdn)
 
static void sdneighborUpdateFree (SCIP *scip, GRAPH *g, SDN *sdn)
 
static void sdneighborUpdateNode (SCIP *scip, const GRAPH *g, int node, int term, SDN *sdn, SDGRAPH *sdgraph, int *nupdates)
 
static SCIP_RETCODE sdneighborUpdateExec (SCIP *scip, GRAPH *g, SD *sddata, int *nupdates)
 
static SCIP_RETCODE sdneighborUpdate (SCIP *scip, GRAPH *g, SD *sddata, int *nupdates)
 
SCIP_RETCODE reduce_sdInit (SCIP *scip, GRAPH *g, SD **sd)
 
SCIP_RETCODE reduce_sdInitBiased (SCIP *scip, GRAPH *g, SD **sd)
 
SCIP_RETCODE reduce_sdInitBiasedBottleneck (SCIP *scip, GRAPH *g, SD **sd)
 
SCIP_RETCODE reduce_sdRepair (SCIP *scip, int edge, SCIP_Bool withEdgeReplacement, GRAPH *g, SD *sd)
 
SCIP_RETCODE reduce_sdRepairSetUp (SCIP *scip, const GRAPH *g, SD *sd)
 
SCIP_RETCODE reduce_sdAddNeighborSd (SCIP *scip, const GRAPH *g, SD *sd)
 
void reduce_sdFree (SCIP *scip, SD **sd)
 
const SCIP_Boolreduce_sdneighborGetBlocked (const SDN *sdneighbors)
 
void reduce_sdneighborGetCloseTerms (const GRAPH *g, const SDN *sdneighbor, int node, SCIP_Real maxdist_strict, int *RESTRICT closeterms, SCIP_Real *RESTRICT closeterms_dist, int *RESTRICT ncloseterms)
 
SCIP_RETCODE reduce_sdneighborInit (SCIP *scip, const GRAPH *g, SDN **sdn)
 
void reduce_sdneighborFree (SCIP *scip, SDN **sdn)
 
SCIP_RETCODE reduce_sdUpdateWithSdNeighbors (SCIP *scip, GRAPH *g, SD *sddata, int *nupdates)
 
SCIP_RETCODE reduce_sdprofitInit (SCIP *scip, const GRAPH *g, SDPROFIT **sdprofit)
 
SCIP_RETCODE reduce_sdprofitInit1stOnly (SCIP *scip, const GRAPH *g, const SCIP_Real *edgecosts, SDPROFIT **sdprofit)
 
void reduce_sdprofitPrintStats (const GRAPH *g, const SDPROFIT *sdprofit)
 
void reduce_sdprofitFree (SCIP *scip, SDPROFIT **sdprofit)
 
SCIP_RETCODE reduce_sdprofitUpdateFromBLC (SCIP *scip, const GRAPH *g, const BLCTREE *blctree, SCIP_Bool blctree_isUpdated, SDPROFIT *sdprofit)
 
SCIP_RETCODE reduce_sdprofitBuildFromBLC (SCIP *scip, const GRAPH *g, const BLCTREE *blctree, SCIP_Bool blctree_isUpdated, SDPROFIT *sdprofit)
 

Macro Definition Documentation

◆ STP_SDN_NCLOSETERMS

#define STP_SDN_NCLOSETERMS   4

Definition at line 32 of file reduce_sdutil.c.

Referenced by reduce_sdneighborInit().

◆ STP_SDN_MAXDEGREE

#define STP_SDN_MAXDEGREE   4

Definition at line 33 of file reduce_sdutil.c.

Referenced by sdneighborUpdateExec().

◆ STP_SDN_MAXNVISITS

#define STP_SDN_MAXNVISITS   4

Definition at line 34 of file reduce_sdutil.c.

Referenced by sdneighborUpdateInit().

Function Documentation

◆ sdgraphInsertEdge()

static void sdgraphInsertEdge ( SCIP scip,
int  term1,
int  term2,
SCIP_Real  edgecost,
SDGRAPH sdgraph 
)
inlinestatic

inserts new edge

Parameters
scipSCIP data structure
term1end node 1
term2end node 2
edgecostcost
sdgraphthe SD graph

Definition at line 62 of file reduce_sdutil.c.

References NULL, reduce_sdgraphGetOrgnodesToSdMap(), reduce_sdgraphInsertEdge(), and SCIP_Bool.

Referenced by sdneighborUpdateNode().

◆ sdprofitAlloc()

static SCIP_RETCODE sdprofitAlloc ( SCIP scip,
const GRAPH g,
SCIP_Bool  useSecond,
SDPROFIT **  sdprofit 
)
static

◆ sdprofitBuild()

◆ sdprofitBuild1stOnly()

static void sdprofitBuild1stOnly ( const GRAPH g,
const SCIP_Real edgecosts,
SDPROFIT sdprofit 
)
static

◆ sdprofitUpdateNode()

static void sdprofitUpdateNode ( const GRAPH g,
int  node,
int  sourceterm,
SCIP_Real  edgecost,
SCIP_Real  bdist,
SCIP_Bool  blctree_isUpdated,
SDPROFIT sdprofit 
)
inlinestatic

updates implied profits by using exact bottleneck distances

Parameters
ggraph
nodethe node to update
sourcetermthe source terminal
edgecostedge cost
bdistbottleneck distance
blctree_isUpdatedBLC tree fresh?
sdprofitthe SD profit

Definition at line 333 of file reduce_sdutil.c.

References FARAWAY, GE, graph_tpathsGet4CloseTerms(), GT, Is_term, LE, special_distance_implied_profit::nodes_bias, special_distance_implied_profit::nodes_bias2, special_distance_implied_profit::nodes_biassource, special_distance_implied_profit::nodes_biassource2, special_distance_neighbors::nodes_maxdist, special_distance_neighbors::nodes_nhits, NULL, SCIP_Real, GRAPH::term, and special_distance_storage::terminalpaths.

Referenced by reduce_sdprofitUpdateFromBLC().

◆ sdneighborMarkCloseNodes()

static SCIP_RETCODE sdneighborMarkCloseNodes ( SCIP scip,
const GRAPH g,
int  sourcenode,
SD sddata 
)
inlinestatic

marks nodes that can be reached from given source node

Parameters
scipSCIP data structure
ggraph to initialize from
sourcenode(neighbor) node to mark from
sddataSD

Definition at line 419 of file reduce_sdutil.c.

References special_distance_neighbors::dijkdata, EQ, graph_dijkLimited_reset(), graph_sdCloseNodesBiased(), GT, special_distance_neighbors::hitlist, special_distance_neighbors::nnodesHit, special_distance_neighbors::nodes_maxdist, special_distance_neighbors::nodes_nhits, SCIP_CALL, SCIP_OKAY, SCIP_Real, special_distance_storage::sdneighbors, and special_distance_storage::sdprofit.

Referenced by sdneighborUpdateExec().

◆ sdneighborUpdateInit()

◆ sdneighborUpdateFree()

static void sdneighborUpdateFree ( SCIP scip,
GRAPH g,
SDN sdn 
)
static

◆ sdneighborUpdateNode()

static void sdneighborUpdateNode ( SCIP scip,
const GRAPH g,
int  node,
int  term,
SDN sdn,
SDGRAPH sdgraph,
int *  nupdates 
)
inlinestatic

updates single node

Parameters
scipSCIP
ggraph to initialize from
nodenode to update
termterminal
sdnSD neighbors
sdgraphSD graph
nupdatesnumber of distance updates

Definition at line 540 of file reduce_sdutil.c.

References special_distance_neighbors::closeterms_distN, special_distance_neighbors::closetermsN, FARAWAY, GT, Is_term, GRAPH::knots, LT, special_distance_neighbors::N, nnodes, special_distance_neighbors::nodes_isBlocked, special_distance_neighbors::nodes_maxdist, reduce_sdgraphGetSd(), SCIP_Real, sdgraphInsertEdge(), GRAPH::term, and TRUE.

Referenced by sdneighborUpdateExec().

◆ sdneighborUpdateExec()

◆ sdneighborUpdate()

static SCIP_RETCODE sdneighborUpdate ( SCIP scip,
GRAPH g,
SD sddata,
int *  nupdates 
)
static

updates SDs by using neighbor argument

Parameters
scipSCIP
ggraph to initialize from
sddataSD
nupdatesnumber of distance updates

Definition at line 670 of file reduce_sdutil.c.

References special_distance_graph::mstcosts, reduce_sdgraphMstBuild(), reduce_sdgraphMstSortCosts(), SCIP_CALL, SCIP_OKAY, special_distance_storage::sdgraph, special_distance_storage::sdneighbors, sdneighborUpdateExec(), sdneighborUpdateFree(), sdneighborUpdateInit(), and GRAPH::terms.

Referenced by reduce_sdUpdateWithSdNeighbors().

◆ reduce_sdInit()

◆ reduce_sdInitBiased()

◆ reduce_sdInitBiasedBottleneck()

◆ reduce_sdRepair()

SCIP_RETCODE reduce_sdRepair ( SCIP scip,
int  edge,
SCIP_Bool  withEdgeReplacement,
GRAPH g,
SD sd 
)

repairs SD structure for imminent edge elimination

Parameters
scipSCIP
edgeedge to be deleted soon
withEdgeReplacementwith edge replacement?
ggraph NOTE: will mark the graph, thus not const :( terrible design
sdto be repaired

Definition at line 811 of file reduce_sdutil.c.

References GRAPH::cost, EQ, FARAWAY, flipedge, graph_edge_isInRange(), graph_tpathsRepair(), special_distance_storage::hasNeigborUpdate, special_distance_storage::isBiased, reduce_sdgraphEdgeIsInMst(), reduce_sdgraphFree(), reduce_sdgraphInit(), reduce_sdgraphInitOrderedMstCosts(), SCIP_CALL, SCIP_OKAY, SCIP_Real, special_distance_storage::sdgraph, special_distance_storage::sdneighbors, special_distance_storage::sdprofit, and special_distance_storage::terminalpaths.

Referenced by removeEdge(), replaceEdgeByPath(), and testSdRepair().

◆ reduce_sdRepairSetUp()

SCIP_RETCODE reduce_sdRepairSetUp ( SCIP scip,
const GRAPH g,
SD sd 
)

sets up SD repairing mechanism

Parameters
scipSCIP
ggraph
sdto be repaired

Definition at line 853 of file reduce_sdutil.c.

References graph_tpathsRepairSetUp(), SCIP_CALL, SCIP_OKAY, and special_distance_storage::terminalpaths.

Referenced by extreduce_deleteArcs(), extreduce_deleteEdges(), extreduce_deleteGeneralStars(), reduce_termsepaDa(), and testSdRepair().

◆ reduce_sdAddNeighborSd()

SCIP_RETCODE reduce_sdAddNeighborSd ( SCIP scip,
const GRAPH g,
SD sd 
)

adds biased neighbor SD structure

Parameters
scipSCIP
ggraph
sdto add to

Definition at line 868 of file reduce_sdutil.c.

References special_distance_storage::hasNeigborUpdate, reduce_sdneighborInit(), SCIP_CALL, SCIP_OKAY, special_distance_storage::sdneighbors, and TRUE.

Referenced by testSdBiasedDeletesEdge().

◆ reduce_sdFree()

◆ reduce_sdneighborGetBlocked()

const SCIP_Bool* reduce_sdneighborGetBlocked ( const SDN sdneighbors)

get blocked nodes

Definition at line 915 of file reduce_sdutil.c.

References special_distance_neighbors::nodes_isBlocked.

Referenced by reduce_sdBiasedNeighbor(), and reduce_sdImpLongEdge().

◆ reduce_sdneighborGetCloseTerms()

void reduce_sdneighborGetCloseTerms ( const GRAPH g,
const SDN sdneighbor,
int  node,
SCIP_Real  maxdist_strict,
int *RESTRICT  closeterms,
SCIP_Real *RESTRICT  closeterms_dist,
int *RESTRICT  ncloseterms 
)

gets (up to) four close terminals to given node i; with strict upper bound on allowed distances

Parameters
ggraph data structure
sdneighborSD neighbor data structure
nodenode
maxdist_strictmaximum valid distance (strict)
closetermsfour close terminals
closeterms_distfour close terminal distance
nclosetermsnumber of close terminals found

Definition at line 926 of file reduce_sdutil.c.

References special_distance_neighbors::closeterms_distN, special_distance_neighbors::closetermsN, GE, graph_get_nNodes(), graph_knot_isInRange(), LT, special_distance_neighbors::N, nnodes, nterms, and SCIP_Real.

◆ reduce_sdneighborInit()

◆ reduce_sdneighborFree()

void reduce_sdneighborFree ( SCIP scip,
SDN **  sdn 
)

frees SDN

Parameters
scipSCIP
sdnSD neighbors

Definition at line 1000 of file reduce_sdutil.c.

References SCIPfreeMemory, and SCIPfreeMemoryArray.

Referenced by reduce_sdFree().

◆ reduce_sdUpdateWithSdNeighbors()

SCIP_RETCODE reduce_sdUpdateWithSdNeighbors ( SCIP scip,
GRAPH g,
SD sddata,
int *  nupdates 
)

updates SDs by using neighbor argument NOTE: invalidates certain SD routines!

Parameters
scipSCIP
ggraph to initialize from
sddataSD
nupdatesnumber of distance updates

Definition at line 1015 of file reduce_sdutil.c.

References SCIP_OKAY, special_distance_storage::sdneighbors, and sdneighborUpdate().

Referenced by reduce_sdBiasedNeighbor().

◆ reduce_sdprofitInit()

SCIP_RETCODE reduce_sdprofitInit ( SCIP scip,
const GRAPH g,
SDPROFIT **  sdprofit 
)

initializes SD profit

Parameters
scipSCIP
ggraph to initialize from
sdprofitthe SD profit

Definition at line 1032 of file reduce_sdutil.c.

References SCIP_CALL, SCIP_OKAY, sdprofitAlloc(), sdprofitBuild(), and TRUE.

Referenced by prInit(), reduce_sdEdgeCliqueStar(), reduce_sdInitBiased(), reduce_sdInitBiasedBottleneck(), reduce_sdStarBiased(), testBiasedTerminalPathsTo4NextFound(), and testSdGraphStrongBiasedDistsAreValid().

◆ reduce_sdprofitInit1stOnly()

SCIP_RETCODE reduce_sdprofitInit1stOnly ( SCIP scip,
const GRAPH g,
const SCIP_Real edgecosts,
SDPROFIT **  sdprofit 
)

initializes SD profit

Parameters
scipSCIP
ggraph to initialize from
edgecostsedge costs (w.r.t graph 'g')
sdprofitthe SD profit

Definition at line 1048 of file reduce_sdutil.c.

References FALSE, SCIP_CALL, SCIP_OKAY, sdprofitAlloc(), and sdprofitBuild1stOnly().

Referenced by pseudodeleteBiasedIsPromising(), and tmBaseInit().

◆ reduce_sdprofitPrintStats()

void reduce_sdprofitPrintStats ( const GRAPH g,
const SDPROFIT sdprofit 
)

prints SD profit statistics

Parameters
ggraph to initialize from
sdprofitthe SD profit

Definition at line 1065 of file reduce_sdutil.c.

References graph_get_nNodes(), GT, Is_term, nnodes, special_distance_implied_profit::nodes_bias, SCIP_Real, and GRAPH::term.

◆ reduce_sdprofitFree()

◆ reduce_sdprofitUpdateFromBLC()

SCIP_RETCODE reduce_sdprofitUpdateFromBLC ( SCIP scip,
const GRAPH g,
const BLCTREE blctree,
SCIP_Bool  blctree_isUpdated,
SDPROFIT sdprofit 
)

updates implied profits by using exact bottleneck distances

Parameters
scipSCIP
ggraph
blctreeBLC tree
blctree_isUpdatedBLC tree fresh?
sdprofitthe SD profit

Definition at line 1123 of file reduce_sdutil.c.

References GRAPH::cost, graph_edge_isInRange(), GRAPH::head, Is_term, LE, LT, reduce_blctreeGetMstBottlenecks(), reduce_blctreeGetMstEdges(), reduce_blctreeGetMstNedges(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, sdprofitUpdateNode(), GRAPH::tail, and GRAPH::term.

Referenced by reduce_sdInitBiasedBottleneck(), and reduce_sdprofitBuildFromBLC().

◆ reduce_sdprofitBuildFromBLC()

SCIP_RETCODE reduce_sdprofitBuildFromBLC ( SCIP scip,
const GRAPH g,
const BLCTREE blctree,
SCIP_Bool  blctree_isUpdated,
SDPROFIT sdprofit 
)

builds implied profits by using exact bottleneck distances

Parameters
scipSCIP
ggraph
blctreeBLC tree
blctree_isUpdatedBLC tree fresh?
sdprofitthe SD profit

Definition at line 1179 of file reduce_sdutil.c.

References reduce_sdprofitUpdateFromBLC(), SCIP_CALL, SCIP_OKAY, and sdprofitBuild().

Referenced by reduce_impliedProfitBased(), and reduce_impliedProfitBasedRpc().