Scippy

SCIP

Solving Constraint Integer Programs

graph_sub.c File Reference

Detailed Description

includes several methods for Steiner problem sub-graphs

Author
Daniel Rehfeldt

This file contains several basic methods to process subgraph of Steiner problem graphs.

Definition in file graph_sub.c.

#include "scip/misc.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "portab.h"
#include "graph.h"
#include "stpvector.h"

Go to the source code of this file.

Data Structures

struct  edge_transfer
 
struct  subgraph_extraction_insertion
 

Typedefs

typedef struct edge_transfer EDGETRANS
 

Functions

static void extractSubgraphGetSizeAndMap (const GRAPH *orggraph, SUBINOUT *subinout)
 
static void extractSubgraphAddNodes (const GRAPH *orggraph, SUBINOUT *subinout, GRAPH *subgraph)
 
static SCIP_RETCODE extractSubgraphInitHistory (SCIP *scip, GRAPH *orggraph, SCIP_Bool moveFixedEdges, GRAPH *subgraph)
 
static SCIP_RETCODE extractSubgraphAddEdge (SCIP *scip, SCIP_Bool useNewHistory, SCIP_Bool moveEdges, const EDGETRANS *edgetrans, GRAPH *source_graph, GRAPH *target_graph)
 
static void reinsertSubgraphAdaptSubToOrgMap (const GRAPH *subgraph, const GRAPH *orggraph, SUBINOUT *subinout)
 
static SCIP_RETCODE extractSubgraphAddEdgesWithHistory (SCIP *scip, GRAPH *orggraph, SUBINOUT *subinout, GRAPH *subgraph)
 
static void borderNodesCollect (SCIP *scip, const GRAPH *orggraph, const GRAPH *subgraph, SUBINOUT *subinout)
 
static SCIP_RETCODE borderNodesContract (SCIP *scip, const GRAPH *subgraph, SUBINOUT *subinout, GRAPH *orggraph)
 
static SCIP_RETCODE extractSubgraphBuild (SCIP *scip, GRAPH *orggraph, SUBINOUT *subinout, GRAPH **subgraph)
 
static void reinsertSubgraphTransferFixedHistory (SCIP *scip, GRAPH *subgraph, GRAPH *orggraph)
 
static SCIP_RETCODE reinsertSubgraphTransferEdges (SCIP *scip, GRAPH *subgraph, SUBINOUT *subinsertion, GRAPH *orggraph)
 
static SCIP_RETCODE reinsertSubgraphTransferTerminals (const GRAPH *subgraph, SUBINOUT *subinout, GRAPH *orggraph)
 
static SCIP_RETCODE reinsertSubgraphDeleteOldEdges (SCIP *scip, const GRAPH *subgraph, SUBINOUT *subinout, GRAPH *orggraph)
 
static SCIP_RETCODE reinsertSubgraph (SCIP *scip, GRAPH *subgraph, SUBINOUT *subinout, GRAPH *orggraph)
 
SCIP_RETCODE graph_subgraphExtract (SCIP *scip, GRAPH *orggraph, SUBINOUT *subinout, GRAPH **subgraph)
 
SCIP_RETCODE graph_subinoutInit (SCIP *scip, const GRAPH *orggraph, SUBINOUT **subinout)
 
SCIP_RETCODE graph_subinoutActivateEdgeMap (const GRAPH *orggraph, SUBINOUT *subinout)
 
void graph_subinoutActivateNewHistory (SUBINOUT *subinout)
 
const int * graph_subinoutGetSubToOrgNodeMap (const SUBINOUT *subinout)
 
const int * graph_subinoutGetSubToOrgEdgeMap (const SUBINOUT *subinout)
 
const int * graph_subinoutGetOrgToSubNodeMap (const SUBINOUT *subinout)
 
const int * graph_subinoutGetContractionRecord (const SUBINOUT *subinout)
 
SCIP_Bool graph_subinoutUsesNewHistory (const SUBINOUT *subinout)
 
void graph_subinoutFree (SCIP *scip, SUBINOUT **subinout)
 
void graph_subinoutClean (SCIP *scip, SUBINOUT *subinout)
 
int graph_knot_getContractionRecordAncestor (int node, const SUBINOUT *subinout)
 
SCIP_RETCODE graph_subgraphCompleteNewHistory (SCIP *scip, const int *edgemap_subToOrg, GRAPH *orggraph, GRAPH *subgraph)
 
SCIP_RETCODE graph_subgraphReinsert (SCIP *scip, SUBINOUT *subinout, GRAPH *orggraph, GRAPH **subgraph)
 
void graph_subgraphFree (SCIP *scip, GRAPH **subgraph)
 

Typedef Documentation

◆ EDGETRANS

typedef struct edge_transfer EDGETRANS

edge transfer

Function Documentation

◆ extractSubgraphGetSizeAndMap()

static void extractSubgraphGetSizeAndMap ( const GRAPH orggraph,
SUBINOUT subinout 
)
static

initializes subgraph

Parameters
orggraphoriginal graph
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 79 of file graph_sub.c.

References EAT_LAST, graph_get_nNodes(), GRAPH::head, Is_term, GRAPH::mark, nnodes, GRAPH::oeat, GRAPH::outbeg, and GRAPH::term.

Referenced by extractSubgraphBuild().

◆ extractSubgraphAddNodes()

static void extractSubgraphAddNodes ( const GRAPH orggraph,
SUBINOUT subinout,
GRAPH subgraph 
)
static

helper

Parameters
orggraphoriginal graph
subinoutdata structure for handling inclusion/exclusion of sub-problems
subgraphgraph to fill

Definition at line 135 of file graph_sub.c.

References graph_knot_add(), graph_knot_isInRange(), Is_term, GRAPH::knots, GRAPH::ksize, GRAPH::source, STP_TERM, STP_TERM_NONE, GRAPH::term, and TRUE.

Referenced by extractSubgraphBuild().

◆ extractSubgraphInitHistory()

static SCIP_RETCODE extractSubgraphInitHistory ( SCIP scip,
GRAPH orggraph,
SCIP_Bool  moveFixedEdges,
GRAPH subgraph 
)
static

helper

Parameters
scipSCIP data structure
orggraphoriginal graph
moveFixedEdgesmove fixed edges?
subgraphgraph to fill

Definition at line 175 of file graph_sub.c.

References GRAPH::ancestors, GRAPH::esize, graph_addPseudoAncestors(), graph_copyFixed(), graph_getNpseudoAncestors(), graph_initPseudoAncestorsSized(), SCIP_CALL, SCIP_OKAY, and SCIPallocMemoryArray.

Referenced by extractSubgraphBuild(), and graph_subgraphCompleteNewHistory().

◆ extractSubgraphAddEdge()

static SCIP_RETCODE extractSubgraphAddEdge ( SCIP scip,
SCIP_Bool  useNewHistory,
SCIP_Bool  moveEdges,
const EDGETRANS edgetrans,
GRAPH source_graph,
GRAPH target_graph 
)
static

◆ reinsertSubgraphAdaptSubToOrgMap()

static void reinsertSubgraphAdaptSubToOrgMap ( const GRAPH subgraph,
const GRAPH orggraph,
SUBINOUT subinout 
)
static

contracts border nodes of subgraph with remaining

Parameters
subgraphsub graph
orggraphoriginal graph
subinouthelper

Definition at line 274 of file graph_sub.c.

References GRAPH::grad, graph_get_nNodes(), graph_knot_isInRange(), Is_term, GRAPH::term, and GRAPH::terms.

Referenced by reinsertSubgraph().

◆ extractSubgraphAddEdgesWithHistory()

static SCIP_RETCODE extractSubgraphAddEdgesWithHistory ( SCIP scip,
GRAPH orggraph,
SUBINOUT subinout,
GRAPH subgraph 
)
static

helper

Parameters
scipSCIP data structure
orggraphoriginal graph
subinoutdata structure for inserting/extracting sub-problem
subgraphgraph to fill

Definition at line 327 of file graph_sub.c.

References EAT_LAST, GRAPH::edges, GRAPH::esize, extractSubgraphAddEdge(), FALSE, flipedge, graph_get_nNodes(), graph_knot_isInRange(), GRAPH::head, GRAPH::mark, MAX, GRAPH::oeat, GRAPH::orgedges, GRAPH::outbeg, SCIP_Bool, SCIP_CALL, SCIP_OKAY, edge_transfer::source_edge, and GRAPH::tail.

Referenced by extractSubgraphBuild().

◆ borderNodesCollect()

static void borderNodesCollect ( SCIP scip,
const GRAPH orggraph,
const GRAPH subgraph,
SUBINOUT subinout 
)
static

collects border nodes (cut vertices) of subgraph

Parameters
scipSCIP data structure
orggraphoriginal graph
subgraphsub graph
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 383 of file graph_sub.c.

References EAT_LAST, graph_get_nNodes(), graph_knot_isInRange(), GRAPH::head, Is_term, GRAPH::mark, GRAPH::oeat, GRAPH::outbeg, SCIPdebugMessage, StpVecGetSize, StpVecPushBack, and GRAPH::term.

Referenced by graph_subgraphExtract().

◆ borderNodesContract()

static SCIP_RETCODE borderNodesContract ( SCIP scip,
const GRAPH subgraph,
SUBINOUT subinout,
GRAPH orggraph 
)
static

contracts border nodes of subgraph with remaining

Parameters
scipSCIP data structure
subgraphsub graph
subinouthelper
orggraphoriginal graph

Definition at line 423 of file graph_sub.c.

References GRAPH::grad, graph_contractTrace(), graph_knot_contract(), graph_knot_hasContractTrace(), graph_knot_isInRange(), Is_term, NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, STP_Vectype, StpVecClear, StpVecGetSize, GRAPH::term, and GRAPH::terms.

Referenced by reinsertSubgraph().

◆ extractSubgraphBuild()

static SCIP_RETCODE extractSubgraphBuild ( SCIP scip,
GRAPH orggraph,
SUBINOUT subinout,
GRAPH **  subgraph 
)
static

builds subgraph

Parameters
scipSCIP data structure
orggraphoriginal graph
subinoutdata structure for handling inclusion/exclusion of sub-problems
subgraphgraph to be created

Definition at line 481 of file graph_sub.c.

References GRAPH::esize, extractSubgraphAddEdgesWithHistory(), extractSubgraphAddNodes(), extractSubgraphGetSizeAndMap(), extractSubgraphInitHistory(), graph_init(), graph_initContractTracing(), graph_path_init(), graph_typeIsSpgLike(), GRAPH::ksize, SCIP_CALL, SCIP_OKAY, STP_SPG, GRAPH::stp_type, and TRUE.

Referenced by graph_subgraphExtract().

◆ reinsertSubgraphTransferFixedHistory()

static void reinsertSubgraphTransferFixedHistory ( SCIP scip,
GRAPH subgraph,
GRAPH orggraph 
)
static

helper

Parameters
scipSCIP data structure
subgraphsub-graph
orggraphoriginal graph

Definition at line 516 of file graph_sub.c.

References GRAPH::fixedcomponents, graph_addPseudoAncestors(), graph_fixed_resetMoved(), graph_free_fixed(), graph_getNfixpseudonodes(), graph_getNpseudoAncestors(), and NULL.

Referenced by reinsertSubgraph().

◆ reinsertSubgraphTransferEdges()

static SCIP_RETCODE reinsertSubgraphTransferEdges ( SCIP scip,
GRAPH subgraph,
SUBINOUT subinsertion,
GRAPH orggraph 
)
static

helper

Parameters
scipSCIP data structure
subgraphgraph to be inserted
subinsertiondata structure for handling inclusion/exclusion of sub-problems
orggraphoriginal graph

Definition at line 548 of file graph_sub.c.

References EAT_FREE, extractSubgraphAddEdge(), FALSE, graph_edge_isDeleted(), graph_get_nEdges(), graph_knot_isInRange(), GRAPH::head, GRAPH::oeat, SCIP_CALL, SCIP_OKAY, edge_transfer::source_edge, STP_Vectype, StpVecGetSize, StpVecPopBack, GRAPH::tail, and TRUE.

Referenced by reinsertSubgraph().

◆ reinsertSubgraphTransferTerminals()

static SCIP_RETCODE reinsertSubgraphTransferTerminals ( const GRAPH subgraph,
SUBINOUT subinout,
GRAPH orggraph 
)
static

helper

Parameters
subgraphgraph to be inserted
subinoutdata structure for handling inclusion/exclusion of sub-problems
orggraphoriginal graph

Definition at line 591 of file graph_sub.c.

References GRAPH::contracttrace, GRAPH::grad, graph_contractTrace(), graph_get_nNodes(), graph_knot_chg(), graph_knot_hasContractTrace(), graph_knot_isInRange(), Is_term, SCIP_OKAY, GRAPH::source, and GRAPH::term.

Referenced by reinsertSubgraph().

◆ reinsertSubgraphDeleteOldEdges()

static SCIP_RETCODE reinsertSubgraphDeleteOldEdges ( SCIP scip,
const GRAPH subgraph,
SUBINOUT subinout,
GRAPH orggraph 
)
static

helper

Parameters
scipSCIP data structure
subgraphgraph to be inserted
subinoutdata structure for handling inclusion/exclusion of sub-problems
orggraphoriginal graph

Definition at line 634 of file graph_sub.c.

References EAT_LAST, graph_edge_del(), graph_get_nNodes(), graph_knot_isInRange(), GRAPH::head, GRAPH::oeat, GRAPH::outbeg, SCIP_OKAY, StpVecPushBack, and TRUE.

Referenced by reinsertSubgraph().

◆ reinsertSubgraph()

static SCIP_RETCODE reinsertSubgraph ( SCIP scip,
GRAPH subgraph,
SUBINOUT subinout,
GRAPH orggraph 
)
static

builds subgraph

Parameters
scipSCIP data structure
subgraphgraph to be inserted
subinoutdata structure for inserting/extracting sub-problem
orggraphoriginal graph

Definition at line 675 of file graph_sub.c.

References borderNodesContract(), GRAPH::edges, GRAPH::knots, reinsertSubgraphAdaptSubToOrgMap(), reinsertSubgraphDeleteOldEdges(), reinsertSubgraphTransferEdges(), reinsertSubgraphTransferFixedHistory(), reinsertSubgraphTransferTerminals(), SCIP_CALL, SCIP_OKAY, StpVecClear, and StpVecGetSize.

Referenced by graph_subgraphReinsert().

◆ graph_subgraphExtract()

SCIP_RETCODE graph_subgraphExtract ( SCIP scip,
GRAPH orggraph,
SUBINOUT subinout,
GRAPH **  subgraph 
)

Obtains a new subgraph corresponding to marked nodes. Also fills a node map from the new to the original nodes. Creates a shallow copy and moves parts wrt ancestor information: ancestors and pseudo-ancestors are kept/moved and will be modified also for original graph!

Parameters
scipSCIP data structure
orggraphoriginal graph
subinoutdata structure for inserting/extracting sub-problem
subgraphgraph to be created

Definition at line 712 of file graph_sub.c.

References borderNodesCollect(), extractSubgraphBuild(), graph_pc_isPcMw(), GRAPH::knots, SCIP_CALL, SCIP_OKAY, and GRAPH::withInexactReductions.

Referenced by decomposeExactSubTry(), decomposeGetSubgraph(), and decomposeReduceSubDoIt().

◆ graph_subinoutInit()

SCIP_RETCODE graph_subinoutInit ( SCIP scip,
const GRAPH orggraph,
SUBINOUT **  subinout 
)

initializes

Parameters
scipSCIP data structure
orggraphoriginal graph
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 733 of file graph_sub.c.

References FALSE, graph_get_nNodes(), nnodes, NULL, SCIP_CALL, SCIP_OKAY, SCIPallocMemory, SCIPallocMemoryArray, and sub.

Referenced by bidecomposition_initSubInOut().

◆ graph_subinoutActivateEdgeMap()

SCIP_RETCODE graph_subinoutActivateEdgeMap ( const GRAPH orggraph,
SUBINOUT subinout 
)

activates

Parameters
orggraphoriginal graph
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 769 of file graph_sub.c.

References graph_get_nEdges(), SCIP_CALL, SCIP_OKAY, SCIPallocMemoryArray, and TRUE.

Referenced by decomposeExec(), and decomposePartialExact().

◆ graph_subinoutActivateNewHistory()

void graph_subinoutActivateNewHistory ( SUBINOUT subinout)

activates

Parameters
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 788 of file graph_sub.c.

References TRUE.

Referenced by decomposeExec(), and decomposePartialExact().

◆ graph_subinoutGetSubToOrgNodeMap()

const int* graph_subinoutGetSubToOrgNodeMap ( const SUBINOUT subinout)

gets nodes map

Parameters
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 799 of file graph_sub.c.

Referenced by decomposeReduceSubDoIt().

◆ graph_subinoutGetSubToOrgEdgeMap()

const int* graph_subinoutGetSubToOrgEdgeMap ( const SUBINOUT subinout)

gets edge map

Parameters
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 812 of file graph_sub.c.

Referenced by decomposeExactFixSol(), decomposeExactSubDoIt(), decomposeSolveSub(), and subsolFixOrgEdges().

◆ graph_subinoutGetOrgToSubNodeMap()

const int* graph_subinoutGetOrgToSubNodeMap ( const SUBINOUT subinout)

gets nodes map

Parameters
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 825 of file graph_sub.c.

Referenced by bidecomposition_getMarkedSubRoot(), and decomposeReduceSubDoIt().

◆ graph_subinoutGetContractionRecord()

const int* graph_subinoutGetContractionRecord ( const SUBINOUT subinout)

get contraction record for cut nodes (-1 if no contraction)

Parameters
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 837 of file graph_sub.c.

Referenced by bidecomposition_markSub().

◆ graph_subinoutUsesNewHistory()

SCIP_Bool graph_subinoutUsesNewHistory ( const SUBINOUT subinout)

new history per subproblem is being used?

Parameters
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 848 of file graph_sub.c.

Referenced by decomposeSolveSub().

◆ graph_subinoutFree()

void graph_subinoutFree ( SCIP scip,
SUBINOUT **  subinout 
)

frees

Parameters
scipSCIP data structure
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 859 of file graph_sub.c.

References SCIPfreeMemory, SCIPfreeMemoryArray, SCIPfreeMemoryArrayNull, StpVecFree, and sub.

Referenced by bidecomposition_free().

◆ graph_subinoutClean()

void graph_subinoutClean ( SCIP scip,
SUBINOUT subinout 
)

cleans

Parameters
scipSCIP data structure
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 882 of file graph_sub.c.

References StpVecClear.

Referenced by decomposeExactSubDoIt(), and decomposeSolveSub().

◆ graph_knot_getContractionRecordAncestor()

int graph_knot_getContractionRecordAncestor ( int  node,
const SUBINOUT subinout 
)

gets ancestor

Parameters
nodenode to get ancestors for
subinoutdata structure for handling inclusion/exclusion of sub-problems

Definition at line 895 of file graph_sub.c.

Referenced by bidecomposition_markSub().

◆ graph_subgraphCompleteNewHistory()

SCIP_RETCODE graph_subgraphCompleteNewHistory ( SCIP scip,
const int *  edgemap_subToOrg,
GRAPH orggraph,
GRAPH subgraph 
)

completes history NOTE: necessary to allocate block memory on subscip

Parameters
scipSCIP data structure
edgemap_subToOrgmaps edges of subgraph to original graph
orggraphoriginal graph
subgraphgraph to fill

Definition at line 920 of file graph_sub.c.

References BMScopyMemoryArray, GRAPH::cost, EQ, extractSubgraphInitHistory(), FALSE, GRAPH::fixedcomponents, graph_edge_getPseudoAncestors(), graph_edge_nPseudoAncestors(), graph_free_fixedEdgesOnly(), graph_get_nEdges(), graph_initAncestors(), graph_pseudoAncestors_appendCopyArrayToEdge(), GRAPH::head, GRAPH::orghead, GRAPH::orgtail, GRAPH::pseudoancestors, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPallocMemoryArray, and GRAPH::tail.

Referenced by substpsolver_transferHistory().

◆ graph_subgraphReinsert()

SCIP_RETCODE graph_subgraphReinsert ( SCIP scip,
SUBINOUT subinout,
GRAPH orggraph,
GRAPH **  subgraph 
)

reinserts extracted (and modified) subgraph; also deletes subgraph. Dual to "graph_subgraphExtract"

Parameters
scipSCIP data structure
subinoutdata structure for handling inclusion/exclusion of sub-problems
orggraphoriginal graph
subgraphgraph to be reinserted (and freed)

Definition at line 983 of file graph_sub.c.

References FALSE, GRAPH::fixedcomponents, graph_free(), graph_path_exit(), graph_pc_isPcMw(), graph_valid(), NULL, GRAPH::orghead, GRAPH::orgtail, reinsertSubgraph(), SCIP_CALL, SCIP_OKAY, and SCIPfreeMemoryArray.

Referenced by decomposeReduceSubDoIt().

◆ graph_subgraphFree()

void graph_subgraphFree ( SCIP scip,
GRAPH **  subgraph 
)

frees extracted subgraph. NOTE: fixed history components are not deleted

Parameters
scipSCIP data structure
subgraphgraph to be freed

Definition at line 1022 of file graph_sub.c.

References FALSE, graph_free(), and graph_path_exit().