Scippy

GCG

Branch-and-Price & Column Generation for Everyone

dec_hrcgpartition.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_hrcgpartition.cpp.

#include "gcg/dec_hrcgpartition.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/hyperrowcolgraph.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   "hrcgpartition"
 
#define DEC_DESC   "enforces arrowhead structures using graph partitioning"
 
#define DEC_FREQCALLROUND   1
 
#define DEC_MAXCALLROUND   1
 
#define DEC_MINCALLROUND   0
 
#define DEC_FREQCALLROUNDORIGINAL   1
 
#define DEC_MAXCALLROUNDORIGINAL   1
 
#define DEC_MINCALLROUNDORIGINAL   0
 
#define DEC_PRIORITY   1000
 
#define DEC_DECCHAR   'a'
 
#define DEC_ENABLED   FALSE
 
#define DEC_ENABLEDFINISHING   FALSE
 
#define DEC_ENABLEDPOSTPROCESSING   FALSE
 
#define DEC_SKIP   FALSE
 
#define DEC_USEFULRECALL   TRUE
 
#define DEFAULT_VARWEIGHT   2
 
#define DEFAULT_VARWEIGHTBIN   3
 
#define DEFAULT_VARWEIGHTINT   3
 
#define DEFAULT_VARWEIGHTIMPL   3
 
#define DEFAULT_VARWEIGHTCONT   2
 
#define DEFAULT_CONSWEIGHT   1
 
#define DEFAULT_RANDSEED   1
 
#define DEFAULT_TIDY   TRUE
 
#define DEFAULT_DUMMYNODES   0.2
 
#define DEFAULT_CONSWEIGHT_SETPPC   5
 
#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   'a'
 
#define FAST_MAXHALFPERIMETER   25000
 
#define SET_MULTIPLEFORSIZETRANSF   12500
 
#define detectorPostprocessPartialdecHrcgpartition   NULL
 

Functions

static GCG_DECL_FREEDETECTOR (freeHrcgpartition)
 
static GCG_DECL_INITDETECTOR (initHrcgpartition)
 
static GCG_DECL_EXITDETECTOR (exitHrcgpartition)
 
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 (SCIP *scip, 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 (propagatePartialdecHrcgpartition)
 
static GCG_DECL_FINISHPARTIALDEC (finishPartialdecHrcgpartition)
 
static GCG_DECL_SETPARAMAGGRESSIVE (setParamAggressiveHrcgpartition)
 
static GCG_DECL_SETPARAMDEFAULT (setParamDefaultHrcgpartition)
 
static GCG_DECL_SETPARAMFAST (setParamFastHrcgpartition)
 
SCIP_RETCODE GCGincludeDetectorHrcgpartition (GCG *gcg)
 

Macro Definition Documentation

◆ HMETIS_EXECUTABLE

#define HMETIS_EXECUTABLE   "hmetis"

Definition at line 58 of file dec_hrcgpartition.cpp.

◆ DEC_NAME

#define DEC_NAME   "hrcgpartition"

name of the detector

Definition at line 83 of file dec_hrcgpartition.cpp.

◆ DEC_DESC

#define DEC_DESC   "enforces arrowhead structures using graph partitioning"

description of detector

Definition at line 84 of file dec_hrcgpartition.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 85 of file dec_hrcgpartition.cpp.

◆ DEC_MAXCALLROUND

#define DEC_MAXCALLROUND   1

last round the detector gets called

Definition at line 86 of file dec_hrcgpartition.cpp.

◆ DEC_MINCALLROUND

#define DEC_MINCALLROUND   0

first round the detector gets called

Definition at line 87 of file dec_hrcgpartition.cpp.

◆ DEC_FREQCALLROUNDORIGINAL

#define DEC_FREQCALLROUNDORIGINAL   1

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

Definition at line 88 of file dec_hrcgpartition.cpp.

◆ DEC_MAXCALLROUNDORIGINAL

#define DEC_MAXCALLROUNDORIGINAL   1

last round the detector gets called while detecting the original problem

Definition at line 89 of file dec_hrcgpartition.cpp.

◆ DEC_MINCALLROUNDORIGINAL

#define DEC_MINCALLROUNDORIGINAL   0

first round the detector gets called while detecting the original problem

Definition at line 90 of file dec_hrcgpartition.cpp.

◆ DEC_PRIORITY

#define DEC_PRIORITY   1000

priority of the detector

Definition at line 91 of file dec_hrcgpartition.cpp.

◆ DEC_DECCHAR

#define DEC_DECCHAR   'a'

display character of detector

Definition at line 92 of file dec_hrcgpartition.cpp.

◆ DEC_ENABLED

#define DEC_ENABLED   FALSE

should detector be called by default

Definition at line 93 of file dec_hrcgpartition.cpp.

◆ DEC_ENABLEDFINISHING

#define DEC_ENABLEDFINISHING   FALSE

should the finishing be enabled

Definition at line 94 of file dec_hrcgpartition.cpp.

◆ DEC_ENABLEDPOSTPROCESSING

#define DEC_ENABLEDPOSTPROCESSING   FALSE

should the postprocessing be enabled

Definition at line 95 of file dec_hrcgpartition.cpp.

◆ DEC_SKIP

#define DEC_SKIP   FALSE

should detector be skipped if others found detections

Definition at line 96 of file dec_hrcgpartition.cpp.

◆ DEC_USEFULRECALL

#define DEC_USEFULRECALL   TRUE

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

Definition at line 97 of file dec_hrcgpartition.cpp.

◆ DEFAULT_VARWEIGHT

#define DEFAULT_VARWEIGHT   2

weight for variable nodes

Definition at line 101 of file dec_hrcgpartition.cpp.

◆ DEFAULT_VARWEIGHTBIN

#define DEFAULT_VARWEIGHTBIN   3

weight for binary variable nodes

Definition at line 102 of file dec_hrcgpartition.cpp.

◆ DEFAULT_VARWEIGHTINT

#define DEFAULT_VARWEIGHTINT   3

weight for integer variable nodes

Definition at line 103 of file dec_hrcgpartition.cpp.

◆ DEFAULT_VARWEIGHTIMPL

#define DEFAULT_VARWEIGHTIMPL   3

weight for implicit integer variable nodes

Definition at line 104 of file dec_hrcgpartition.cpp.

◆ DEFAULT_VARWEIGHTCONT

#define DEFAULT_VARWEIGHTCONT   2

weight for continous variable nodes

Definition at line 105 of file dec_hrcgpartition.cpp.

◆ DEFAULT_CONSWEIGHT

#define DEFAULT_CONSWEIGHT   1

weight for constraint hyperedges

Definition at line 106 of file dec_hrcgpartition.cpp.

◆ DEFAULT_RANDSEED

#define DEFAULT_RANDSEED   1

random seed for the hmetis call

Definition at line 107 of file dec_hrcgpartition.cpp.

◆ DEFAULT_TIDY

#define DEFAULT_TIDY   TRUE

whether to clean up afterwards

Definition at line 108 of file dec_hrcgpartition.cpp.

◆ DEFAULT_DUMMYNODES

#define DEFAULT_DUMMYNODES   0.2

percentage of dummy vertices

Definition at line 109 of file dec_hrcgpartition.cpp.

◆ DEFAULT_CONSWEIGHT_SETPPC

#define DEFAULT_CONSWEIGHT_SETPPC   5

weight for constraint hyperedges that are setpartitioning or covering constraints

Definition at line 111 of file dec_hrcgpartition.cpp.

◆ DEFAULT_MAXNBLOCKCANDIDATES

#define DEFAULT_MAXNBLOCKCANDIDATES   3

number of block number candidates to be considered

Definition at line 112 of file dec_hrcgpartition.cpp.

◆ DEFAULT_ALPHA

#define DEFAULT_ALPHA   0.0

factor for standard deviation of constraint weights

Definition at line 113 of file dec_hrcgpartition.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 115 of file dec_hrcgpartition.cpp.

◆ DEFAULT_METIS_UBFACTOR

#define DEFAULT_METIS_UBFACTOR   5.0

default unbalance factor given to metis on the commandline

Definition at line 116 of file dec_hrcgpartition.cpp.

◆ DEFAULT_METIS_VERBOSE

#define DEFAULT_METIS_VERBOSE   FALSE

should metis be verbose

Definition at line 117 of file dec_hrcgpartition.cpp.

◆ DEFAULT_METISUSEPTYPE_RB

#define DEFAULT_METISUSEPTYPE_RB   TRUE

Should metis use the rb or kway partitioning algorithm

Definition at line 118 of file dec_hrcgpartition.cpp.

◆ DEFAULT_REALNAME

#define DEFAULT_REALNAME   FALSE

whether the metis name should be real or temporary

Definition at line 119 of file dec_hrcgpartition.cpp.

◆ DEFAULT_TYPE

#define DEFAULT_TYPE   'a'

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 122 of file dec_hrcgpartition.cpp.

◆ FAST_MAXHALFPERIMETER

#define FAST_MAXHALFPERIMETER   25000

if nrows + ncols does not exceeds this value

Definition at line 124 of file dec_hrcgpartition.cpp.

◆ SET_MULTIPLEFORSIZETRANSF

#define SET_MULTIPLEFORSIZETRANSF   12500

Definition at line 126 of file dec_hrcgpartition.cpp.

◆ detectorPostprocessPartialdecHrcgpartition

#define detectorPostprocessPartialdecHrcgpartition   NULL

Definition at line 654 of file dec_hrcgpartition.cpp.

Function Documentation

◆ GCG_DECL_FREEDETECTOR()

static GCG_DECL_FREEDETECTOR ( freeHrcgpartition  )
static

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

Definition at line 173 of file dec_hrcgpartition.cpp.

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

◆ GCG_DECL_INITDETECTOR()

static GCG_DECL_INITDETECTOR ( initHrcgpartition  )
static

detector initialization method

Definition at line 189 of file dec_hrcgpartition.cpp.

References DEC_NAME, FALSE, GCG_DetectorData::found, GCGdetectorGetData(), GCGdetectorGetName(), NULL, and SCIP_OKAY.

◆ GCG_DECL_EXITDETECTOR()

static GCG_DECL_EXITDETECTOR ( exitHrcgpartition  )
static

detector deinitialization method (called before the transformed problem is freed)

Definition at line 204 of file dec_hrcgpartition.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
detectordatadetector 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 215 of file dec_hrcgpartition.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 ( SCIP *  scip,
GCG_DETECTORDATA *  detectordata,
int  partialdecID,
MatrixGraph< gcg::GraphTclique > *  graph,
char  tempfile[SCIP_MAXSTRLEN] 
)
static

creates the temporary metis input file

Parameters
scipSCIP 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 323 of file dec_hrcgpartition.cpp.

References DEC_DECCHAR, GCG_DetectorData::dummynodes, 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 450 of file dec_hrcgpartition.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, Partialdec_Detection_Data::detprobdata, GCG_DetectorData::found, GCGgetOrigprob(), gcg::PARTIALDECOMP::getID(), gcg::PARTIALDECOMP::getNBlocks(), gcg::MatrixGraph< T >::getNNonzeroes(), 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_FINISHPARTIALDEC(), and GCG_DECL_PROPAGATEPARTIALDEC().

◆ GCG_DECL_PROPAGATEPARTIALDEC()

◆ GCG_DECL_FINISHPARTIALDEC()

◆ GCG_DECL_SETPARAMAGGRESSIVE()

◆ GCG_DECL_SETPARAMDEFAULT()

◆ GCG_DECL_SETPARAMFAST()

◆ GCGincludeDetectorHrcgpartition()

SCIP_RETCODE GCGincludeDetectorHrcgpartition ( GCG *  gcg)

creates the hrcgpartition presolver and includes it in SCIP

Parameters
gcgGCG data structure

Definition at line 807 of file dec_hrcgpartition.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_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, detectorPostprocessPartialdecHrcgpartition, GCG_DetectorData::dummynodes, FALSE, GCGgetOrigprob(), GCGincludeDetector(), 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, GCG_DetectorData::varWeight, GCG_DetectorData::varWeightBinary, GCG_DetectorData::varWeightContinous, GCG_DetectorData::varWeightImplint, and GCG_DetectorData::varWeightInteger.

Referenced by GCGincludeGcgPlugins().