Scippy

GCG

Branch-and-Price & Column Generation for Everyone

dec_hrgpartition.cpp File Reference

Detailed Description

arrowhead and bordered detector via graph partitioning (uses hmetis)

Author
Martin Bergner

Detects arrowhead (double bordered) decompositions as well as decompositions with only linking variables or linking constraints.

This detector needs hmetis and works only under Linux/MacOS, it further needs the Z-shell (zsh) to enforce memory and time limits on hmetis as this is the only shell reliably doing that.

Definition in file dec_hrgpartition.cpp.

#include "gcg/dec_hrgpartition.h"
#include <cassert>
#include <cstring>
#include <cerrno>
#include <unistd.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include "gcg/cons_decomp.h"
#include "gcg/struct_decomp.h"
#include "gcg/pub_decomp.h"
#include "gcg/scip_misc.h"
#include "scip/pub_misc.h"
#include "scip/cons_linear.h"
#include "scip/cons_setppc.h"
#include "graph/matrixgraph.h"
#include "graph/hyperrowgraph.h"
#include "graph/graph_tclique.h"
#include "graph/weights.h"
#include "gcg/class_partialdecomp.h"
#include "gcg/class_detprobdata.h"
#include "scip/clock.h"
#include <set>

Go to the source code of this file.

Data Structures

struct  GCG_DetectorData
 

Macros

#define HMETIS_EXECUTABLE   "hmetis"
 
#define DEC_NAME   "hrgpartition"
 
#define DEC_DESC   "enforces arrowhead structures using graph partitioning"
 
#define DEC_FREQCALLROUND   1
 
#define DEC_MAXCALLROUND   0
 
#define DEC_MINCALLROUND   0
 
#define DEC_FREQCALLROUNDORIGINAL   1
 
#define DEC_MAXCALLROUNDORIGINAL   0
 
#define DEC_MINCALLROUNDORIGINAL   0
 
#define DEC_PRIORITY   1000
 
#define DEC_DECCHAR   'r'
 
#define DEC_ENABLED   FALSE
 
#define DEC_ENABLEDFINISHING   FALSE
 
#define DEC_ENABLEDPOSTPROCESSING   FALSE
 
#define DEC_SKIP   FALSE
 
#define DEC_USEFULRECALL   TRUE
 
#define DEFAULT_VARWEIGHT   1
 
#define DEFAULT_VARWEIGHTBIN   2
 
#define DEFAULT_VARWEIGHTINT   2
 
#define DEFAULT_VARWEIGHTIMPL   2
 
#define DEFAULT_VARWEIGHTCONT   1
 
#define DEFAULT_CONSWEIGHT   5
 
#define DEFAULT_RANDSEED   1
 
#define DEFAULT_TIDY   TRUE
 
#define DEFAULT_DUMMYNODES   0.2
 
#define DEFAULT_CONSWEIGHT_SETPPC   5
 
#define DEFAULT_LIMITNCONSSNVARSDEFAULT   10000
 
#define DEFAULT_ENABLEDFORLARGEPROBLEMS   FALSE /** should this detector be enabled even the limit nconssnvars is exceeded */
 
#define DEFAULT_MAXNBLOCKCANDIDATES   3
 
#define DEFAULT_ALPHA   0.0
 
#define DEFAULT_BETA   0.5
 
#define DEFAULT_METIS_UBFACTOR   5.0
 
#define DEFAULT_METIS_VERBOSE   FALSE
 
#define DEFAULT_METISUSEPTYPE_RB   TRUE
 
#define DEFAULT_REALNAME   FALSE
 
#define DEFAULT_TYPE   'r'
 
#define DEFAULT_FALLBACK_NBLOCKS   8
 
#define SET_MULTIPLEFORSIZETRANSF   12500
 
#define finishPartialdecHrgpartition   NULL
 
#define detectorPostprocessPartialdecHrgpartition   NULL
 

Functions

static GCG_DECL_FREEDETECTOR (freeHrgpartition)
 
static GCG_DECL_INITDETECTOR (initHrgpartition)
 
static GCG_DECL_EXITDETECTOR (exitHrgpartition)
 
static SCIP_RETCODE callMetis (GCG *gcg, GCG_DETECTORDATA *detectordata, MatrixGraph< gcg::GraphTclique > *graph, char tempfile[SCIP_MAXSTRLEN], int nblocks, SCIP_RESULT *result)
 
static SCIP_RETCODE createMetisFile (GCG *gcg, GCG_DETECTORDATA *detectordata, int partialdecID, MatrixGraph< gcg::GraphTclique > *graph, char tempfile[SCIP_MAXSTRLEN])
 
static bool connected (gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec)
 
static SCIP_RETCODE detection (GCG *gcg, GCG_DETECTORDATA *detectordata, Partialdec_Detection_Data *partialdecdetectiondata, gcg::PARTIALDECOMP *partialdec, bool allowopenpartialdecs, SCIP_RESULT *result)
 
static GCG_DECL_PROPAGATEPARTIALDEC (propagatePartialdecHrgpartition)
 
static GCG_DECL_SETPARAMAGGRESSIVE (setParamAggressiveHrgpartition)
 
static GCG_DECL_SETPARAMDEFAULT (setParamDefaultHrgpartition)
 
static GCG_DECL_SETPARAMFAST (setParamFastHrgpartition)
 
SCIP_RETCODE GCGincludeDetectorHrgpartition (GCG *gcg)
 

Macro Definition Documentation

◆ HMETIS_EXECUTABLE

#define HMETIS_EXECUTABLE   "hmetis"

Definition at line 59 of file dec_hrgpartition.cpp.

◆ DEC_NAME

#define DEC_NAME   "hrgpartition"

name of the detector

Definition at line 84 of file dec_hrgpartition.cpp.

◆ DEC_DESC

#define DEC_DESC   "enforces arrowhead structures using graph partitioning"

description of detector

Definition at line 85 of file dec_hrgpartition.cpp.

◆ DEC_FREQCALLROUND

#define DEC_FREQCALLROUND   1

frequency the detector gets called in detection loop ,ie it is called in round r if and only if minCallRound <= r <= maxCallRound AND (r - minCallRound) mod freqCallRound == 0

Definition at line 86 of file dec_hrgpartition.cpp.

◆ DEC_MAXCALLROUND

#define DEC_MAXCALLROUND   0

last round the detector gets called

Definition at line 87 of file dec_hrgpartition.cpp.

◆ DEC_MINCALLROUND

#define DEC_MINCALLROUND   0

first round the detector gets called

Definition at line 88 of file dec_hrgpartition.cpp.

◆ DEC_FREQCALLROUNDORIGINAL

#define DEC_FREQCALLROUNDORIGINAL   1

frequency the detector gets called in detection loop while detecting the original problem

Definition at line 89 of file dec_hrgpartition.cpp.

◆ DEC_MAXCALLROUNDORIGINAL

#define DEC_MAXCALLROUNDORIGINAL   0

last round the detector gets called while detecting the original problem

Definition at line 90 of file dec_hrgpartition.cpp.

◆ DEC_MINCALLROUNDORIGINAL

#define DEC_MINCALLROUNDORIGINAL   0

first round the detector gets called while detecting the original problem

Definition at line 91 of file dec_hrgpartition.cpp.

◆ DEC_PRIORITY

#define DEC_PRIORITY   1000

priority of the detector

Definition at line 92 of file dec_hrgpartition.cpp.

◆ DEC_DECCHAR

#define DEC_DECCHAR   'r'

display character of detector

Definition at line 93 of file dec_hrgpartition.cpp.

◆ DEC_ENABLED

#define DEC_ENABLED   FALSE

should detector be called by default

Definition at line 94 of file dec_hrgpartition.cpp.

◆ DEC_ENABLEDFINISHING

#define DEC_ENABLEDFINISHING   FALSE

should the finishing be enabled

Definition at line 95 of file dec_hrgpartition.cpp.

◆ DEC_ENABLEDPOSTPROCESSING

#define DEC_ENABLEDPOSTPROCESSING   FALSE

should the postprocessing be enabled

Definition at line 96 of file dec_hrgpartition.cpp.

◆ DEC_SKIP

#define DEC_SKIP   FALSE

should detector be skipped if others found detections

Definition at line 97 of file dec_hrgpartition.cpp.

◆ DEC_USEFULRECALL

#define DEC_USEFULRECALL   TRUE

is it useful to call this detector on a descendant of the propagated partialdec

Definition at line 98 of file dec_hrgpartition.cpp.

◆ DEFAULT_VARWEIGHT

#define DEFAULT_VARWEIGHT   1

weight for variable nodes

Definition at line 102 of file dec_hrgpartition.cpp.

◆ DEFAULT_VARWEIGHTBIN

#define DEFAULT_VARWEIGHTBIN   2

weight for binary variable nodes

Definition at line 103 of file dec_hrgpartition.cpp.

◆ DEFAULT_VARWEIGHTINT

#define DEFAULT_VARWEIGHTINT   2

weight for integer variable nodes

Definition at line 104 of file dec_hrgpartition.cpp.

◆ DEFAULT_VARWEIGHTIMPL

#define DEFAULT_VARWEIGHTIMPL   2

weight for implicit integer variable nodes

Definition at line 105 of file dec_hrgpartition.cpp.

◆ DEFAULT_VARWEIGHTCONT

#define DEFAULT_VARWEIGHTCONT   1

weight for continous variable nodes

Definition at line 106 of file dec_hrgpartition.cpp.

◆ DEFAULT_CONSWEIGHT

#define DEFAULT_CONSWEIGHT   5

weight for constraint hyperedges

Definition at line 107 of file dec_hrgpartition.cpp.

◆ DEFAULT_RANDSEED

#define DEFAULT_RANDSEED   1

random seed for the hmetis call

Definition at line 108 of file dec_hrgpartition.cpp.

◆ DEFAULT_TIDY

#define DEFAULT_TIDY   TRUE

whether to clean up afterwards

Definition at line 109 of file dec_hrgpartition.cpp.

◆ DEFAULT_DUMMYNODES

#define DEFAULT_DUMMYNODES   0.2

percentage of dummy vertices

Definition at line 110 of file dec_hrgpartition.cpp.

◆ DEFAULT_CONSWEIGHT_SETPPC

#define DEFAULT_CONSWEIGHT_SETPPC   5

weight for constraint hyperedges that are setpartitioning or covering constraints

Definition at line 112 of file dec_hrgpartition.cpp.

◆ DEFAULT_LIMITNCONSSNVARSDEFAULT

#define DEFAULT_LIMITNCONSSNVARSDEFAULT   10000

limit for sum of nvars and nconss for enabling this detector in default

Definition at line 114 of file dec_hrgpartition.cpp.

◆ DEFAULT_ENABLEDFORLARGEPROBLEMS

#define DEFAULT_ENABLEDFORLARGEPROBLEMS   FALSE /** should this detector be enabled even the limit nconssnvars is exceeded */

Definition at line 115 of file dec_hrgpartition.cpp.

◆ DEFAULT_MAXNBLOCKCANDIDATES

#define DEFAULT_MAXNBLOCKCANDIDATES   3

number of block number candidates to be considered

Definition at line 117 of file dec_hrgpartition.cpp.

◆ DEFAULT_ALPHA

#define DEFAULT_ALPHA   0.0

factor for standard deviation of constraint weights

Definition at line 118 of file dec_hrgpartition.cpp.

◆ DEFAULT_BETA

#define DEFAULT_BETA   0.5

factor of how the weight for equality and inequality constraints is distributed (keep 1/2 for the same on both)

Definition at line 120 of file dec_hrgpartition.cpp.

◆ DEFAULT_METIS_UBFACTOR

#define DEFAULT_METIS_UBFACTOR   5.0

default unbalance factor given to metis on the commandline

Definition at line 121 of file dec_hrgpartition.cpp.

◆ DEFAULT_METIS_VERBOSE

#define DEFAULT_METIS_VERBOSE   FALSE

should metis be verbose

Definition at line 122 of file dec_hrgpartition.cpp.

◆ DEFAULT_METISUSEPTYPE_RB

#define DEFAULT_METISUSEPTYPE_RB   TRUE

Should metis use the rb or kway partitioning algorithm

Definition at line 123 of file dec_hrgpartition.cpp.

◆ DEFAULT_REALNAME

#define DEFAULT_REALNAME   FALSE

whether the metis name should be real or temporary

Definition at line 124 of file dec_hrgpartition.cpp.

◆ DEFAULT_TYPE

#define DEFAULT_TYPE   'r'

type of the decomposition 'c' column hypergraph (single bordered, no linking constraints), 'r' row hypergraph (single bordered, no linking variables) and 'a' column-row hypergraph (arrowhead)

Definition at line 127 of file dec_hrgpartition.cpp.

◆ DEFAULT_FALLBACK_NBLOCKS

#define DEFAULT_FALLBACK_NBLOCKS   8

Definition at line 128 of file dec_hrgpartition.cpp.

◆ SET_MULTIPLEFORSIZETRANSF

#define SET_MULTIPLEFORSIZETRANSF   12500

Definition at line 129 of file dec_hrgpartition.cpp.

◆ finishPartialdecHrgpartition

#define finishPartialdecHrgpartition   NULL

Definition at line 630 of file dec_hrgpartition.cpp.

◆ detectorPostprocessPartialdecHrgpartition

#define detectorPostprocessPartialdecHrgpartition   NULL

Definition at line 631 of file dec_hrgpartition.cpp.

Function Documentation

◆ GCG_DECL_FREEDETECTOR()

static GCG_DECL_FREEDETECTOR ( freeHrgpartition  )
static

destructor of detector to free user data (called when GCG is exiting)

Definition at line 185 of file dec_hrgpartition.cpp.

References DEC_NAME, GCGdetectorGetData(), GCGdetectorGetName(), GCGgetOrigprob(), NULL, SCIP_OKAY, and SCIPfreeMemory.

◆ GCG_DECL_INITDETECTOR()

static GCG_DECL_INITDETECTOR ( initHrgpartition  )
static

detector initialization method

Definition at line 204 of file dec_hrgpartition.cpp.

References DEC_NAME, GCGdetectorGetName(), NULL, and SCIP_OKAY.

◆ GCG_DECL_EXITDETECTOR()

static GCG_DECL_EXITDETECTOR ( exitHrgpartition  )
static

presolving deinitialization method of presolver (called after presolving has been finished)

Definition at line 215 of file dec_hrgpartition.cpp.

References DEC_NAME, GCGdetectorGetName(), NULL, and SCIP_OKAY.

◆ callMetis()

static SCIP_RETCODE callMetis ( GCG *  gcg,
GCG_DETECTORDATA *  detectordata,
MatrixGraph< gcg::GraphTclique > *  graph,
char  tempfile[SCIP_MAXSTRLEN],
int  nblocks,
SCIP_RESULT *  result 
)
static

will call hmetis via a system call

Parameters
gcgGCG data struture
detectordatapresolver data data structure
graphthe graph of the matrix
tempfilefilename for the metis input file
nblocksnumber of blocks
resultresult indicating whether the detection was successful

Definition at line 228 of file dec_hrgpartition.cpp.

References GCGgetOrigprob(), GCGgetRemainingTime(), HMETIS_EXECUTABLE, GCG_DetectorData::metisubfactor, GCG_DetectorData::metisuseptyperb, GCG_DetectorData::metisverbose, NULL, GCG_DetectorData::randomseed, gcg::MatrixGraph< T >::readPartition(), SCIP_CALL, SCIP_DIDNOTRUN, SCIP_ERROR, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_SUCCESS, SCIP_VERBLEVEL_NORMAL, SCIP_WRITEERROR, SCIPcreateWallClock(), SCIPdebugMessage, SCIPerrorMessage, SCIPfreeClock(), SCIPgetClockTime(), SCIPinfoMessage(), SCIPisInfinity(), SCIPsnprintf(), SCIPstartClock(), SCIPstopClock(), SCIPverbMessage(), and GCG_DetectorData::tidy.

Referenced by detection().

◆ createMetisFile()

static SCIP_RETCODE createMetisFile ( GCG *  gcg,
GCG_DETECTORDATA *  detectordata,
int  partialdecID,
MatrixGraph< gcg::GraphTclique > *  graph,
char  tempfile[SCIP_MAXSTRLEN] 
)
static

creates the temporary metis input file

Parameters
gcgGCG data struture
detectordatadetector data structure
partialdecIDID of partial decomposition to be used
graphthe graph of the matrix
tempfilefilename for the metis input file

Definition at line 335 of file dec_hrgpartition.cpp.

References DEC_DECCHAR, GCG_DetectorData::dummynodes, GCGgetOrigprob(), gcg::MatrixGraph< T >::getNNonzeroes(), GCG_DetectorData::realname, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPceil(), SCIPgetProbName(), SCIPsnprintf(), gcg::MatrixGraph< T >::setDummynodes(), TRUE, and gcg::MatrixGraph< T >::writeToFile().

Referenced by detection().

◆ connected()

◆ detection()

static SCIP_RETCODE detection ( GCG *  gcg,
GCG_DETECTORDATA *  detectordata,
Partialdec_Detection_Data *  partialdecdetectiondata,
gcg::PARTIALDECOMP *  partialdec,
bool  allowopenpartialdecs,
SCIP_RESULT *  result 
)
static

detection function for partialdecs

< filename for the metis input file

Parameters
gcgGCG data structure
detectordatadetectordata of the detector
partialdecdetectiondatapartialdecdetectiondata (including the detprobdata) where to store the new Partialdecs
partialdecpartialdec to propagate
allowopenpartialdecswhether new partialdecs should be stored in which this detector only assignes conss to master
resultpointer where to store the result

Definition at line 423 of file dec_hrgpartition.cpp.

References gcg::PARTIALDECOMP::addClockTime(), gcg::PARTIALDECOMP::addDetectorChainInfo(), callMetis(), gcg::PARTIALDECOMP::considerImplicits(), GCG_DetectorData::consWeight, gcg::MatrixGraph< T >::createFromPartialMatrix(), createMetisFile(), gcg::MatrixGraph< T >::createPartialdecFromPartition(), DEC_NAME, DEFAULT_FALLBACK_NBLOCKS, Partialdec_Detection_Data::detprobdata, GCG_DetectorData::found, GCGgetOrigprob(), gcg::PARTIALDECOMP::getID(), gcg::PARTIALDECOMP::getNBlocks(), gcg::PARTIALDECOMP::getNOpenvars(), gcg::DETPROBDATA::getSortedCandidatesNBlocks(), MIN, Partialdec_Detection_Data::newpartialdecs, Partialdec_Detection_Data::nnewpartialdecs, NULL, gcg::PARTIALDECOMP::refineToBlocks(), SCIP_CALL, SCIP_CALL_ABORT, SCIP_DIDNOTFIND, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_SUCCESS, SCIP_VERBLEVEL_NORMAL, SCIP_WRITEERROR, SCIPallocMemoryArray, SCIPcreateClock(), SCIPdebugMessage, SCIPerrorMessage, SCIPfreeClock(), SCIPfreeMemoryArray, SCIPgetClockTime(), SCIPgetIntParam(), SCIPresetClock(), SCIPsnprintf(), SCIPstartClock(), SCIPstopClock(), SCIPverbMessage(), GCG_DetectorData::tidy, TRUE, GCG_DetectorData::varWeight, GCG_DetectorData::varWeightBinary, GCG_DetectorData::varWeightContinous, GCG_DetectorData::varWeightInteger, and w.

Referenced by GCG_DECL_PROPAGATEPARTIALDEC().

◆ GCG_DECL_PROPAGATEPARTIALDEC()

◆ GCG_DECL_SETPARAMAGGRESSIVE()

◆ GCG_DECL_SETPARAMDEFAULT()

◆ GCG_DECL_SETPARAMFAST()

◆ GCGincludeDetectorHrgpartition()

SCIP_RETCODE GCGincludeDetectorHrgpartition ( GCG *  gcg)

creates the hrgpartition presolver and includes it in SCIP

Parameters
gcgGCG data structure

Definition at line 778 of file dec_hrgpartition.cpp.

References GCG_DetectorData::alpha, GCG_DetectorData::beta, GCG_DetectorData::consWeight, GCG_DetectorData::consWeightSetppc, DEC_DECCHAR, DEC_DESC, DEC_ENABLED, DEC_ENABLEDFINISHING, DEC_ENABLEDPOSTPROCESSING, DEC_FREQCALLROUND, DEC_FREQCALLROUNDORIGINAL, DEC_MAXCALLROUND, DEC_MAXCALLROUNDORIGINAL, DEC_MINCALLROUND, DEC_MINCALLROUNDORIGINAL, DEC_NAME, DEC_PRIORITY, DEC_SKIP, DEC_USEFULRECALL, DEFAULT_ALPHA, DEFAULT_BETA, DEFAULT_CONSWEIGHT, DEFAULT_CONSWEIGHT_SETPPC, DEFAULT_DUMMYNODES, DEFAULT_ENABLEDFORLARGEPROBLEMS, DEFAULT_LIMITNCONSSNVARSDEFAULT, DEFAULT_MAXNBLOCKCANDIDATES, DEFAULT_METIS_UBFACTOR, DEFAULT_METIS_VERBOSE, DEFAULT_METISUSEPTYPE_RB, DEFAULT_RANDSEED, DEFAULT_REALNAME, DEFAULT_TIDY, DEFAULT_VARWEIGHT, DEFAULT_VARWEIGHTBIN, DEFAULT_VARWEIGHTCONT, DEFAULT_VARWEIGHTIMPL, DEFAULT_VARWEIGHTINT, detectorPostprocessPartialdecHrgpartition, GCG_DetectorData::dummynodes, GCG_DetectorData::enabledforlargeproblems, FALSE, finishPartialdecHrgpartition, GCG_DetectorData::found, GCGgetOrigprob(), GCGincludeDetector(), GCG_DetectorData::limitnconssnvarsdefault, GCG_DetectorData::maxnblockcandidates, GCG_DetectorData::metisubfactor, GCG_DetectorData::metisuseptyperb, GCG_DetectorData::metisverbose, NULL, GCG_DetectorData::randomseed, GCG_DetectorData::realname, SCIP_CALL, SCIP_OKAY, SCIPaddBoolParam(), SCIPaddIntParam(), SCIPaddRealParam(), SCIPallocMemory, GCG_DetectorData::tidy, TRUE, GCG_DetectorData::varWeight, GCG_DetectorData::varWeightBinary, GCG_DetectorData::varWeightContinous, GCG_DetectorData::varWeightImplint, and GCG_DetectorData::varWeightInteger.

Referenced by GCGincludeGcgPlugins().