GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
dec_mastersetcover.cpp
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file dec_mastersetcover.cpp
30 *
31 * @brief detector mastersetcover (sets setcovering and logicor constraint to master)
32 * @author Martin Bergner
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
38#include "gcg/cons_decomp.h"
41#include "gcg/gcg.h"
42#include "scip/cons_setppc.h"
43#include "scip/scip.h"
44#include "gcg/scip_misc.h"
45#include "scip/clock.h"
46
47#include <iostream>
48
49/* constraint handler properties */
50#define DEC_NAME "mastersetcover" /**< name of detector */
51#define DEC_DESC "detector mastersetcover" /**< description of detector*/
52#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 */
53#define DEC_MAXCALLROUND INT_MAX /**< last round the detector gets called */
54#define DEC_MINCALLROUND 0 /**< first round the detector gets called */
55#define DEC_FREQCALLROUNDORIGINAL 1 /**< frequency the detector gets called in detection loop while detecting the original problem */
56#define DEC_MAXCALLROUNDORIGINAL INT_MAX /**< last round the detector gets called while detecting the original problem */
57#define DEC_MINCALLROUNDORIGINAL 0 /**< first round the detector gets called while detecting the original problem */
58#define DEC_PRIORITY 0 /**< priority of the constraint handler for separation */
59#define DEC_DECCHAR '?' /**< display character of detector */
60#define DEC_ENABLED TRUE /**< should the detection be enabled */
61#define DEC_ENABLEDFINISHING FALSE /**< should the finishing be enabled */
62#define DEC_ENABLEDPOSTPROCESSING FALSE /**< should the postprocessing be enabled */
63#define DEC_SKIP FALSE /**< should detector be skipped if other detectors found decompositions */
64#define DEC_USEFULRECALL FALSE /**< is it useful to call this detector on a descendant of the propagated partialdec */
65
66
67/*
68 * Data structures
69 */
70
71/** @todo fill in the necessary detector data */
72
73/** detector handler data */
75{
76};
77
78/*
79 * Local methods
80 */
81
82/* put your local methods here, and declare them static */
83
84/*
85 * detector callback methods
86 */
87
88/** destructor of detector to free user data (called when GCG is exiting) */
89#define freeMastersetcover NULL
90
91/** destructor of detector to free detector data (called before the solving process begins) */
92#define exitMastersetcover NULL
93
94/** detection initialization function of detector (called before solving is about to begin) */
95#define initMastersetcover NULL
96
97
98static GCG_DECL_PROPAGATEPARTIALDEC(propagatePartialdecMastersetcover)
99{
102 SCIP_CLOCK* temporaryClock;
103 SCIP_CALL_ABORT(SCIPcreateClock(origprob, &temporaryClock) );
104 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
105
106 SCIP_CONS* cons;
107
108 gcg::PARTIALDECOMP* partialdec = partialdecdetectiondata->workonpartialdec;
109
110 /* set open setcovering constraints to Master */
111 auto& openconss = partialdec->getOpenconss();
112 for( auto itr = openconss.cbegin(); itr != openconss.cend(); )
113 {
114 cons = partialdecdetectiondata->detprobdata->getCons(*itr);
116 {
117 itr = partialdec->fixConsToMaster(itr);
118 }
119 else
120 {
121 ++itr;
122 }
123 }
124
125 partialdec->sort();
126 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock) );
127
128 partialdecdetectiondata->detectiontime = SCIPgetClockTime(origprob, temporaryClock);
129 SCIP_CALL( SCIPallocMemoryArray(origprob, &(partialdecdetectiondata->newpartialdecs), 1) );
130 partialdecdetectiondata->newpartialdecs[0] = partialdec;
131 partialdecdetectiondata->nnewpartialdecs = 1;
132 partialdecdetectiondata->newpartialdecs[0]->addClockTime(SCIPgetClockTime(origprob, temporaryClock));
133 partialdecdetectiondata->newpartialdecs[0]->addDetectorChainInfo(DEC_NAME);
134 // we used the provided partialdec -> prevent deletion
135 partialdecdetectiondata->workonpartialdec = NULL;
136 SCIP_CALL_ABORT(SCIPfreeClock(origprob, &temporaryClock) );
137
139
140 return SCIP_OKAY;
141}
142/*
143 * detector specific interface methods
144 */
145
146#define finishPartialdecMastersetcover NULL
147#define detectorPostprocessPartialdecMastersetcover NULL
148#define setParamAggressiveMastersetcover NULL
149#define setParamDefaultMastersetcover NULL
150#define setParamFastMastersetcover NULL
151
152
153/** creates the handler for mastersetcover detector and includes it in SCIP */
173
174
175
176
class storing partialdecs and the problem matrix
class storing (potentially incomplete) decompositions
class to manage partial decompositions
GCG_EXPORT void addClockTime(SCIP_Real clocktime)
adds detection time of one detector
GCG_EXPORT std::vector< int > & getOpenconss()
Gets vector containing constraints not assigned yet.
GCG_EXPORT std::vector< int >::const_iterator fixConsToMaster(std::vector< int >::const_iterator itr)
fixes a constraint to the master constraints
GCG_EXPORT bool sort()
sorts the vars and conss data structures by their indices
SCIP_RETCODE GCGincludeDetector(GCG *gcg, 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, GCG_DETECTORDATA *detectordata, GCG_DECL_FREEDETECTOR((*freeDetector)), GCG_DECL_INITDETECTOR((*initDetector)), GCG_DECL_EXITDETECTOR((*exitDetector)), GCG_DECL_PROPAGATEPARTIALDEC((*propagatePartialdecDetector)), GCG_DECL_FINISHPARTIALDEC((*finishPartialdecDetector)), GCG_DECL_POSTPROCESSPARTIALDEC((*postprocessPartialdecDetector)), GCG_DECL_SETPARAMAGGRESSIVE((*setParamAggressiveDetector)), GCG_DECL_SETPARAMDEFAULT((*setParamDefaultDetector)),)
includes one detector
constraint handler for structure detection
#define DEC_MAXCALLROUND
#define DEC_MINCALLROUNDORIGINAL
#define DEC_ENABLEDFINISHING
#define DEC_ENABLED
#define DEC_DECCHAR
#define DEC_NAME
#define DEC_MINCALLROUND
#define DEC_ENABLEDPOSTPROCESSING
#define DEC_DESC
#define DEC_FREQCALLROUND
#define DEC_PRIORITY
#define DEC_USEFULRECALL
#define DEC_SKIP
#define DEC_MAXCALLROUNDORIGINAL
#define DEC_FREQCALLROUNDORIGINAL
#define initMastersetcover
SCIP_RETCODE GCGincludeDetectorMastersetcover(GCG *gcg)
#define setParamFastMastersetcover
#define detectorPostprocessPartialdecMastersetcover
#define freeMastersetcover
#define setParamAggressiveMastersetcover
#define finishPartialdecMastersetcover
#define setParamDefaultMastersetcover
#define exitMastersetcover
mastersetcover detector
#define SCIP_CALL_ABORT(x)
GCG interface methods.
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
consType GCGconsGetType(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:52
#define SCIPallocMemoryArray(scip, ptr, num)
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIP * origprob
* result
#define NULL
various SCIP helper methods
@ setcovering
Definition scip_misc.h:50
@ logicor
Definition scip_misc.h:51
struct SCIP_Clock SCIP_CLOCK
struct SCIP_Cons SCIP_CONS
#define GCG_DECL_PROPAGATEPARTIALDEC(x)
struct GCG_DetectorData GCG_DETECTORDATA
struct Gcg GCG
Definition type_gcg.h:44
SCIP_DIDNOTFIND
SCIP_SUCCESS
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP