Scippy

SCIP

Solving Constraint Integer Programs

reduce_ext.c File Reference

Detailed Description

extended reductions for Steiner tree problems

Author
Daniel Rehfeldt

This file implements extended reduction techniques for several Steiner problems. Note: Deprecated and is only used for test purposes. Use extreduce.h methods instead.

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

Definition in file reduce_ext.c.

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "graph.h"
#include "reduce.h"

Go to the source code of this file.

Macros

#define EXT_ANCESTORS_MAX   16
 
#define RED_EXT_MAXDFSDEPTH   6
 
#define RED_EXT_MINDFSDEPTH   4
 
#define RED_EXT_MAXGRAD   8
 
#define RED_EXT_MINGRAD   6
 
#define RED_EXT_EDGELIMIT   50000
 

Functions

static void removeEdge (SCIP *scip, int edge, GRAPH *graph)
 
static SCIP_Bool markAncestorsConflict (const GRAPH *graph, int edge, int *ancestormark)
 
static void markAncestors (const GRAPH *graph, int edge, int *ancestormark)
 
static void unmarkAncestorsConflict (const GRAPH *graph, int edge, int *ancestormark)
 
static void unmarkAncestors (const GRAPH *graph, int edge, int *ancestormark)
 
static void finalizeSubtree (const GRAPH *graph, const int *edgeends, const int *treeedges, int dfsdepth, SCIP_Bool stopped, SCIP_Real localbound, SCIP_Real *globalbound, SCIP_Bool *ruleout, int *nodepos, int *ancestormark)
 
static SCIP_Bool truncateSubtree (const GRAPH *graph, SCIP_Real extendedcost, int root, int currhead, int maxgrad, int dfsdepth, int maxdfsdepth, SCIP_Real *minbound, SCIP_Bool *stopped)
 
static SCIP_Real shortenSubtree (SCIP *scip, const GRAPH *graph, const SCIP_Real *redcost, const int *treeedges, SCIP_Real treecostold, SCIP_Real treecostoffset, int dfsdepth, int lastnode, int *nodepos, int *ancestormark, unsigned int *nstallrounds)
 
static int extendSubtreeHead (SCIP *scip, const GRAPH *graph, const SCIP_Real *redcost, int curredge, int currhead, int dfsdepth, int nadded_edges, SCIP_Real *treecost, SCIP_Real *treecosts, int *nodepos, int *treeedges, int *edgestack, int *ancestormark)
 
static int extendSubtreeTail (const GRAPH *graph, const SCIP_Real *redcost, int curredge, int currtail, int dfsdepth, int nadded_edges, SCIP_Real *treecost, SCIP_Real *treecosts, int *nodepos, int *treeedges, int *edgestack, int *ancestormark)
 
static void updateEqArrays (int edge, unsigned int *eqstack, int *eqstack_size, SCIP_Bool *eqmark)
 
static SCIP_Bool bottleneckRuleOut (SCIP *scip, const GRAPH *graph, const SCIP_Real *treecosts, const SCIP_Real *basebottlenecks, const int *nodepos, const int *treeedges, SCIP_Real orgedgecost, SCIP_Real extedgecost, int orgedge, int extedge, int dfsdepth, SCIP_Bool allow_eq, unsigned int *eqstack, int *eqstack_size, SCIP_Bool *eqmark)
 
static SCIP_Bool ruleOutSubtree (SCIP *scip, const GRAPH *graph, const SCIP_Real *treecosts, const SCIP_Real *basebottlenecks, const int *nodepos, const int *treeedges, SCIP_Real cutoff, SCIP_Real extendedcost, int dfsdepth, int curredge, SCIP_Bool allowequality, const int *ancestormark, unsigned int *eqstack, int *eqstack_size, SCIP_Bool *eqmark)
 
static SCIP_RETCODE reduceCheckEdge (SCIP *scip, const GRAPH *graph, int root, const SCIP_Real *redcost, const SCIP_Real *pathdist, const PATH *vnoi, SCIP_Real cutoff, int edge, SCIP_Bool equality, int *edgestack, SCIP_Bool *deletable, unsigned int *eqstack, int *eqstack_size, SCIP_Bool *eqmark)
 
SCIP_RETCODE reduce_deleteConflictEdges (SCIP *scip, GRAPH *g)
 
SCIP_RETCODE reduce_extendedCheck3Tree (SCIP *scip, const GRAPH *graph, int root, const SCIP_Real *redcost, const SCIP_Real *pathdist, const PATH *vnoi, const int *vbase, SCIP_Real cutoff, const int *outedges, int inedge, SCIP_Real *treebound, SCIP_Bool *ruleout, unsigned int *eqstack, int *eqstack_size, SCIP_Bool *eqmark)
 
int reduce_extendedEdge (SCIP *scip, GRAPH *graph, const PATH *vnoi, const SCIP_Real *cost, const SCIP_Real *pathdist, const int *result, SCIP_Real minpathcost, int root, STP_Bool *marked, SCIP_Bool markdirected)
 

Macro Definition Documentation

◆ EXT_ANCESTORS_MAX

#define EXT_ANCESTORS_MAX   16

◆ RED_EXT_MAXDFSDEPTH

#define RED_EXT_MAXDFSDEPTH   6

Definition at line 38 of file reduce_ext.c.

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ RED_EXT_MINDFSDEPTH

#define RED_EXT_MINDFSDEPTH   4

Definition at line 39 of file reduce_ext.c.

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ RED_EXT_MAXGRAD

#define RED_EXT_MAXGRAD   8

Definition at line 40 of file reduce_ext.c.

Referenced by reduce_extendedCheck3Tree(), reduceCheckEdge(), and ruleOutSubtree().

◆ RED_EXT_MINGRAD

#define RED_EXT_MINGRAD   6

Definition at line 41 of file reduce_ext.c.

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ RED_EXT_EDGELIMIT

#define RED_EXT_EDGELIMIT   50000

Definition at line 42 of file reduce_ext.c.

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

Function Documentation

◆ removeEdge()

static void removeEdge ( SCIP scip,
int  edge,
GRAPH graph 
)
static

deletes an edge and makes corresponding adaptations

Parameters
scipSCIP
edgeedge to delete
graphgraph data structure

Definition at line 47 of file reduce_ext.c.

References FALSE, GRAPH::grad, graph_edge_del(), graph_pc_isPcMw(), GRAPH::head, Is_term, GRAPH::mark, GRAPH::source, GRAPH::tail, GRAPH::term, and TRUE.

Referenced by reduce_extendedEdge().

◆ markAncestorsConflict()

static SCIP_Bool markAncestorsConflict ( const GRAPH graph,
int  edge,
int *  ancestormark 
)
static

mark ancestors of given edge

Parameters
graphgraph data structure
edgeedge to use
ancestormarkancestor mark array

Definition at line 84 of file reduce_ext.c.

References GRAPH::edges, EXT_ANCESTORS_MAX, FALSE, graph_edge_getAncestors(), MAX, NULL, GRAPH::orgedges, and TRUE.

Referenced by reduce_deleteConflictEdges(), and reduce_extendedCheck3Tree().

◆ markAncestors()

static void markAncestors ( const GRAPH graph,
int  edge,
int *  ancestormark 
)
static

mark ancestors of given edge

Parameters
graphgraph data structure
edgeedge to use
ancestormarkancestor mark array

Definition at line 110 of file reduce_ext.c.

References GRAPH::edges, EXT_ANCESTORS_MAX, graph_edge_getAncestors(), MAX, NULL, and GRAPH::orgedges.

Referenced by extendSubtreeHead(), extendSubtreeTail(), and reduceCheckEdge().

◆ unmarkAncestorsConflict()

static void unmarkAncestorsConflict ( const GRAPH graph,
int  edge,
int *  ancestormark 
)
static

unmark ancestors of given edge

Parameters
graphgraph data structure
edgeedge to use
ancestormarkancestor mark array

Definition at line 130 of file reduce_ext.c.

References GRAPH::edges, EXT_ANCESTORS_MAX, graph_edge_getAncestors(), MAX, NULL, and GRAPH::orgedges.

Referenced by reduce_deleteConflictEdges(), and reduce_extendedCheck3Tree().

◆ unmarkAncestors()

static void unmarkAncestors ( const GRAPH graph,
int  edge,
int *  ancestormark 
)
static

unmark ancestors of given edge

Parameters
graphgraph data structure
edgeedge to use
ancestormarkancestor mark array

Definition at line 148 of file reduce_ext.c.

References GRAPH::edges, EXT_ANCESTORS_MAX, graph_edge_getAncestors(), MAX, NULL, and GRAPH::orgedges.

Referenced by finalizeSubtree(), reduceCheckEdge(), and shortenSubtree().

◆ finalizeSubtree()

static void finalizeSubtree ( const GRAPH graph,
const int *  edgeends,
const int *  treeedges,
int  dfsdepth,
SCIP_Bool  stopped,
SCIP_Real  localbound,
SCIP_Real globalbound,
SCIP_Bool ruleout,
int *  nodepos,
int *  ancestormark 
)
static

finalize subtree computations (clean up, update global bound)

Parameters
graphgraph data structure
edgeendsheads or tail of edge
treeedgestree edges
dfsdepthdfs depth
stoppedhas extension been stopped?
localboundlocal bound
globalboundpoints to global bound
ruleoutrule out?
nodeposnode position in tree
ancestormarkancestor mark array

Definition at line 170 of file reduce_ext.c.

References TRUE, and unmarkAncestors().

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ truncateSubtree()

static SCIP_Bool truncateSubtree ( const GRAPH graph,
SCIP_Real  extendedcost,
int  root,
int  currhead,
int  maxgrad,
int  dfsdepth,
int  maxdfsdepth,
SCIP_Real minbound,
SCIP_Bool stopped 
)
static

should we truncate subtree?

Parameters
graphgraph data structure
extendedcostcost of subtree
rootDA root
currheadlatest node
maxgradmaximum allowed degree
dfsdepthdfs depth
maxdfsdepthmax dfs depth
minboundbound
stoppedreal truncation?

Definition at line 208 of file reduce_ext.c.

References FALSE, GRAPH::grad, Is_term, GRAPH::mark, GRAPH::term, and TRUE.

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ shortenSubtree()

static SCIP_Real shortenSubtree ( SCIP scip,
const GRAPH graph,
const SCIP_Real redcost,
const int *  treeedges,
SCIP_Real  treecostold,
SCIP_Real  treecostoffset,
int  dfsdepth,
int  lastnode,
int *  nodepos,
int *  ancestormark,
unsigned int *  nstallrounds 
)
static

remove latest edge from subtree and returns new tree cost

Parameters
scipSCIP
graphgraph data structure
redcostreduced costs
treeedgesedges of tree
treecostoldold tree cost
treecostoffsettree cost offset
dfsdepthDFS depth
lastnodelast node
nodeposarray to mark node position
ancestormarkancestor mark array
nstallroundsrounds since latest update

Definition at line 238 of file reduce_ext.c.

References SCIP_Real, SCIPisEQ(), SCIPisGE(), and unmarkAncestors().

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ extendSubtreeHead()

static int extendSubtreeHead ( SCIP scip,
const GRAPH graph,
const SCIP_Real redcost,
int  curredge,
int  currhead,
int  dfsdepth,
int  nadded_edges,
SCIP_Real treecost,
SCIP_Real treecosts,
int *  nodepos,
int *  treeedges,
int *  edgestack,
int *  ancestormark 
)
static

extend subtree and return new nadded_edges

Parameters
scipSCIP
graphgraph data structure
redcostreduced costs
curredgeadded edges
currheadlatest node
dfsdepthDFS depth
nadded_edgesadded edges
treecostpointer to treecost
treecostsedge costs of tree
nodeposnode position in tree
treeedgesedges of tree
edgestackstack
ancestormarkancestor mark array

Definition at line 278 of file reduce_ext.c.

References GRAPH::cost, EAT_LAST, GRAPH::head, GRAPH::mark, markAncestors(), GRAPH::oeat, and GRAPH::outbeg.

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ extendSubtreeTail()

static int extendSubtreeTail ( const GRAPH graph,
const SCIP_Real redcost,
int  curredge,
int  currtail,
int  dfsdepth,
int  nadded_edges,
SCIP_Real treecost,
SCIP_Real treecosts,
int *  nodepos,
int *  treeedges,
int *  edgestack,
int *  ancestormark 
)
static

extend subtree and return new nadded_edges

Parameters
graphgraph data structure
redcostreduced costs
curredgeadded edges
currtaillatest node
dfsdepthDFS depth
nadded_edgesadded edges
treecostpointer to treecost
treecostsedge costs of tree
nodeposnode position in tree
treeedgesedges of tree
edgestackstack
ancestormarkancestor mark array

Definition at line 315 of file reduce_ext.c.

References GRAPH::cost, EAT_LAST, GRAPH::ieat, GRAPH::inpbeg, GRAPH::mark, markAncestors(), and GRAPH::tail.

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ updateEqArrays()

static void updateEqArrays ( int  edge,
unsigned int *  eqstack,
int *  eqstack_size,
SCIP_Bool eqmark 
)
static

small helper

Parameters
edgethe edge
eqstackstores edges that were used for equality comparison
eqstack_sizepointer to size of eqstack
eqmarkmarks edges that were used for equality comparison

Definition at line 352 of file reduce_ext.c.

References TRUE.

Referenced by bottleneckRuleOut().

◆ bottleneckRuleOut()

static SCIP_Bool bottleneckRuleOut ( SCIP scip,
const GRAPH graph,
const SCIP_Real treecosts,
const SCIP_Real basebottlenecks,
const int *  nodepos,
const int *  treeedges,
SCIP_Real  orgedgecost,
SCIP_Real  extedgecost,
int  orgedge,
int  extedge,
int  dfsdepth,
SCIP_Bool  allow_eq,
unsigned int *  eqstack,
int *  eqstack_size,
SCIP_Bool eqmark 
)
static

compare with tree bottleneck

Parameters
scipSCIP
graphgraph data structure
treecostscosts of edges of the tree
basebottlenecksbottleneck costs for innode and basenode
nodeposnode position in tree
treeedgesedges in tree (corresponding to treecosts)
orgedgecostcost of original edge
extedgecostcost of short-cut edge
orgedgeoriginal edge
extedgeshort-cut edge
dfsdepthdfs depth
allow_eqtest for equality?
eqstackstores edges that were used for equality comparison
eqstack_sizepointer to size of eqstack
eqmarkmarks edges that were used for equality comparison

Definition at line 375 of file reduce_ext.c.

References FALSE, GRAPH::knots, NULL, SCIPisEQ(), SCIPisLE(), SCIPisLT(), GRAPH::tail, TRUE, and updateEqArrays().

Referenced by ruleOutSubtree().

◆ ruleOutSubtree()

static SCIP_Bool ruleOutSubtree ( SCIP scip,
const GRAPH graph,
const SCIP_Real treecosts,
const SCIP_Real basebottlenecks,
const int *  nodepos,
const int *  treeedges,
SCIP_Real  cutoff,
SCIP_Real  extendedcost,
int  dfsdepth,
int  curredge,
SCIP_Bool  allowequality,
const int *  ancestormark,
unsigned int *  eqstack,
int *  eqstack_size,
SCIP_Bool eqmark 
)
static

can subtree be ruled out?

Parameters
scipSCIP
graphgraph data structure
treecostscosts of edges of the tree
basebottlenecksbottleneck costs for innode and basenode
nodeposnode position in tree
treeedgesedges in tree (corresponding to treecosts)
cutoffcut-off bound
extendedcostcost of subtree
dfsdepthdfs depth
curredgelatest edge
allowequalityrule out also in case of equality
ancestormarkancestor mark array
eqstackstores edges that were used for equality comparison
eqstack_sizepointer to size of eqstack
eqmarkmarks edges that were used for equality comparison

Definition at line 455 of file reduce_ext.c.

References bottleneckRuleOut(), GRAPH::cost, EAT_LAST, GRAPH::edges, EXT_ANCESTORS_MAX, FALSE, flipedge, graph_edge_getAncestors(), graph_pc_isPcMw(), GRAPH::head, GRAPH::ieat, GRAPH::inpbeg, Is_term, GRAPH::mark, MAX, NULL, GRAPH::oeat, GRAPH::orgedges, GRAPH::outbeg, GRAPH::prize, RED_EXT_MAXGRAD, SCIP_Bool, SCIP_Real, SCIPisGT(), GRAPH::tail, GRAPH::term, and TRUE.

Referenced by reduce_extendedCheck3Tree(), and reduceCheckEdge().

◆ reduceCheckEdge()

static SCIP_RETCODE reduceCheckEdge ( SCIP scip,
const GRAPH graph,
int  root,
const SCIP_Real redcost,
const SCIP_Real pathdist,
const PATH vnoi,
SCIP_Real  cutoff,
int  edge,
SCIP_Bool  equality,
int *  edgestack,
SCIP_Bool deletable,
unsigned int *  eqstack,
int *  eqstack_size,
SCIP_Bool eqmark 
)
static

check (directed) edge

Parameters
scipSCIP data structure
graphgraph data structure
rootgraph root from dual ascent
redcostreduced costs
pathdistshortest path distances
vnoiVoronoi paths
cutoffcutoff value
edge(directed) edge to be checked
equalityallow equality?
edgestackarray of size nodes for internal computations
deletableis edge deletable?
eqstackstores edges that were used for equality comparison
eqstack_sizepointer to size of eqstack
eqmarkmarks edges that were used for equality comparison

Definition at line 564 of file reduce_ext.c.

References GRAPH::cost, shortest_path::dist, EAT_LAST, GRAPH::edges, GRAPH::extended, extendSubtreeHead(), extendSubtreeTail(), FALSE, FARAWAY, finalizeSubtree(), flipedge, GRAPH::grad, graph_pc_isPcMw(), GRAPH::head, GRAPH::ieat, GRAPH::inpbeg, Is_term, GRAPH::knots, GRAPH::mark, markAncestors(), MAX, nnodes, NULL, GRAPH::oeat, GRAPH::orgedges, GRAPH::outbeg, RED_EXT_EDGELIMIT, RED_EXT_MAXDFSDEPTH, RED_EXT_MAXGRAD, RED_EXT_MINDFSDEPTH, RED_EXT_MINGRAD, ruleOutSubtree(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocCleanBufferArray, SCIPfreeCleanBufferArray, SCIPisEQ(), SCIPisGE(), SCIPisGT(), shortenSubtree(), GRAPH::tail, GRAPH::term, TRUE, truncateSubtree(), and unmarkAncestors().

Referenced by reduce_extendedEdge().

◆ reduce_deleteConflictEdges()

SCIP_RETCODE reduce_deleteConflictEdges ( SCIP scip,
GRAPH g 
)

todo don't use this function, but check for conflicts in misc_stp.c and handle them

Parameters
scipSCIP data structure
gthe graph

Definition at line 791 of file reduce_ext.c.

References GRAPH::ancestors, GRAPH::cost, EAT_FREE, GRAPH::edges, GRAPH::extended, FALSE, graph_edge_del(), graph_pc_isPcMw(), GRAPH::head, Is_pseudoTerm, markAncestorsConflict(), MAX, NULL, GRAPH::oeat, GRAPH::orgedges, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPfreeBufferArray, GRAPH::tail, GRAPH::term, TRUE, and unmarkAncestorsConflict().

Referenced by reduce_redLoopPc().

◆ reduce_extendedCheck3Tree()

SCIP_RETCODE reduce_extendedCheck3Tree ( SCIP scip,
const GRAPH graph,
int  root,
const SCIP_Real redcost,
const SCIP_Real pathdist,
const PATH vnoi,
const int *  vbase,
SCIP_Real  cutoff,
const int *  outedges,
int  inedge,
SCIP_Real treebound,
SCIP_Bool ruleout,
unsigned int *  eqstack,
int *  eqstack_size,
SCIP_Bool eqmark 
)

check 3-tree

Parameters
scipSCIP data structure
graphgraph data structure
rootgraph root from dual ascent
redcostreduced costs
pathdistshortest path distances
vnoiVoronoi paths
vbasebases to Voronoi paths
cutoffcutoff value
outedgestwo outgoing edge
inedgeincoming edge
treeboundto store a lower bound for the tree
ruleoutcould tree be ruled out?
eqstackstores edges that were used for equality comparison
eqstack_sizepointer to size of eqstack
eqmarkmarks edges that were used for equality comparison

Definition at line 842 of file reduce_ext.c.

References GRAPH::cost, shortest_path::dist, EAT_LAST, GRAPH::edges, extendSubtreeHead(), extendSubtreeTail(), FALSE, FARAWAY, finalizeSubtree(), flipedge, GRAPH::grad, GRAPH::head, GRAPH::ieat, GRAPH::inpbeg, Is_term, GRAPH::knots, markAncestorsConflict(), MAX, nnodes, NULL, GRAPH::oeat, GRAPH::orgedges, GRAPH::outbeg, RED_EXT_EDGELIMIT, RED_EXT_MAXDFSDEPTH, RED_EXT_MAXGRAD, RED_EXT_MINDFSDEPTH, RED_EXT_MINGRAD, ruleOutSubtree(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPallocCleanBufferArray, SCIPfreeBufferArray, SCIPfreeCleanBufferArray, SCIPisGE(), SCIPisGT(), shortenSubtree(), GRAPH::tail, GRAPH::term, TRUE, truncateSubtree(), and unmarkAncestorsConflict().

Referenced by updateNodeReplaceBounds().

◆ reduce_extendedEdge()

int reduce_extendedEdge ( SCIP scip,
GRAPH graph,
const PATH vnoi,
const SCIP_Real cost,
const SCIP_Real pathdist,
const int *  result,
SCIP_Real  minpathcost,
int  root,
STP_Bool marked,
SCIP_Bool  markdirected 
)

reduce SPG graph based on reduced cost information and given upper bound todo to be deleted and replaced by reduce_extendedEdge2

Parameters
scipSCIP data structure
graphgraph data structure
vnoiVoronoi data structure
costdual ascent costs
pathdistdistance array from shortest path calculations
resultsol int array
minpathcostthe required reduced path cost to be surpassed
rootthe root
markededge array to mark which (directed) edge can be removed
markdirectedtry to also mark edge if anti-parallel is not marked

Definition at line 1155 of file reduce_ext.c.

References CONNECT, GRAPH::cost, EAT_FREE, GRAPH::edges, GRAPH::extended, FALSE, GRAPH::grad, graph_pc_isPcMw(), Is_term, GRAPH::knots, GRAPH::mark, nnodes, NULL, GRAPH::oeat, reduceCheckEdge(), removeEdge(), SCIP_Bool, SCIP_CALL, SCIP_CALL_ABORT, SCIPallocBufferArray, SCIPallocCleanBufferArray, SCIPfreeBufferArray, SCIPfreeCleanBufferArray, SCIPisEQ(), SCIPisZero(), GRAPH::term, and TRUE.

Referenced by fixVarsExtendedRed().