Scippy

GCG

Branch-and-Price & Column Generation for Everyone

dec_connected_noNewLinkingVars.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_connected_noNewLinkingVars.cpp
30 *
31 * @brief detector connected_noNewLinkingVars (assigns all dependent open conss and vars and completes the partialdec by bfs)
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"
39#include "gcg/gcg.h"
42#include "scip/scip.h"
43#include "gcg/scip_misc.h"
44#include "scip/clock.h"
45#include <iostream>
46#include <algorithm>
47#include <vector>
48#include <queue>
49
50/* constraint handler properties */
51#define DEC_NAME "connected_nonewlinkingvars" /**< name of detector */
52#define DEC_DESC "detector connected_noNewLinkingVars" /**< description of detector*/
53#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 */
54#define DEC_MAXCALLROUND INT_MAX /** last round the detector gets called */
55#define DEC_MINCALLROUND 0 /** first round the detector gets called */
56#define DEC_FREQCALLROUNDORIGINAL 1 /** frequency the detector gets called in detection loop while detecting the original problem */
57#define DEC_MAXCALLROUNDORIGINAL INT_MAX /** last round the detector gets called while detecting the original problem */
58#define DEC_MINCALLROUNDORIGINAL 0 /** first round the detector gets called while detecting the original problem */
59#define DEC_PRIORITY 0 /**< priority of the constraint handler for separation */
60#define DEC_DECCHAR '?' /**< display character of detector */
61#define DEC_ENABLED FALSE /**< should the detection be enabled */
62#define DEC_ENABLEDFINISHING FALSE /**< should the finishing be enabled */
63#define DEC_ENABLEDPOSTPROCESSING FALSE /**< should the finishing be enabled */
64#define DEC_SKIP FALSE /**< should detector be skipped if other detectors found decompositions */
65#define DEC_USEFULRECALL FALSE /**< is it useful to call this detector on a descendant of the propagated partialdec */
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/*
80 * Local methods
81 */
82
83/* put your local methods here, and declare them static */
84
85
86/*
87 * detector callback methods
88 */
89
90/** destructor of detector to free user data (called when GCG is exiting) */
91#define freeConnected_noNewLinkingVars NULL
92
93/** destructor of detector to free detector data (called before the solving process begins) */
94#define exitConnected_noNewLinkingVars NULL
95
96/** detection initialization function of detector (called before solving is about to begin) */
97#define initConnected_noNewLinkingVars NULL
98
99
100
101/** detection function for partialdecs */
102static
104 SCIP* scip, /**< SCIP data structure */
105 Partialdec_Detection_Data* partialdecdetectiondata /**< partialdecdetectiondata (including the detprobdata and workonpartialdec) where to store the new Partialdecs */
106)
107{
108 SCIP_CLOCK* temporaryClock;
109 SCIP_CALL_ABORT( SCIPcreateClock(scip, &temporaryClock) );
110 SCIP_CALL_ABORT( SCIPstartClock(scip, temporaryClock) );
111
112 gcg::PARTIALDECOMP* partialdec = partialdecdetectiondata->workonpartialdec;
113
114 partialdec->considerImplicits();
115
116 //assign all dependent open vars and conss
117 partialdec->refineToBlocks();
118
119 //complete the partialdec by bfs
120 partialdec->completeByConnected();
121
122 SCIP_CALL_ABORT( SCIPstopClock(scip, temporaryClock) );
123
124 partialdecdetectiondata->detectiontime = SCIPgetClockTime(scip, temporaryClock);
125 partialdecdetectiondata->nnewpartialdecs = 1;
126 SCIP_CALL( SCIPallocMemoryArray(scip, &(partialdecdetectiondata->newpartialdecs), 1) );
127 partialdecdetectiondata->newpartialdecs[0] = partialdec;
128 partialdecdetectiondata->newpartialdecs[0]->addDetectorChainInfo(DEC_NAME);
129 partialdecdetectiondata->newpartialdecs[0]->addClockTime(SCIPgetClockTime(scip, temporaryClock));
130 // we used the provided partialdec -> prevent deletion
131 partialdecdetectiondata->workonpartialdec = NULL;
132 SCIP_CALL_ABORT(SCIPfreeClock(scip, &temporaryClock) );
133
134 return SCIP_OKAY;
135}
136
137
138static
139GCG_DECL_PROPAGATEPARTIALDEC(propagatePartialdecConnected_noNewLinkingVars)
140{
141 SCIP* origprob = GCGgetOrigprob(gcg);
142 assert(origprob != NULL);
143 *result = SCIP_DIDNOTFIND;
144 detection(origprob, partialdecdetectiondata);
145 *result = SCIP_SUCCESS;
146
147 return SCIP_OKAY;
148}
149
150static
151GCG_DECL_FINISHPARTIALDEC(finishPartialdecConnected_noNewLinkingVars)
152{
153 SCIP* origprob = GCGgetOrigprob(gcg);
154 assert(origprob != NULL);
155 *result = SCIP_DIDNOTFIND;
156 detection(origprob, partialdecdetectiondata);
157 *result = SCIP_SUCCESS;
158
159 return SCIP_OKAY;
160}
161#define detectorPostprocessPartialdecConnected_noNewLinkingVars NULL
162
163
164#define setParamAggressiveConnected_noNewLinkingVars NULL
165#define setParamDefaultConnected_noNewLinkingVars NULL
166#define setParamFastConnected_noNewLinkingVars NULL
167
168
169
170/*
171 * detector specific interface methods
172 */
173
174/** creates the handler for connected_noNewLinkingVars detector and includes it in SCIP */
176 GCG* gcg /**< GCG data structure */
177 )
178{
179 GCG_DETECTORDATA* detectordata;
180
181 /**@todo create connected_noNewLinkingVars detector data here*/
182 detectordata = NULL;
183
185
186 /**@todo add connected_noNewLinkingVars detector parameters */
187
188 return SCIP_OKAY;
189}
class storing partialdecs and the problem matrix
class storing (potentially incomplete) decompositions
class to manage partial decompositions
GCG_EXPORT void addDetectorChainInfo(const char *decinfo)
add information about the detector chain
GCG_EXPORT void completeByConnected()
assigns all open constraints and open variables
GCG_EXPORT void refineToBlocks()
refine partialdec with focus on blocks
GCG_EXPORT void considerImplicits()
: assigns every open cons/var
GCG_EXPORT void addClockTime(SCIP_Real clocktime)
adds detection time of one detector
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)),)
constraint handler for structure detection
#define setParamAggressiveConnected_noNewLinkingVars
#define DEC_MAXCALLROUND
#define DEC_MINCALLROUNDORIGINAL
static SCIP_RETCODE detection(SCIP *scip, Partialdec_Detection_Data *partialdecdetectiondata)
#define detectorPostprocessPartialdecConnected_noNewLinkingVars
#define DEC_ENABLEDFINISHING
#define DEC_MINCALLROUND
#define setParamDefaultConnected_noNewLinkingVars
#define exitConnected_noNewLinkingVars
#define DEC_ENABLEDPOSTPROCESSING
#define setParamFastConnected_noNewLinkingVars
static GCG_DECL_FINISHPARTIALDEC(finishPartialdecConnected_noNewLinkingVars)
#define freeConnected_noNewLinkingVars
#define DEC_FREQCALLROUND
#define DEC_USEFULRECALL
SCIP_RETCODE GCGincludeDetectorConnected_noNewLinkingVars(GCG *gcg)
#define initConnected_noNewLinkingVars
#define DEC_MAXCALLROUNDORIGINAL
#define DEC_FREQCALLROUNDORIGINAL
static GCG_DECL_PROPAGATEPARTIALDEC(propagatePartialdecConnected_noNewLinkingVars)
connected_noNewLinkingVars detector
#define SCIP_CALL_ABORT(x)
#define SCIP_CALL(x)
GCG interface methods.
SCIP * GCGgetOrigprob(GCG *gcg)
Definition: gcg.cpp:87
#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)
#define NULL
various SCIP helper methods
Definition: struct_gcg.h:55
interface data structure for the detector calling methods
gcg::PARTIALDECOMP ** newpartialdecs
gcg::PARTIALDECOMP * workonpartialdec
SCIP_DIDNOTFIND
SCIP_SUCCESS
SCIP_OKAY
enum SCIP_Retcode SCIP_RETCODE