GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
dec_hcgpartition.cpp File Reference

Detailed Description

arrowhead and bordered detector via graph partitioning (uses hmetis)

Author
Martin Bergner
Michael Bastubbe

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_hcgpartition.cpp.

#include "gcg/dec_hcgpartition.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/hypercolgraph.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
class  HypercolGraph< T >
class  MatrixGraph< T >

Macros

#define HMETIS_EXECUTABLE   "hmetis"
#define DEC_NAME   "hcgpartition"
#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   'G'
#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_MAXNBLOCKCANDIDATES   1
#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 SET_MULTIPLEFORSIZETRANSF   12500
#define detectorPostprocessPartialdecHcgpartition   NULL

Functions

static GCG_DECL_FREEDETECTOR (freeHcgpartition)
static GCG_DECL_INITDETECTOR (initHcgpartition)
static GCG_DECL_EXITDETECTOR (exitHcgpartition)
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 (propagatePartialdecHcgpartition)
static GCG_DECL_FINISHPARTIALDEC (finishPartialdecHcgpartition)
static GCG_DECL_SETPARAMAGGRESSIVE (setParamAggressiveHcgpartition)
static GCG_DECL_SETPARAMDEFAULT (setParamDefaultHcgpartition)
static GCG_DECL_SETPARAMFAST (setParamFastHcgpartition)
SCIP_RETCODE GCGincludeDetectorHcgpartition (GCG *gcg)

Macro Definition Documentation

◆ HMETIS_EXECUTABLE

#define HMETIS_EXECUTABLE   "hmetis"

Definition at line 62 of file dec_hcgpartition.cpp.

Referenced by callMetis(), callMetis(), and callMetis().

◆ DEC_NAME

#define DEC_NAME   "hcgpartition"

name of the detector

Definition at line 87 of file dec_hcgpartition.cpp.

◆ DEC_DESC

#define DEC_DESC   "enforces arrowhead structures using graph partitioning"

description of detector

Definition at line 88 of file dec_hcgpartition.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 89 of file dec_hcgpartition.cpp.

◆ DEC_MAXCALLROUND

#define DEC_MAXCALLROUND   0

last round the detector gets called

Definition at line 90 of file dec_hcgpartition.cpp.

◆ DEC_MINCALLROUND

#define DEC_MINCALLROUND   0

first round the detector gets called

Definition at line 91 of file dec_hcgpartition.cpp.

◆ DEC_FREQCALLROUNDORIGINAL

#define DEC_FREQCALLROUNDORIGINAL   1

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

Definition at line 92 of file dec_hcgpartition.cpp.

◆ DEC_MAXCALLROUNDORIGINAL

#define DEC_MAXCALLROUNDORIGINAL   0

last round the detector gets called while detecting the original problem

Definition at line 93 of file dec_hcgpartition.cpp.

◆ DEC_MINCALLROUNDORIGINAL

#define DEC_MINCALLROUNDORIGINAL   0

first round the detector gets called while detecting the original problem

Definition at line 94 of file dec_hcgpartition.cpp.

◆ DEC_PRIORITY

#define DEC_PRIORITY   1000

priority of the detector

Definition at line 95 of file dec_hcgpartition.cpp.

◆ DEC_DECCHAR

#define DEC_DECCHAR   'G'

display character of detector

Definition at line 96 of file dec_hcgpartition.cpp.

◆ DEC_ENABLED

#define DEC_ENABLED   FALSE

should detector be called by default

Definition at line 97 of file dec_hcgpartition.cpp.

◆ DEC_ENABLEDFINISHING

#define DEC_ENABLEDFINISHING   FALSE

should detector be called by default

Definition at line 98 of file dec_hcgpartition.cpp.

◆ DEC_ENABLEDPOSTPROCESSING

#define DEC_ENABLEDPOSTPROCESSING   FALSE

should the postprocessing be enabled

Definition at line 99 of file dec_hcgpartition.cpp.

◆ DEC_SKIP

#define DEC_SKIP   FALSE

should detector be skipped if others found detections

Definition at line 100 of file dec_hcgpartition.cpp.

◆ DEC_USEFULRECALL

#define DEC_USEFULRECALL   TRUE

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

Definition at line 101 of file dec_hcgpartition.cpp.

◆ DEFAULT_VARWEIGHT

#define DEFAULT_VARWEIGHT   1

weight for variable nodes

Definition at line 105 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_VARWEIGHTBIN

#define DEFAULT_VARWEIGHTBIN   2

weight for binary variable nodes

Definition at line 106 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_VARWEIGHTINT

#define DEFAULT_VARWEIGHTINT   2

weight for integer variable nodes

Definition at line 107 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_VARWEIGHTIMPL

#define DEFAULT_VARWEIGHTIMPL   2

weight for implicit integer variable nodes

Definition at line 108 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_VARWEIGHTCONT

#define DEFAULT_VARWEIGHTCONT   1

weight for continous variable nodes

Definition at line 109 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_CONSWEIGHT

#define DEFAULT_CONSWEIGHT   5

weight for constraint hyperedges

Definition at line 110 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_RANDSEED

◆ DEFAULT_TIDY

#define DEFAULT_TIDY   TRUE

whether to clean up afterwards

Definition at line 112 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_DUMMYNODES

#define DEFAULT_DUMMYNODES   0.2

percentage of dummy vertices

Definition at line 113 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_CONSWEIGHT_SETPPC

#define DEFAULT_CONSWEIGHT_SETPPC   5

weight for constraint hyperedges that are setpartitioning or covering constraints

Definition at line 114 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_MAXNBLOCKCANDIDATES

◆ DEFAULT_ALPHA

#define DEFAULT_ALPHA   0.0

factor for standard deviation of constraint weights

Definition at line 117 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ 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 118 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_METIS_UBFACTOR

#define DEFAULT_METIS_UBFACTOR   5.0

default unbalance factor given to metis on the commandline

Definition at line 120 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_METIS_VERBOSE

#define DEFAULT_METIS_VERBOSE   FALSE

◆ DEFAULT_METISUSEPTYPE_RB

#define DEFAULT_METISUSEPTYPE_RB   TRUE

Should metis use the rb or kway partitioning algorithm

Definition at line 122 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ DEFAULT_REALNAME

#define DEFAULT_REALNAME   FALSE

whether the metis name should be real or temporary

Definition at line 123 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition(), GCGincludeDetectorHrcgpartition(), and GCGincludeDetectorHrgpartition().

◆ 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 124 of file dec_hcgpartition.cpp.

◆ SET_MULTIPLEFORSIZETRANSF

#define SET_MULTIPLEFORSIZETRANSF   12500

Definition at line 128 of file dec_hcgpartition.cpp.

◆ detectorPostprocessPartialdecHcgpartition

#define detectorPostprocessPartialdecHcgpartition   NULL

Definition at line 633 of file dec_hcgpartition.cpp.

Referenced by GCGincludeDetectorHcgpartition().

Function Documentation

◆ GCG_DECL_FREEDETECTOR()

GCG_DECL_FREEDETECTOR ( freeHcgpartition )
static

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

Definition at line 177 of file dec_hcgpartition.cpp.

References assert(), DEC_NAME, GCG_DECL_FREEDETECTOR, GCGdetectorGetData(), GCGdetectorGetName(), GCGgetOrigprob(), and SCIPfreeMemory().

◆ GCG_DECL_INITDETECTOR()

GCG_DECL_INITDETECTOR ( initHcgpartition )
static

detector initialization method (called after problem was transformed)

Definition at line 195 of file dec_hcgpartition.cpp.

References assert(), DEC_NAME, GCG_DetectorData::found, GCG_DECL_INITDETECTOR, GCGdetectorGetData(), and GCGdetectorGetName().

◆ GCG_DECL_EXITDETECTOR()

GCG_DECL_EXITDETECTOR ( exitHcgpartition )
static

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

Definition at line 212 of file dec_hcgpartition.cpp.

References assert(), DEC_NAME, GCG_DECL_EXITDETECTOR, and GCGdetectorGetName().

◆ callMetis()

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
gcgSCIP 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 225 of file dec_hcgpartition.cpp.

References assert(), callMetis(), GCGgetOrigprob(), GCGgetRemainingTime(), HMETIS_EXECUTABLE, GCG_DetectorData::metisubfactor, GCG_DetectorData::metisuseptyperb, GCG_DetectorData::metisverbose, GCG_DetectorData::randomseed, gcg::MatrixGraph< T >::readPartition(), result, SCIP_CALL(), SCIPdebugMessage(), and GCG_DetectorData::tidy.

Referenced by callMetis(), and detection().

◆ createMetisFile()

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
partialdecidused for speaking filenames
graphthe graph of the matrix
tempfilefilename for the metis input file

Definition at line 334 of file dec_hcgpartition.cpp.

References createMetisFile(), DEC_DECCHAR, GCG_DetectorData::dummynodes, gcg::MatrixGraph< T >::getNNonzeroes(), GCG_DetectorData::realname, SCIP_CALL(), gcg::MatrixGraph< T >::setDummynodes(), and gcg::MatrixGraph< T >::writeToFile().

Referenced by createMetisFile(), and detection().

◆ connected()

◆ detection()

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

◆ GCG_DECL_PROPAGATEPARTIALDEC()

◆ GCG_DECL_FINISHPARTIALDEC()

◆ GCG_DECL_SETPARAMAGGRESSIVE()

GCG_DECL_SETPARAMAGGRESSIVE ( setParamAggressiveHcgpartition )
static

◆ GCG_DECL_SETPARAMDEFAULT()

GCG_DECL_SETPARAMDEFAULT ( setParamDefaultHcgpartition )
static

◆ GCG_DECL_SETPARAMFAST()

GCG_DECL_SETPARAMFAST ( setParamFastHcgpartition )
static

◆ GCGincludeDetectorHcgpartition()

SCIP_RETCODE GCGincludeDetectorHcgpartition ( GCG * gcg)

creates the hcgpartition presolver and includes it in SCIP

creates the arrowheur detector and includes it in SCIP creates the hcgpartition presolver and includes it in SCIP

Parameters
gcgGCG data structure

Definition at line 775 of file dec_hcgpartition.cpp.

References GCG_DetectorData::alpha, assert(), 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, detectorPostprocessPartialdecHcgpartition, GCG_DetectorData::dummynodes, GCGgetOrigprob(), GCGincludeDetector(), GCGincludeDetectorHcgpartition(), GCG_DetectorData::maxnblockcandidates, GCG_DetectorData::metisubfactor, GCG_DetectorData::metisuseptyperb, GCG_DetectorData::metisverbose, GCG_DetectorData::randomseed, GCG_DetectorData::realname, SCIP_CALL(), GCG_DetectorData::tidy, GCG_DetectorData::varWeight, GCG_DetectorData::varWeightBinary, GCG_DetectorData::varWeightContinous, GCG_DetectorData::varWeightImplint, and GCG_DetectorData::varWeightInteger.

Referenced by GCGincludeDetectorHcgpartition(), and GCGincludeGcgPlugins().