dec_isomorph.cpp
Go to the documentation of this file.
38 * This detector finds subproblems that can be aggregated thus reducing the symmetry of the problem using color preserving
42 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
65 #define DEC_DESC "detector for pricing problems suitable for aggregation" /**< description of detector */
66 #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 */
69 #define DEC_FREQCALLROUNDORIGINAL 1 /**< frequency the detector gets called in detection loop while detecting the original problem */
70 #define DEC_MAXCALLROUNDORIGINAL 0 /**< last round the detector gets called while detecting the original problem */
71 #define DEC_MINCALLROUNDORIGINAL 0 /**< first round the detector gets called while detecting the original problem */
79 #define DEC_USEFULRECALL FALSE /**< is it useful to call this detector on a descendant of the propagated partialdec */
202 SCIP_CALL_ABORT( SCIPallocMemoryArray(scip, &conssperm, detprobdata_->getNConss() ) ); /*lint !e666*/
240 SCIPdebugMessage("%d <%s> <-> %d <%s>\n", i, SCIPconsGetName(conss[i]), auti, SCIPconsGetName(conss[auti]));
383 SCIPdebugMessage("%s color %d %d\n", SCIPvarGetName(vars[i]), colorinfo->get(*svar), colorinfo->color);
402 SCIPdebugMessage("%s color %d %d\n", SCIPconsGetName(conss[i]), colorinfo->get(*scons), colorinfo->color);
413 //save the properties of variables of the constraints in a struct array and in a sorted pointer array
441 SCIPdebugMessage("%f color %d %d\n", scoef->getVal(), colorinfo->get(*scoef), colorinfo->color);
487 SCIPdebugMessage("%s color %d %d\n", SCIPvarGetName(var), colorinfo->get(*svar), colorinfo->color);
507 SCIPdebugMessage("%s color %d %d\n", SCIPconsGetName(cons), colorinfo->get(*scons), colorinfo->color);
512 //save the properties of variables of the constraints in a struct array and in a sorted pointer array
536 SCIPdebugMessage("%f color %d %d\n", scoef->getVal(), colorinfo->get(*scoef), colorinfo->color);
661 (void) h->add_vertex((unsigned int) (colorinfo.getLenCons() + colorinfo.getLenVar() + color)); /*lint !e864 */
666 "nz: c <%s> (id: %d, colour: %d) -> nz (id: %d) (value: %f, colour: %d) -> var <%s> (id: %d, colour: %d) \n",
680 SCIPdebugMessage("Iteration 1: nnodes = %ud, Cons = %d, Vars = %d\n", nnodes, colorinfo.getLenCons(), colorinfo.getLenVar()); /*lint !e864 */
800 (void) h->add_vertex((unsigned int) (colorinfo.getLenCons() + colorinfo.getLenVar() + color)); /*lint !e864 */
805 "nz: c <%s> (id: %d, colour: %d) -> nz (id: %d) (value: %f, colour: %d) -> var <%s> (id: %d, colour: %d) \n",
817 SCIPdebugMessage("Iteration 1: nnodes = %ud, Cons = %d, Vars = %d\n", nnodes, colorinfo.getLenCons(), colorinfo.getLenVar()); /*lint !e864 */
837 SCIP_Bool exact /** does this partialdec stems from exact graph construction ( or was onlysign = TRUE ) was used */
962 SCIPdebugMessage("Cons %s will be in block %d (next %d)\n", SCIPconsGetName(detprobdata->getCons(cons)), consblock, nextblock);
980 if( (blockrepresentative[oldblock] != -1) && (blockrepresentative[oldblock] > blockrepresentative[consblock]) )
984 SCIPdebugMessage("\t\tBlock representative from block %d changed from %d to %d.\n", oldblock, blockrepresentative[oldblock], consblock);
990 SCIPdebugMessage("\t\tBlock representative from block %d changed from %d to %d.\n", oldrepr, blockrepresentative[oldrepr], consblock);
1005 SCIPdebugMessage("cons %s in block %d\n", SCIPconsGetName(detprobdata->getCons(cons)), consblock);
1054 /* SCIP_CALL( SCIPhashmapInsert(newconstoblock, (void*) (size_t) cons, (void*) (size_t) (nblocks+1)) ); */
1362 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Detecting almost aggregatable structure: ");
1365 SCIP_CALL( createGraph(scip, *colorinfo, &graph, &detectordata->result, partialdec, detprobdata) );
1393 SCIP_CALL( SCIPreallocMemoryArray(scip, &(detectiondata->newpartialdecs), detectiondata->nnewpartialdecs + MIN(maxdecomps, nperms)) ); /*lint !e506*/
1420 SCIP_CALL( createPartialdecFromMasterconss(scip, &(detectiondata->newpartialdecs[pos]), masterconss, nmasterconss, partialdec, detprobdata, !onlysign) );
1425 SCIP_CALL( detectiondata->newpartialdecs[pos]->isEqual(detectiondata->newpartialdecs[q], &isduplicate, TRUE) );
1451 SCIP_CALL( SCIPreallocMemoryArray(scip, &(detectiondata->newpartialdecs), detectiondata->nnewpartialdecs) );
1454 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "found %d (new) decompositions.\n", detectiondata->nnewpartialdecs);
1474 detectiondata->newpartialdecs[i]->addClockTime(detectiondata->detectiontime / detectiondata->nnewpartialdecs);
1501 SCIP_CALL( detectIsomorph(scip, partialdecdetectiondata, detectordata, result, TRUE, detectordata->maxdecompsextend) );
1504 SCIP_CALL( detectIsomorph(scip, partialdecdetectiondata, detectordata, result, FALSE, detectordata->maxdecompsexact) );
1561 modifier = ( (SCIP_Real)SCIPgetNConss(scip) + (SCIP_Real)SCIPgetNVars(scip) ) / SET_MULTIPLEFORSIZETRANSF;
1617 modifier = ( (SCIP_Real)SCIPgetNConss(scip) + (SCIP_Real)SCIPgetNVars(scip) ) / SET_MULTIPLEFORSIZETRANSF;
1671 newval = ( (SCIP_Real)SCIPgetNConss(scip) + (SCIP_Real)SCIPgetNVars(scip) > SET_MULTIPLEFORSIZETRANSF) ? 0 : 1;
1706 SCIP_CALL( DECincludeDetector(scip, DEC_DETECTORNAME, DEC_DECCHAR, DEC_DESC, DEC_FREQCALLROUND, DEC_MAXCALLROUND, DEC_MINCALLROUND, DEC_FREQCALLROUNDORIGINAL, DEC_MAXCALLROUNDORIGINAL, DEC_MINCALLROUNDORIGINAL, DEC_PRIORITY, DEC_ENABLED, DEC_ENABLEDFINISHING,DEC_ENABLEDPOSTPROCESSING, DEC_SKIP, DEC_USEFULRECALL,
1707 detectordata, detectorFreeIsomorph, detectorInitIsomorph, detectorExitIsomorph, detectorPropagatePartialdecIsomorph, detectorFinishPartialdecIsomorph, detectorPostprocessPartialdecIsomorph, setParamAggressiveIsomorph, setParamDefaultIsomorph, setParamFastIsomorph) );
1711 "Maximum number of solutions/decompositions with exact detection", &detectordata->maxdecompsexact, FALSE,
1715 "Maximum number of solutions/decompositions with extended detection", &detectordata->maxdecompsextend, FALSE,
void addClockTime(SCIP_Real clocktime)
adds detection time of one detector
Definition: class_partialdecomp.cpp:286
int getNConss()
returns the number of variables considered in the detprobdata
Definition: class_detprobdata.cpp:796
const char * DECdetectorGetName(DEC_DETECTOR *detector)
returns the name of the provided detector
Definition: cons_decomp.cpp:2618
static void fhook(void *user_param, unsigned int N, const unsigned int *aut)
Definition: dec_isomorph.cpp:216
static DEC_DECL_FREEDETECTOR(detectorFreeIsomorph)
Definition: dec_isomorph.cpp:1093
GCG interface methods.
int getNOpenvars()
Gets size of vector containing variables not assigned yet.
Definition: class_partialdecomp.cpp:4198
SCIP_RETCODE SCIPincludeDetectorIsomorphism(SCIP *scip)
Definition: dec_isomorph.cpp:1693
static SCIP_RETCODE detectIsomorph(SCIP *scip, PARTIALDEC_DETECTION_DATA *detectiondata, DEC_DETECTORDATA *detectordata, SCIP_RESULT *result, SCIP_Bool onlysign, int maxdecomps)
Definition: dec_isomorph.cpp:1329
SCIP_Bool isAssignedToOrigProb()
returns true if the matrix structure corresponds to the presolved problem
Definition: class_detprobdata.cpp:1098
static DEC_DECL_SETPARAMDEFAULT(setParamDefaultIsomorph)
Definition: dec_isomorph.cpp:1586
constraint handler for structure detection
SCIP_RETCODE GCGconsGetVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int nvars)
Definition: scip_misc.c:490
#define detectorFinishPartialdecIsomorph
Definition: dec_isomorph.cpp:1515
DEC_DECL_PROPAGATEPARTIALDEC(detectorPropagatePartialdecIsomorph)
Definition: dec_isomorph.cpp:1485
various SCIP helper methods
#define detectorPostprocessPartialdecIsomorph
Definition: dec_isomorph.cpp:1517
SCIP_CONS * getCons(int consIndex)
returns the SCIP constraint related to a constraint index
Definition: class_detprobdata.cpp:698
void collapsePermutation(int *permutation, int permsize)
Definition: dec_isomorph.cpp:1165
std::vector< SCIP_Real > & getValsForCons(int consIndex)
returns the nonzero coefficients of the coefficient matrix for a constraint
Definition: class_detprobdata.cpp:931
DEC_DETECTORDATA * DECdetectorGetData(DEC_DETECTOR *detector)
returns the data of the provided detector
Definition: cons_decomp.cpp:2609
interface data structure for the detector calling methods
Definition: class_detprobdata.h:672
static DEC_DECL_INITDETECTOR(detectorInitIsomorph)
Definition: dec_isomorph.cpp:1112
gcg::DETPROBDATA * detprobdata
Definition: class_detprobdata.h:674
const int * getOpenconss()
Gets array containing constraints not assigned yet.
Definition: class_partialdecomp.cpp:4247
Definition: class_detprobdata.h:106
SCIP_RETCODE GCGconsGetVals(SCIP *scip, SCIP_CONS *cons, SCIP_Real *vals, int nvals)
Definition: scip_misc.c:621
detector for pricing problems that can be aggregated (uses bliss)
int renumberPermutations(int *permutation, int permsize)
Definition: dec_isomorph.cpp:1132
static SCIP_RETCODE setupArrays(SCIP *scip, AUT_COLOR *colorinfo, SCIP_RESULT *result)
Definition: dec_isomorph.cpp:350
struct gcg::subset subset
gcg::PARTIALDECOMP ** newpartialdecs
Definition: class_detprobdata.h:676
static SCIP_RETCODE createGraph(SCIP *scip, AUT_COLOR colorinfo, bliss::Graph *graph, SCIP_RESULT *result)
Definition: dec_isomorph.cpp:549
int getNVarsForCons(int consIndex)
returns the number of variables for a given constraint
Definition: class_detprobdata.cpp:854
SCIP_RETCODE DECincludeDetector(SCIP *scip, const char *name, const char decchar, const char *description, int freqCallRound, int maxCallRound, int minCallRound, int freqCallRoundOriginal, int maxCallRoundOriginal, int minCallRoundOriginal, int priority, SCIP_Bool enabled, SCIP_Bool enabledFinishing, SCIP_Bool enabledPostprocessing, SCIP_Bool skip, SCIP_Bool usefulRecall, DEC_DETECTORDATA *detectordata, DEC_DECL_FREEDETECTOR((*freeDetector)), DEC_DECL_INITDETECTOR((*initDetector)), DEC_DECL_EXITDETECTOR((*exitDetector)), DEC_DECL_PROPAGATEPARTIALDEC((*propagatePartialdecDetector)), DEC_DECL_FINISHPARTIALDEC((*finishPartialdecDetector)), DEC_DECL_POSTPROCESSPARTIALDEC((*postprocessPartialdecDetector)), DEC_DECL_SETPARAMAGGRESSIVE((*setParamAggressiveDetector)), DEC_DECL_SETPARAMDEFAULT((*setParamDefaultDetector)),)
Definition: cons_decomp.cpp:3041
helper functions for automorphism detection
int getNOpenconss()
Gets size of vector containing constraints not assigned yet.
Definition: class_partialdecomp.cpp:4192
SCIP_RETCODE isEqual(PARTIALDECOMP *otherpartialdec, SCIP_Bool *isequal, bool sortpartialdecs)
method to check whether this partialdec is equal to a given other partialdec (
Definition: class_partialdecomp.cpp:4539
static DEC_DECL_SETPARAMFAST(setParamFastIsomorph)
Definition: dec_isomorph.cpp:1641
static void fhookForPartialdecs(void *user_param, unsigned int N, const unsigned int *aut)
Definition: dec_isomorph.cpp:258
static DEC_DECL_SETPARAMAGGRESSIVE(setParamAggressiveIsomorph)
Definition: dec_isomorph.cpp:1520
SCIP_RETCODE reorderPermutations(SCIP *scip, gcg::DETPROBDATA *detprobdata, int *permutation, int permsize, int nperms)
Definition: dec_isomorph.cpp:1206
Definition: dec_compgreedily.cpp:73
class storing (potentially incomplete) decompositions
public methods for GCG variables
std::vector< int > & getVarsForCons(int consIndex)
returns the variable indices of the coefficient matrix for a constraint
Definition: class_detprobdata.cpp:963
Definition: dec_isomorph.cpp:101
static SCIP_RETCODE allocMemory(SCIP *scip, AUT_COLOR *colorinfo, int nconss, int nvars)
Definition: dec_isomorph.cpp:304
SCIP_VAR * getVar(int varIndex)
returns SCIP variable related to a variable index
Definition: class_detprobdata.cpp:955
static std::vector< std::vector< int > > getAllSubsets(std::vector< int > set)
Definition: dec_isomorph.cpp:1186
SCIP_RETCODE createPartialdecFromMasterconss(SCIP *scip, gcg::PARTIALDECOMP **newPartialdec, int *masterconss, int nmasterconss, gcg::PARTIALDECOMP *partialdec, gcg::DETPROBDATA *detprobdata, SCIP_Bool exact)
Definition: dec_isomorph.cpp:830
class storing partialdecs and the problem matrix
gcg::PARTIALDECOMP * workonpartialdec
Definition: class_detprobdata.h:675
struct_hook(SCIP_Bool aut, unsigned int n, SCIP *scip)
Definition: dec_isomorph.cpp:176
void GCGconshdlrDecompAddCandidatesNBlocks(SCIP *scip, SCIP_Bool origprob, int candidate)
adds a candidate for block number and counts how often a candidate is added
Definition: cons_decomp.cpp:3435
public methods for working with decomposition structures