GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
dec_mastersetpart.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_mastersetpart.cpp
30 *
31 * @brief detector mastersetpart (set setpartitioning constraints 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 "mastersetpart" /**< name of detector */
51#define DEC_DESC "detector mastersetpart" /**< 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 * Data structures
67 */
68
69/** @todo fill in the necessary detector data */
70
71/** detector handler data */
73{
74};
75
76/*
77 * Local methods
78 */
79
80/* put your local methods here, and declare them static */
81
82/*
83 * detector callback methods
84 */
85
86/** destructor of detector to free user data (called when GCG is exiting) */
87#define freeMastersetpart NULL
88
89/** destructor of detector to free detector data (called before the solving process begins) */
90#define exitMastersetpart NULL
91
92/** detection initialization function of detector (called before solving is about to begin) */
93#define initMastersetpart NULL
94
95
96static GCG_DECL_PROPAGATEPARTIALDEC(propagatePartialdecMastersetpart)
97{
100 SCIP_CLOCK* temporaryClock;
101 SCIP_CALL_ABORT( SCIPcreateClock(origprob, &temporaryClock) );
102 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
103
104 SCIP_CONS* cons;
105
106 gcg::PARTIALDECOMP* partialdec = partialdecdetectiondata->workonpartialdec;
107
108 /* set open setpartitioning constraints to Master */
109 auto& openconss = partialdec->getOpenconss();
110 for( auto itr = openconss.cbegin(); itr != openconss.cend(); )
111 {
112 cons = partialdecdetectiondata->detprobdata->getCons(*itr);
114 {
115 itr = partialdec->fixConsToMaster(itr);
116 }
117 else
118 {
119 ++itr;
120 }
121 }
122
123 partialdec->sort();
124 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
125
126 partialdecdetectiondata->detectiontime = SCIPgetClockTime(origprob, temporaryClock);
127 SCIP_CALL( SCIPallocMemoryArray(origprob, &(partialdecdetectiondata->newpartialdecs), 1) );
128 partialdecdetectiondata->newpartialdecs[0] = partialdec;
129 partialdecdetectiondata->nnewpartialdecs = 1;
130 partialdecdetectiondata->newpartialdecs[0]->addClockTime(SCIPgetClockTime(origprob, temporaryClock));
131 partialdecdetectiondata->newpartialdecs[0]->addDetectorChainInfo(DEC_NAME);
132 // we used the provided partialdec -> prevent deletion
133 partialdecdetectiondata->workonpartialdec = NULL;
134 SCIP_CALL_ABORT(SCIPfreeClock(origprob, &temporaryClock) );
135
137
138 return SCIP_OKAY;
139}
140
141#define finishPartialdecMastersetpart NULL
142
143#define detectorPostprocessPartialdecMastersetpart NULL
144
145#define setParamAggressiveMastersetpart NULL
146#define setParamDefaultMastersetpart NULL
147#define setParamFastMastersetpart NULL
148
149
150/*
151 * detector specific interface methods
152 */
153
154/** creates the handler for mastersetpart detector and includes it in SCIP */
171
172
173
174
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 setParamDefaultMastersetpart
#define finishPartialdecMastersetpart
SCIP_RETCODE GCGincludeDetectorMastersetpart(GCG *gcg)
#define setParamAggressiveMastersetpart
#define freeMastersetpart
#define setParamFastMastersetpart
#define detectorPostprocessPartialdecMastersetpart
#define exitMastersetpart
#define initMastersetpart
mastersetpart 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
@ setpartitioning
Definition scip_misc.h:50
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