Scippy

SCIP

Solving Constraint Integer Programs

extreduce_mldists.c File Reference

Detailed Description

multi-level distance storage methods for Steiner tree extended reductions

Author
Daniel Rehfeldt

This file implements utility methods for Steiner tree problem extended reduction techniques that allow use to store and retrieve (special) distances between vertices of the extension tree.

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

Definition in file extreduce_mldists.c.

#include "extreduce.h"
#include "misc_stp.h"
#include "portab.h"

Go to the source code of this file.

Data Structures

struct  multi_level_distances_storage
 

Macros

#define MLDISTS_EMPTYSLOT_NONE   -1
 

Functions

Local methods
static int mldistsGetTopLevel (const MLDISTS *mldists)
 
static int mldistsGetPosBasesStart (const MLDISTS *mldists, int level)
 
static int mldistsGetPosBasesEnd (const MLDISTS *mldists, int level)
 
static int mldistsGetPosBase (const MLDISTS *mldists, int level, int baseid)
 
static int mldistsGetPosTargetsStart (const MLDISTS *mldists, int level, int baseid)
 
static int mldistsGetPosTargets (const MLDISTS *mldists, int level, int baseid, int targetid)
 
static int mldistsGetPosEmptyTargetsStart (const MLDISTS *mldists)
 
static void mldistsTopLevelUnset (const MLDISTS *mldists)
 
Interface methods
SCIP_RETCODE extreduce_mldistsInit (SCIP *scip, int maxnlevels, int maxnslots, int maxntargets, int emptyslot_nbuffers, SCIP_Bool use_targetids, MLDISTS **mldistances)
 
void extreduce_mldistsFree (SCIP *scip, MLDISTS **mldistances)
 
SCIP_Bool extreduce_mldistsIsEmpty (const MLDISTS *mldists)
 
SCIP_Bool extreduce_mldistsEmptySlotExists (const MLDISTS *mldists)
 
int * extreduce_mldistsEmptySlotTargetIds (const MLDISTS *mldists)
 
int * extreduce_mldistsEmptySlotTargetIdsDirty (const MLDISTS *mldists)
 
SCIP_Realextreduce_mldistsEmptySlotTargetDists (const MLDISTS *mldists)
 
SCIP_Realextreduce_mldistsEmptySlotTargetDistsDirty (const MLDISTS *mldists)
 
int extreduce_mldistsEmptySlotLevel (const MLDISTS *mldists)
 
void extreduce_mldistsEmptySlotSetBase (int baseid, MLDISTS *mldists)
 
void extreduce_mldistsEmptySlotReset (MLDISTS *mldists)
 
void extreduce_mldistsEmptySlotSetFilled (MLDISTS *mldists)
 
void extreduce_mldistsLevelAddTop (int nslots, int nslottargets, MLDISTS *mldists)
 
void extreduce_mldistsLevelAddAndCloseEmpty (int nslottargets, MLDISTS *mldists)
 
void extreduce_mldistsLevelAddAndCloseRoot (int base, MLDISTS *mldists)
 
void extreduce_mldistsLevelCloseTop (MLDISTS *mldists)
 
void extreduce_mldistsLevelReopenTop (MLDISTS *mldists)
 
void extreduce_mldistsLevelRemoveTop (MLDISTS *mldists)
 
void extreduce_mldistsLevelRemoveTopNonClosed (MLDISTS *mldists)
 
int extreduce_mldistsLevelNTargets (const MLDISTS *mldists, int level)
 
int extreduce_mldistsLevelNTopTargets (const MLDISTS *mldists)
 
int extreduce_mldistsLevelNSlots (const MLDISTS *mldists, int level)
 
int extreduce_mldistsTopLevelNSlots (const MLDISTS *mldists)
 
int extreduce_mldistsNlevels (const MLDISTS *mldists)
 
int extreduce_mldistsTopLevel (const MLDISTS *mldists)
 
const int * extreduce_mldistsTopLevelBases (const MLDISTS *mldists)
 
SCIP_Bool extreduce_mldistsLevelContainsBase (const MLDISTS *mldists, int level, int baseid)
 
const int * extreduce_mldistsTargetIds (const MLDISTS *mldists, int level, int baseid)
 
const SCIP_Realextreduce_mldistsTargetDists (const MLDISTS *mldists, int level, int baseid)
 
const int * extreduce_mldistsTopTargetIds (const MLDISTS *mldists, int baseid)
 
const SCIP_Realextreduce_mldistsTopTargetDists (const MLDISTS *mldists, int baseid)
 
SCIP_Real extreduce_mldistsTopTargetDist (const MLDISTS *mldists, int baseid, int targetid)
 
SCIP_Real extreduce_mldistsTargetDist (const MLDISTS *mldists, int level, int baseid, int targetid)
 

Macro Definition Documentation

◆ MLDISTS_EMPTYSLOT_NONE

Function Documentation

◆ mldistsGetTopLevel()

◆ mldistsGetPosBasesStart()

static int mldistsGetPosBasesStart ( const MLDISTS mldists,
int  level 
)
inlinestatic

gets start of bases

Parameters
mldistsmulti-level distances
levelthe level

Definition at line 85 of file extreduce_mldists.c.

References multi_level_distances_storage::level_basestart, multi_level_distances_storage::maxnslots, and mldistsGetTopLevel().

Referenced by extreduce_mldistsTopLevelBases(), and mldistsGetPosBase().

◆ mldistsGetPosBasesEnd()

static int mldistsGetPosBasesEnd ( const MLDISTS mldists,
int  level 
)
inlinestatic

gets start of bases

Parameters
mldistsmulti-level distances
levelthe level

Definition at line 99 of file extreduce_mldists.c.

References multi_level_distances_storage::level_basestart, multi_level_distances_storage::maxnslots, and mldistsGetTopLevel().

Referenced by mldistsGetPosBase().

◆ mldistsGetPosBase()

static int mldistsGetPosBase ( const MLDISTS mldists,
int  level,
int  baseid 
)
static

Gets (internal) position of given base id, or -1 if it could not be found.

Parameters
mldistsmulti-level distances
levellevel
baseidthe base id

Definition at line 114 of file extreduce_mldists.c.

References multi_level_distances_storage::base_ids, multi_level_distances_storage::emptyslot_number, extreduce_mldistsEmptySlotExists(), mldistsGetPosBasesEnd(), mldistsGetPosBasesStart(), mldistsGetTopLevel(), and STP_MLDISTS_ID_EMPTY.

Referenced by extreduce_mldistsLevelContainsBase(), and mldistsGetPosTargetsStart().

◆ mldistsGetPosTargetsStart()

static int mldistsGetPosTargetsStart ( const MLDISTS mldists,
int  level,
int  baseid 
)
inlinestatic

◆ mldistsGetPosTargets()

static int mldistsGetPosTargets ( const MLDISTS mldists,
int  level,
int  baseid,
int  targetid 
)
inlinestatic

gets (internal) position of targets for given base id and target id

Parameters
mldistsmulti-level distances
levellevel
baseidthe base id
targetidthe target id

Definition at line 189 of file extreduce_mldists.c.

References multi_level_distances_storage::level_ntargets, mldistsGetPosTargetsStart(), multi_level_distances_storage::target_ids, and multi_level_distances_storage::target_withids.

Referenced by extreduce_mldistsTargetDist(), and extreduce_mldistsTopTargetDist().

◆ mldistsGetPosEmptyTargetsStart()

◆ mldistsTopLevelUnset()

◆ extreduce_mldistsInit()

SCIP_RETCODE extreduce_mldistsInit ( SCIP scip,
int  maxnlevels,
int  maxnslots,
int  maxntargets,
int  emptyslot_nbuffers,
SCIP_Bool  use_targetids,
MLDISTS **  mldistances 
)

◆ extreduce_mldistsFree()

◆ extreduce_mldistsIsEmpty()

SCIP_Bool extreduce_mldistsIsEmpty ( const MLDISTS mldists)

empty?

Parameters
mldistsmulti-level distances

Definition at line 372 of file extreduce_mldists.c.

References multi_level_distances_storage::nlevels.

Referenced by extreduce_extPermaIsClean(), extreduce_mldistsLevelCloseTop(), extreduce_mldistsLevelReopenTop(), and testMldistsBuilding().

◆ extreduce_mldistsEmptySlotExists()

◆ extreduce_mldistsEmptySlotTargetIds()

int* extreduce_mldistsEmptySlotTargetIds ( const MLDISTS mldists)

◆ extreduce_mldistsEmptySlotTargetIdsDirty()

int* extreduce_mldistsEmptySlotTargetIdsDirty ( const MLDISTS mldists)

gets targets IDs memory from clean slot (to be filled in)

Parameters
mldistsmulti-level distances

Definition at line 418 of file extreduce_mldists.c.

References mldistsGetPosEmptyTargetsStart(), and multi_level_distances_storage::target_ids.

Referenced by mstLevelLeafAdjustVerticalSDs().

◆ extreduce_mldistsEmptySlotTargetDists()

SCIP_Real* extreduce_mldistsEmptySlotTargetDists ( const MLDISTS mldists)

Gets targets distances memory from clean slot (to be filled in). NOTE: Can only be called as long as this empty slots' distances have not not modified!

Parameters
mldistsmulti-level distances

Definition at line 432 of file extreduce_mldists.c.

References EQ, multi_level_distances_storage::level_ntargets, mldistsGetPosEmptyTargetsStart(), mldistsGetTopLevel(), STP_MLDISTS_DIST_UNSET, and multi_level_distances_storage::target_dists.

Referenced by mstLevelHorizontalAddSds(), mstLevelLeafSetVerticalSDsBoth(), and testMldistsBuilding().

◆ extreduce_mldistsEmptySlotTargetDistsDirty()

SCIP_Real* extreduce_mldistsEmptySlotTargetDistsDirty ( const MLDISTS mldists)

Gets targets distances memory from empty slot. NOTE: This method does not make sure that the distances are clean! (i.e. not already set)

Parameters
mldistsmulti-level distances

Definition at line 454 of file extreduce_mldists.c.

References mldistsGetPosEmptyTargetsStart(), and multi_level_distances_storage::target_dists.

Referenced by mstLevelLeafAdjustVerticalSDs(), and mstLevelLeafTryExtMst().

◆ extreduce_mldistsEmptySlotLevel()

int extreduce_mldistsEmptySlotLevel ( const MLDISTS mldists)

gets level of current empty slot

Parameters
mldistsmulti-level distances

Definition at line 466 of file extreduce_mldists.c.

References extreduce_mldistsEmptySlotExists(), and mldistsGetTopLevel().

◆ extreduce_mldistsEmptySlotSetBase()

◆ extreduce_mldistsEmptySlotReset()

◆ extreduce_mldistsEmptySlotSetFilled()

◆ extreduce_mldistsLevelAddTop()

◆ extreduce_mldistsLevelAddAndCloseEmpty()

void extreduce_mldistsLevelAddAndCloseEmpty ( int  nslottargets,
MLDISTS mldists 
)

adds dummy level

Parameters
nslottargetsnumber of targets per slot
mldistsmulti-level distances

Definition at line 594 of file extreduce_mldists.c.

References extreduce_mldistsEmptySlotSetBase(), extreduce_mldistsEmptySlotSetFilled(), extreduce_mldistsLevelAddTop(), extreduce_mldistsLevelCloseTop(), and STP_MLDISTS_ID_EMPTY.

Referenced by extreduce_mstLevelHorizontalAddEmpty(), and extreduce_mstLevelVerticalAddEmpty().

◆ extreduce_mldistsLevelAddAndCloseRoot()

void extreduce_mldistsLevelAddAndCloseRoot ( int  base,
MLDISTS mldists 
)

adds root level of slots

Parameters
basethe base
mldistsmulti-level distances

Definition at line 609 of file extreduce_mldists.c.

References extreduce_mldistsEmptySlotSetBase(), extreduce_mldistsEmptySlotSetFilled(), extreduce_mldistsLevelAddTop(), and extreduce_mldistsLevelCloseTop().

Referenced by mstAddRootLevelSDs().

◆ extreduce_mldistsLevelCloseTop()

◆ extreduce_mldistsLevelReopenTop()

◆ extreduce_mldistsLevelRemoveTop()

void extreduce_mldistsLevelRemoveTop ( MLDISTS mldists)

◆ extreduce_mldistsLevelRemoveTopNonClosed()

void extreduce_mldistsLevelRemoveTopNonClosed ( MLDISTS mldists)

removes top level of slots, which is not yet closed

Parameters
mldistsmulti-level distances

Definition at line 712 of file extreduce_mldists.c.

References multi_level_distances_storage::emptyslot_number, extreduce_mldistsEmptySlotExists(), MLDISTS_EMPTYSLOT_NONE, mldistsTopLevelUnset(), and multi_level_distances_storage::nlevels.

◆ extreduce_mldistsLevelNTargets()

int extreduce_mldistsLevelNTargets ( const MLDISTS mldists,
int  level 
)

gets number of targets (per slots) for given level

Parameters
mldistsmulti-level distances
levellevel

Definition at line 730 of file extreduce_mldists.c.

References multi_level_distances_storage::level_maxntargets, multi_level_distances_storage::level_ntargets, and mldistsGetTopLevel().

Referenced by baseMstInitMsts(), compRootDistsUpdateLeavesDists(), and extreduce_mldistsLevelNTopTargets().

◆ extreduce_mldistsLevelNTopTargets()

int extreduce_mldistsLevelNTopTargets ( const MLDISTS mldists)

gets number of targets (per slots) for top level

Parameters
mldistsmulti-level distances

Definition at line 743 of file extreduce_mldists.c.

References extreduce_mldistsLevelNTargets(), and mldistsGetTopLevel().

Referenced by compMstInitMsts(), compUpDistUpdateLeavesDists(), extreduce_mstLevelVerticalReopen(), mstCompLeafGetSDsToAncestors(), mstCompLeafGetSDsToSiblings(), and mstCompLeafToAncestorsBiasedRuleOut().

◆ extreduce_mldistsLevelNSlots()

int extreduce_mldistsLevelNSlots ( const MLDISTS mldists,
int  level 
)

gets number of slots for given level

Parameters
mldistsmulti-level distances
levellevel

Definition at line 754 of file extreduce_mldists.c.

References multi_level_distances_storage::level_basestart, multi_level_distances_storage::level_maxnslots, and mldistsGetTopLevel().

Referenced by extreduce_mldistsEmptySlotSetFilled(), extreduce_mldistsTopLevelNSlots(), and extreduce_mstLevelVerticalClose().

◆ extreduce_mldistsTopLevelNSlots()

int extreduce_mldistsTopLevelNSlots ( const MLDISTS mldists)

gets number of slots for top level

Parameters
mldistsmulti-level distances

Definition at line 769 of file extreduce_mldists.c.

References extreduce_mldistsLevelNSlots(), and extreduce_mldistsTopLevel().

Referenced by extreduce_mstInternalsInSync(), extreduce_mstLevelClose(), and extreduce_printTopLevel().

◆ extreduce_mldistsNlevels()

int extreduce_mldistsNlevels ( const MLDISTS mldists)

◆ extreduce_mldistsTopLevel()

◆ extreduce_mldistsTopLevelBases()

const int* extreduce_mldistsTopLevelBases ( const MLDISTS mldists)

gets top level bases

Parameters
mldistsmulti-level distances

Definition at line 802 of file extreduce_mldists.c.

References multi_level_distances_storage::base_ids, mldistsGetPosBasesStart(), and mldistsGetTopLevel().

Referenced by extreduce_printTopLevel().

◆ extreduce_mldistsLevelContainsBase()

SCIP_Bool extreduce_mldistsLevelContainsBase ( const MLDISTS mldists,
int  level,
int  baseid 
)

is the base contained in a slot of the given level?

Parameters
mldistsmulti-level distances
levellevel
baseidthe base id

Definition at line 814 of file extreduce_mldists.c.

References mldistsGetPosBase(), and mldistsGetTopLevel().

Referenced by extStackTopCollectExtEdges(), and mldistsGetPosTargetsStart().

◆ extreduce_mldistsTargetIds()

const int* extreduce_mldistsTargetIds ( const MLDISTS mldists,
int  level,
int  baseid 
)

gets targets ids

Parameters
mldistsmulti-level distances
levellevel
baseidthe base

Definition at line 829 of file extreduce_mldists.c.

References mldistsGetPosTargetsStart(), multi_level_distances_storage::target_ids, and multi_level_distances_storage::target_withids.

Referenced by compRootDistsUpdateLeavesDists(), and extreduce_mldistsTopTargetIds().

◆ extreduce_mldistsTargetDists()

const SCIP_Real* extreduce_mldistsTargetDists ( const MLDISTS mldists,
int  level,
int  baseid 
)

gets targets distances

Parameters
mldistsmulti-level distances
levellevel
baseidthe base

Definition at line 845 of file extreduce_mldists.c.

References mldistsGetPosTargetsStart(), and multi_level_distances_storage::target_dists.

Referenced by baseMstGetAdjcosts(), and compRootDistsUpdateLeavesDists().

◆ extreduce_mldistsTopTargetIds()

const int* extreduce_mldistsTopTargetIds ( const MLDISTS mldists,
int  baseid 
)

Gets targets ids

Parameters
mldistsmulti-level distances
baseidthe base

Definition at line 863 of file extreduce_mldists.c.

References extreduce_mldistsTargetIds(), and mldistsGetTopLevel().

Referenced by compUpDistUpdateLeavesDists(), and extreduce_sdsverticalInSync().

◆ extreduce_mldistsTopTargetDists()

const SCIP_Real* extreduce_mldistsTopTargetDists ( const MLDISTS mldists,
int  baseid 
)

◆ extreduce_mldistsTopTargetDist()

SCIP_Real extreduce_mldistsTopTargetDist ( const MLDISTS mldists,
int  baseid,
int  targetid 
)

gets (one!) target distance for given target ID and base ID

Parameters
mldistsmulti-level distances
baseidthe base
targetidthe identifier

Definition at line 885 of file extreduce_mldists.c.

References GE, mldistsGetPosTargets(), mldistsGetTopLevel(), and multi_level_distances_storage::target_dists.

Referenced by extreduce_sdshorizontalInSync(), mst3LeafTreeGetSds(), mstCompLeafGetSDsToSiblings(), mstCompLeafToSiblingsBiasedRuleOut(), and mstLevelHorizontalAddSds().

◆ extreduce_mldistsTargetDist()

SCIP_Real extreduce_mldistsTargetDist ( const MLDISTS mldists,
int  level,
int  baseid,
int  targetid 
)

gets (one!) target distance for given level, target ID and base ID

Parameters
mldistsmulti-level distances
levellevel
baseidthe base
targetidthe identifier

Definition at line 904 of file extreduce_mldists.c.

References GE, mldistsGetPosTargets(), mldistsGetTopLevel(), and multi_level_distances_storage::target_dists.

Referenced by baseMstGetAdjcosts().