Scippy

SCIP

Solving Constraint Integer Programs

shortestpath.c File Reference

Detailed Description

Shortest path based algorithms for Steiner problems.

Author
Daniel Rehfeldt

This file encompasses various shortest path based algorithms. Note: This file is supposed to replace graph_path.c in the long run, as it includes the faster implementations.

Definition in file shortestpath.c.

#include "reduce.h"
#include "shortestpath.h"
#include "portab.h"
#include "stpvector.h"

Go to the source code of this file.

Functions

static SCIP_Bool computeSteinerTree_allTermsAreReached (const GRAPH *g, const STP_Bool *connected)
 
static SCIP_Bool computeSteinerTree_allPseudoTermsAreReached (const GRAPH *g, const STP_Bool *connected)
 
static SCIP_Bool computeSteinerTree_allFixedTermsAreReached (const GRAPH *g, const STP_Bool *connected)
 
static void computeSteinerTree_init (const GRAPH *g, int startnode, SPATHS *spaths)
 
static void computeSteinerTree_connectTerminal (const GRAPH *g, int k, const int *nodes_pred, SCIP_Real *RESTRICT nodes_dist, DHEAP *dheap, STP_Bool *RESTRICT connected)
 
static void computeSteinerTree_connectNode (const GRAPH *g, int k, const int *nodes_pred, SCIP_Real *RESTRICT nodes_dist, DHEAP *dheap, int *termscount, STP_Bool *RESTRICT connected)
 
static void computeSteinerTree_exec (const GRAPH *g, int startnode, SPATHS *spaths)
 
static void computeSteinerTree_execDirected (SCIP *scip, const GRAPH *g, int startnode, SPATHS *spaths)
 
static void computeSteinerTree_execBiased (const GRAPH *g, const SDPROFIT *sdprofit, int startnode, SPATHS *spaths)
 
static void computeSteinerTree_connectPseudoTerm (const GRAPH *g, int k, const int *nodes_pred, SCIP_Real *RESTRICT nodes_dist, SPATHSPC *spaths_pc, DHEAP *dheap, STP_Bool *RESTRICT connected, int *RESTRICT nPseudoTerms)
 
static void computeSteinerTree_tryConnectNodePcMw (const GRAPH *g, int k, const SCIP_Real *prize, SCIP_Bool costIsBiased, const int *nodes_pred, SCIP_Real *RESTRICT nodes_dist, DHEAP *dheap, STP_Bool *RESTRICT connected, SPATHSPC *spaths_pc, SCIP_Bool *isConnected, int *RESTRICT nPseudoTerms)
 
static void computeSteinerTree_execPcMw (const GRAPH *g, int startnode, const SCIP_Real *prize, SCIP_Bool costIsBiased, SPATHSPC *spaths_pc, SPATHS *spaths)
 
static void computeSteinerTree_execRpcMw (const GRAPH *g, int startnode, const SCIP_Real *prize, SPATHSPC *spaths_pc, SPATHS *spaths)
 
static void computeSteinerTree_execPcMwFull (const GRAPH *g, int startnode, SPATHS *spaths)
 
SCIP_RETCODE shortestpath_pcInit (SCIP *scip, const GRAPH *graph, const SCIP_Real *costs, const SCIP_Real *prizes, SPATHSPC **sppc)
 
void shortestpath_pcFree (SCIP *scip, SPATHSPC **sppc)
 
void shortestpath_pcReset (SPATHSPC *sppc)
 
void shortestpath_pcConnectNode (const GRAPH *g, const STP_Bool *connected, int node_connected, SPATHSPC *sppc)
 
void shortestpath_computeSteinerTree (const GRAPH *g, int startnode, SPATHS *spaths)
 
void shortestpath_computeSteinerTreeDirected (SCIP *scip, const GRAPH *g, int startnode, SPATHS *spaths)
 
void shortestpath_computeSteinerTreeBiased (const GRAPH *g, const SDPROFIT *sdprofit, int startnode, SPATHS *spaths)
 
void shortestpath_computeSteinerTreePcMw (const GRAPH *g, int startnode, const SCIP_Real *prize, SCIP_Bool costIsBiased, SPATHSPC *spaths_pc, SPATHS *spaths)
 
void shortestpath_computeSteinerTreeRpcMw (const GRAPH *g, int startnode, const SCIP_Real *prize, SPATHSPC *spaths_pc, SPATHS *spaths)
 
void shortestpath_computeSteinerTreePcMwFull (const GRAPH *g, int startnode, SPATHS *spaths)
 

Function Documentation

◆ computeSteinerTree_allTermsAreReached()

static SCIP_Bool computeSteinerTree_allTermsAreReached ( const GRAPH g,
const STP_Bool connected 
)
static

all terminals reached?

Parameters
ggraph data structure
connectedarray to mark whether a vertex is part of computed Steiner tree

Definition at line 35 of file shortestpath.c.

References FALSE, graph_get_nNodes(), Is_term, nnodes, SCIPdebugMessage, GRAPH::term, and TRUE.

Referenced by shortestpath_computeSteinerTree(), shortestpath_computeSteinerTreeBiased(), and shortestpath_computeSteinerTreeDirected().

◆ computeSteinerTree_allPseudoTermsAreReached()

static SCIP_Bool computeSteinerTree_allPseudoTermsAreReached ( const GRAPH g,
const STP_Bool connected 
)
static

all pseudo terminals reached?

Parameters
ggraph data structure
connectedarray to mark whether a vertex is part of computed Steiner tree

Definition at line 57 of file shortestpath.c.

References FALSE, graph_get_nNodes(), graph_pc_isPcMw(), Is_pseudoTerm, nnodes, GRAPH::term, and TRUE.

Referenced by computeSteinerTree_execPcMw().

◆ computeSteinerTree_allFixedTermsAreReached()

static SCIP_Bool computeSteinerTree_allFixedTermsAreReached ( const GRAPH g,
const STP_Bool connected 
)
static

all fixed terminals reached?

Parameters
ggraph data structure
connectedarray to mark whether a vertex is part of computed Steiner tree

Definition at line 80 of file shortestpath.c.

References FALSE, graph_get_nNodes(), graph_pc_isPcMw(), graph_pc_knotIsFixedTerm(), nnodes, and TRUE.

Referenced by computeSteinerTree_execPcMwFull(), and computeSteinerTree_execRpcMw().

◆ computeSteinerTree_init()

◆ computeSteinerTree_connectTerminal()

static void computeSteinerTree_connectTerminal ( const GRAPH g,
int  k,
const int *  nodes_pred,
SCIP_Real *RESTRICT  nodes_dist,
DHEAP dheap,
STP_Bool *RESTRICT  connected 
)
inlinestatic

connects (also PC/MW potential) terminal to current tree

Parameters
ggraph data structure
kvertex to connect
nodes_predpredecessor array (on vertices)
nodes_distdistance array (on vertices)
dheapDijkstra heap
connectedarray to mark whether a vertex is part of computed Steiner tree

Definition at line 147 of file shortestpath.c.

References graph_heap_correct(), Is_pseudoTerm, Is_term, SCIPdebugMessage, GRAPH::term, and TRUE.

Referenced by computeSteinerTree_exec(), computeSteinerTree_execBiased(), and computeSteinerTree_execPcMwFull().

◆ computeSteinerTree_connectNode()

static void computeSteinerTree_connectNode ( const GRAPH g,
int  k,
const int *  nodes_pred,
SCIP_Real *RESTRICT  nodes_dist,
DHEAP dheap,
int *  termscount,
STP_Bool *RESTRICT  connected 
)
inlinestatic

connects node to current tree

Parameters
ggraph data structure
kvertex to connect
nodes_predpredecessor array (on vertices)
nodes_distdistance array (on vertices)
dheapDijkstra heap
termscountpointer for terminal count
connectedarray to mark whether a vertex is part of computed Steiner tree

Definition at line 182 of file shortestpath.c.

References graph_heap_correct(), Is_term, SCIPdebugMessage, GRAPH::term, and TRUE.

Referenced by computeSteinerTree_execDirected().

◆ computeSteinerTree_exec()

◆ computeSteinerTree_execDirected()

static void computeSteinerTree_execDirected ( SCIP scip,
const GRAPH g,
int  startnode,
SPATHS spaths 
)
inlinestatic

◆ computeSteinerTree_execBiased()

◆ computeSteinerTree_connectPseudoTerm()

static void computeSteinerTree_connectPseudoTerm ( const GRAPH g,
int  k,
const int *  nodes_pred,
SCIP_Real *RESTRICT  nodes_dist,
SPATHSPC spaths_pc,
DHEAP dheap,
STP_Bool *RESTRICT  connected,
int *RESTRICT  nPseudoTerms 
)
inlinestatic

connects node to current tree

Parameters
ggraph data structure
kvertex to connect
nodes_predpredecessor array (on vertices)
nodes_distdistance array (on vertices)
spaths_pcPC/MW shortest paths data
dheapDijkstra heap
connectedarray to mark whether a vertex is part of computed Steiner tree
nPseudoTermspointer

Definition at line 511 of file shortestpath.c.

References graph_heap_correct(), Is_pseudoTerm, Is_term, SCIPdebugMessage, shortestpath_pcConnectNode(), GRAPH::term, and TRUE.

Referenced by computeSteinerTree_tryConnectNodePcMw().

◆ computeSteinerTree_tryConnectNodePcMw()

static void computeSteinerTree_tryConnectNodePcMw ( const GRAPH g,
int  k,
const SCIP_Real prize,
SCIP_Bool  costIsBiased,
const int *  nodes_pred,
SCIP_Real *RESTRICT  nodes_dist,
DHEAP dheap,
STP_Bool *RESTRICT  connected,
SPATHSPC spaths_pc,
SCIP_Bool isConnected,
int *RESTRICT  nPseudoTerms 
)
inlinestatic

connects node to current tree

Parameters
ggraph data structure
kvertex to connect
prize(possibly biased) prize
costIsBiasedis cost biased?
nodes_predpredecessor array (on vertices)
nodes_distdistance array (on vertices)
dheapDijkstra heap
connectedarray to mark whether a vertex is part of computed Steiner tree
spaths_pcPC/MW shortest paths data
isConnectednode connected to tree?
nPseudoTermspointer

Definition at line 556 of file shortestpath.c.

References computeSteinerTree_connectPseudoTerm(), FALSE, FARAWAY, GE, graph_pc_isPc(), graph_pc_knotIsNonLeafTerm(), Is_pseudoTerm, LT, SCIP_Bool, SCIP_Real, and GRAPH::term.

Referenced by computeSteinerTree_execPcMw().

◆ computeSteinerTree_execPcMw()

◆ computeSteinerTree_execRpcMw()

◆ computeSteinerTree_execPcMwFull()

◆ shortestpath_pcInit()

SCIP_RETCODE shortestpath_pcInit ( SCIP scip,
const GRAPH graph,
const SCIP_Real costs,
const SCIP_Real prizes,
SPATHSPC **  sppc 
)

initializes

Parameters
scipSCIP data structure
graphgraph data structure
costscost for edges (might be negative for MWCS or RMWCS)
prizesprizes for all nodes
sppcPC/MW shortest path data

Definition at line 893 of file shortestpath.c.

References EAT_LAST, GRAPH::extended, FARAWAY, graph_get_nNodes(), graph_pc_isPcMw(), GRAPH::ieat, GRAPH::inpbeg, Is_pseudoTerm, nnodes, nterms, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocMemory, SCIPallocMemoryArray, SCIPsortDownRealInt(), STP_MWCSP, STP_RMWCSP, GRAPH::stp_type, GRAPH::term, and GRAPH::terms.

Referenced by runTmPcMW_mode().

◆ shortestpath_pcFree()

void shortestpath_pcFree ( SCIP scip,
SPATHSPC **  sppc 
)

frees

Parameters
scipSCIP data structure
sppcPC/MW shortest path data

Definition at line 964 of file shortestpath.c.

References SCIPfreeMemory, and SCIPfreeMemoryArray.

Referenced by runTmPcMW_mode().

◆ shortestpath_pcReset()

◆ shortestpath_pcConnectNode()

void shortestpath_pcConnectNode ( const GRAPH g,
const STP_Bool connected,
int  node_connected,
SPATHSPC sppc 
)

update maximum prize

Parameters
ggraph data structure
connectedarray to mark whether a vertex is part of computed Steiner tree
node_connectednode that is removed
sppcPC data

Definition at line 991 of file shortestpath.c.

References EQ, stortest_path_prizecollecting::maxoutprize, stortest_path_prizecollecting::maxoutprize_idx, stortest_path_prizecollecting::orderedprizes, stortest_path_prizecollecting::orderedprizes_id, and SCIP_Real.

Referenced by computeSteinerTree_connectPseudoTerm(), computeSteinerTree_execPcMw(), computeSteinerTree_execRpcMw(), graph_path_st_pcmw(), graph_path_st_rpcmw(), and stPcmwConnectNode().

◆ shortestpath_computeSteinerTree()

void shortestpath_computeSteinerTree ( const GRAPH g,
int  startnode,
SPATHS spaths 
)

shortest path based heuristic for computing a Steiner tree

Parameters
ggraph data structure
startnodestart vertex
spathsshortest paths data

Definition at line 1033 of file shortestpath.c.

References computeSteinerTree_allTermsAreReached(), computeSteinerTree_exec(), computeSteinerTree_init(), stortest_paths::csr, stortest_paths::dheap, graph_typeIsSpgLike(), GRAPH::knots, stortest_paths::nodes_dist, stortest_paths::nodes_isConnected, and stortest_paths::nodes_pred.

Referenced by computeSteinerTreeCsr(), and computeSteinerTreeKeyNodesCsr().

◆ shortestpath_computeSteinerTreeDirected()

void shortestpath_computeSteinerTreeDirected ( SCIP scip,
const GRAPH g,
int  startnode,
SPATHS spaths 
)

shortest path based heuristic for computing a Steiner tree

Parameters
scipSCIP data structure
ggraph data structure
startnodestart vertex
spathsshortest paths data

Definition at line 1055 of file shortestpath.c.

References computeSteinerTree_allTermsAreReached(), computeSteinerTree_execDirected(), computeSteinerTree_init(), stortest_paths::csr, stortest_paths::dheap, graph_typeIsDirected(), GRAPH::knots, stortest_paths::nodes_dist, stortest_paths::nodes_isConnected, stortest_paths::nodes_pred, SCIPdebugMessage, and GRAPH::source.

Referenced by computeSteinerTreeCsr().

◆ shortestpath_computeSteinerTreeBiased()

void shortestpath_computeSteinerTreeBiased ( const GRAPH g,
const SDPROFIT sdprofit,
int  startnode,
SPATHS spaths 
)

shortest path based heuristic for computing a Steiner tree

Parameters
ggraph data structure
sdprofitimplied profit data structure
startnodestart vertex
spathsshortest paths data

Definition at line 1081 of file shortestpath.c.

References computeSteinerTree_allTermsAreReached(), computeSteinerTree_execBiased(), computeSteinerTree_init(), stortest_paths::csr, stortest_paths::dheap, graph_typeIsSpgLike(), GRAPH::knots, stortest_paths::nodes_dist, stortest_paths::nodes_isConnected, and stortest_paths::nodes_pred.

Referenced by computeSteinerTreeCsr(), and computeSteinerTreeKeyNodesCsr().

◆ shortestpath_computeSteinerTreePcMw()

void shortestpath_computeSteinerTreePcMw ( const GRAPH g,
int  startnode,
const SCIP_Real prize,
SCIP_Bool  costIsBiased,
SPATHSPC spaths_pc,
SPATHS spaths 
)

shortest path based heuristic for computing a Steiner tree in PC/MW case

Parameters
ggraph data structure
startnodestart vertex
prize(possibly biased) prize
costIsBiasedis cost biased?
spaths_pcPC/MW shortest paths data
spathsshortest paths data

Definition at line 1104 of file shortestpath.c.

References computeSteinerTree_execPcMw(), computeSteinerTree_init(), stortest_paths::csr, stortest_paths::dheap, GRAPH::extended, graph_pc_isPcMw(), graph_pc_isRootedPcMw(), graph_pc_knotIsDummyTerm(), GRAPH::knots, stortest_paths::nodes_dist, stortest_paths::nodes_isConnected, and stortest_paths::nodes_pred.

Referenced by computeSteinerTreeDijkPcMw().

◆ shortestpath_computeSteinerTreeRpcMw()

void shortestpath_computeSteinerTreeRpcMw ( const GRAPH g,
int  startnode,
const SCIP_Real prize,
SPATHSPC spaths_pc,
SPATHS spaths 
)

shortest path based heuristic for computing a Steiner tree in rooted PC/MW case

Parameters
ggraph data structure
startnodestart vertex
prize(possibly biased) prize
spaths_pcPC/MW shortest paths data
spathsshortest paths data

Definition at line 1129 of file shortestpath.c.

References computeSteinerTree_execRpcMw(), computeSteinerTree_init(), stortest_paths::csr, stortest_paths::dheap, GRAPH::extended, graph_pc_isRootedPcMw(), graph_pc_knotIsDummyTerm(), GRAPH::knots, stortest_paths::nodes_dist, stortest_paths::nodes_isConnected, and stortest_paths::nodes_pred.

Referenced by computeSteinerTreeDijkPcMw().

◆ shortestpath_computeSteinerTreePcMwFull()

void shortestpath_computeSteinerTreePcMwFull ( const GRAPH g,
int  startnode,
SPATHS spaths 
)

shortest path based heuristic for computing a Steiner tree in PC/MW case that contains all (potential and fixed) terminals

Parameters
ggraph data structure
startnodestart vertex
spathsshortest paths data

Definition at line 1153 of file shortestpath.c.

References computeSteinerTree_execPcMwFull(), computeSteinerTree_init(), stortest_paths::csr, stortest_paths::dheap, GRAPH::extended, graph_pc_isPcMw(), graph_pc_knotIsDummyTerm(), GRAPH::knots, stortest_paths::nodes_dist, stortest_paths::nodes_isConnected, and stortest_paths::nodes_pred.

Referenced by computeSteinerTreeDijkPcMwFull().