Scippy

SCIP

Solving Constraint Integer Programs

dpterms_core.c File Reference

Detailed Description

Core of dynamic programming solver for Steiner tree (sub-) problems with small number of terminals.

Author
Daniel Rehfeldt

Contains core methods.

Definition in file dpterms_core.c.

#include "scip/scipdefplugins.h"
#include "scip/rbtree.h"
#include "dpterms.h"
#include "dptermsinterns.h"
#include "stpbitset.h"
#include "stpvector.h"
#include "stpprioqueue.h"

Go to the source code of this file.

Data Structures

struct  trace_triplet
 
struct  dynamic_programming_iterator
 

Typedefs

typedef struct trace_triplet TTRIPLET
 
typedef struct dynamic_programming_iterator DPITER
 

Functions

static void debugPrintSeparator (SCIP_Real maxvaliddist, const DPITER *dpiterator)
 
static STP_Vectype (int)
 
static SCIP_Bool nodeIsNonSolTerm (STP_Bitset sol_bitset, const int *nodes_termId, int node)
 
static SCIP_Bool allExtensionsAreInvalid (const GRAPH *graph, const DPSOLVER *dpsolver, const DPITER *dpiterator)
 
static SCIP_RETCODE getOrderedRootIndices (SCIP *scip, DPITER *dpiterator, int *roots_indices)
 
static SCIP_RETCODE dpiterInit (SCIP *scip, const GRAPH *graph, DPITER **dpiterator)
 
static void dpiterFree (SCIP *scip, DPITER **dpiterator)
 
static void dpiterSetDefault (SCIP *scip, DPITER *dpiterator)
 
static void dpiterPopSol (SCIP *scip, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static void dpiterGetNextSol (SCIP *scip, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static SCIP_RETCODE subtreesBuild (SCIP *scip, DPMISC *dpmisc, DPITER *dpiterator)
 
static SCIP_RETCODE subtreesExtend (SCIP *scip, const GRAPH *graph, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static SCIP_RETCODE dpiterAddNewPrepare (SCIP *scip, DPMISC *dpmisc, DPITER *dpiterator, SCIP_Bool *hasExtension)
 
static STP_Vectype (SOLTRACE)
 
static void subsolUpdate (SCIP *scip, STP_Vectype(SOLTRACE) combined_traces, DPITER *dpiterator, DPSUBSOL *dpsubsol)
 
static SCIP_RETCODE combineWithIntersecting (SCIP *scip, const GRAPH *graph, int index, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static void updateIncumbent (SCIP *scip, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static SCIP_RETCODE subtreesAddNewFinalize (SCIP *scip, const GRAPH *graph, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static SCIP_RETCODE subtreesAddNew (SCIP *scip, const GRAPH *graph, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static void propagateUBs (const GRAPH *graph, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static SCIP_RETCODE subtreesRemoveNonValids (SCIP *scip, const GRAPH *graph, DPSOLVER *dpsolver, DPITER *dpiterator)
 
static void dpiterFinalizeSol (SCIP *scip, DPITER *dpiterator)
 
SCIP_RETCODE dpterms_coreSolve (SCIP *scip, GRAPH *graph, DPSOLVER *dpsolver, SCIP_Bool *wasSolved)
 

Typedef Documentation

◆ TTRIPLET

typedef struct trace_triplet TTRIPLET

helper data

◆ DPITER

saves some data updated in every iteration

Function Documentation

◆ debugPrintSeparator()

static void debugPrintSeparator ( SCIP_Real  maxvaliddist,
const DPITER dpiterator 
)
static

prints separator nodes in SCIP_DEBUG mode

Parameters
maxvaliddistmaximum value distance
dpiteratoriterator

Definition at line 79 of file dpterms_core.c.

References GT, LE, nnodes, SCIP_Real, and SCIPdebugMessage.

Referenced by subtreesRemoveNonValids().

◆ STP_Vectype() [1/2]

◆ nodeIsNonSolTerm()

static SCIP_Bool nodeIsNonSolTerm ( STP_Bitset  sol_bitset,
const int *  nodes_termId,
int  node 
)
inlinestatic

helper

Parameters
sol_bitsetbitset
nodes_termIdID
nodenode to check

Definition at line 170 of file dpterms_core.c.

References stpbitset_bitIsTrue().

Referenced by subtreesExtend(), and subtreesRemoveNonValids().

◆ allExtensionsAreInvalid()

static SCIP_Bool allExtensionsAreInvalid ( const GRAPH graph,
const DPSOLVER dpsolver,
const DPITER dpiterator 
)
static

helper

Parameters
graphgraph
dpsolversolver
dpiteratoriterator

Definition at line 182 of file dpterms_core.c.

References dynamic_programming_solver::dpgraph, FALSE, GT, nterms, SCIP_Real, SCIPdebugMessage, STP_Bitset, stpbitset_bitIsTrue(), dynamic_programming_graph::terminals, GRAPH::terms, and TRUE.

Referenced by subtreesRemoveNonValids().

◆ getOrderedRootIndices()

static SCIP_RETCODE getOrderedRootIndices ( SCIP scip,
DPITER dpiterator,
int *  roots_indices 
)
static

gets ordered root indices according to the solution costs

Parameters
scipSCIP data structure
dpiteratoriterator
roots_indicesto initialize

Definition at line 209 of file dpterms_core.c.

References LE, nnodes, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPsortDownRealInt(), STP_Vectype(), and StpVecGetSize.

Referenced by subtreesBuild().

◆ dpiterInit()

static SCIP_RETCODE dpiterInit ( SCIP scip,
const GRAPH graph,
DPITER **  dpiterator 
)
static

initializes

Parameters
scipSCIP data structure
graphoriginal graph
dpiteratorto initialize

Definition at line 247 of file dpterms_core.c.

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

Referenced by dpterms_coreSolve().

◆ dpiterFree()

static void dpiterFree ( SCIP scip,
DPITER **  dpiterator 
)
static

frees

Parameters
scipSCIP data structure
dpiteratorto free

Definition at line 288 of file dpterms_core.c.

References SCIPfreeMemory, SCIPfreeMemoryArray, and StpVecFree.

Referenced by dpterms_coreSolve().

◆ dpiterSetDefault()

static void dpiterSetDefault ( SCIP scip,
DPITER dpiterator 
)
static

sets arrays to default values

Parameters
scipSCIP data structure
dpiteratorto update

Definition at line 315 of file dpterms_core.c.

References BMSclearMemoryArray, FARAWAY, nnodes, SCIP_Bool, and SCIP_Real.

Referenced by dpiterGetNextSol().

◆ dpiterPopSol()

static void dpiterPopSol ( SCIP scip,
DPSOLVER dpsolver,
DPITER dpiterator 
)
static

◆ dpiterGetNextSol()

static void dpiterGetNextSol ( SCIP scip,
DPSOLVER dpsolver,
DPITER dpiterator 
)
static

updates

Parameters
scipSCIP data structure
dpsolversolver
dpiteratorto update

Definition at line 387 of file dpterms_core.c.

References dynamic_programming_solver::dpgraph, dpiterPopSol(), dpiterSetDefault(), dynamic_programming_graph::nterms, SCIPdebugMessage, stpbitset_bitIsTrue(), stpbitset_print(), and dynamic_programming_graph::terminals.

Referenced by dpterms_coreSolve().

◆ subtreesBuild()

static SCIP_RETCODE subtreesBuild ( SCIP scip,
DPMISC dpmisc,
DPITER dpiterator 
)
static

◆ subtreesExtend()

◆ dpiterAddNewPrepare()

static SCIP_RETCODE dpiterAddNewPrepare ( SCIP scip,
DPMISC dpmisc,
DPITER dpiterator,
SCIP_Bool hasExtension 
)
static

helper

Parameters
scipSCIP data structure
dpmiscDP misc data structure
dpiteratoriterator
hasExtensionextensions existing?

Definition at line 659 of file dpterms_core.c.

References FALSE, FARAWAY, GE, dynamic_programming_misc::global_size, LT, nnodes, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPdebugMessage, SCIPfreeBuffer, STP_Bitset, STP_Vectype(), stpbitset_free(), stpbitset_new(), stpbitset_setBitTrue(), StpVecClear, StpVecGetSize, StpVecPushBack, and TRUE.

Referenced by subtreesAddNew().

◆ STP_Vectype() [2/2]

static STP_Vectype ( SOLTRACE  )
static

◆ subsolUpdate()

static void subsolUpdate ( SCIP scip,
STP_Vectype(SOLTRACE combined_traces,
DPITER dpiterator,
DPSUBSOL dpsubsol 
)
static

updates existing subsol

Parameters
scipSCIP data structure
combined_tracesfor updating
dpiteratoriterator
dpsubsolto be updated

Definition at line 805 of file dpterms_core.c.

References LE, nnodes, NULL, STP_Vectype(), StpVecFree, StpVecGetSize, and StpVecPushBack.

Referenced by combineWithIntersecting().

◆ combineWithIntersecting()

static SCIP_RETCODE combineWithIntersecting ( SCIP scip,
const GRAPH graph,
int  index,
DPSOLVER dpsolver,
DPITER dpiterator 
)
static

◆ updateIncumbent()

◆ subtreesAddNewFinalize()

static SCIP_RETCODE subtreesAddNewFinalize ( SCIP scip,
const GRAPH graph,
DPSOLVER dpsolver,
DPITER dpiterator 
)
static

finalizes

Parameters
scipSCIP data structure
graphgraph
dpsolversolver
dpiteratoriterator

Definition at line 972 of file dpterms_core.c.

References dynamic_programming_solver::dpmisc, dynamic_programming_solver::dpstree, dpterms_streeInsert(), dynamic_programming_misc::global_size, NULL, SCIP_CALL, SCIP_OKAY, stpbitset_free(), stpbitset_newCopy(), StpVecGetSize, StpVecPushBack, and GRAPH::terms.

Referenced by subtreesAddNew().

◆ subtreesAddNew()

static SCIP_RETCODE subtreesAddNew ( SCIP scip,
const GRAPH graph,
DPSOLVER dpsolver,
DPITER dpiterator 
)
static

◆ propagateUBs()

static void propagateUBs ( const GRAPH graph,
DPSOLVER dpsolver,
DPITER dpiterator 
)
static

remove non-valid sub-Steiner trees

Parameters
graphgraph
dpsolversolver
dpiteratoriterator

Definition at line 1064 of file dpterms_core.c.

References csr_storage::cost, GRAPH::csr_storage, dynamic_programming_solver::dheap, EQ, graph_heap_clean(), graph_heap_correct(), graph_heap_deleteMin(), GT, csr_storage::head, GRAPH::knots, nnodes, SCIP_Real, dijkstra_heap::size, csr_storage::start, and TRUE.

Referenced by dpterms_coreSolve().

◆ subtreesRemoveNonValids()

◆ dpiterFinalizeSol()

static void dpiterFinalizeSol ( SCIP scip,
DPITER dpiterator 
)
static

frees etc.

Parameters
scipSCIP data structure
dpiteratorto update

Definition at line 1265 of file dpterms_core.c.

References dynamic_programming_iterator::dpsubsol, dpterms_dpsubsolFree(), NULL, and stpbitset_free().

Referenced by dpterms_coreSolve().

◆ dpterms_coreSolve()