GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
dec_mst.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_mst.cpp
30 *
31 * @brief minimum spanning tree clustering detector
32 * @author Igor Pesic
33 *
34 * @note requires package to be installed: GSL library, requires flag to be set: `GSL=true`
35 *
36 * This detector performs minimum spanning tree clustering.
37 */
38
39/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
40#include <time.h> // for measuring time performance
41#include <algorithm>
42
43#include "gcg/dec_mst.h"
44#include "gcg/cons_decomp.h"
45#include "graph/matrixgraph.h"
47#include "graph/graph_gcg.h"
48#include "scip/clock.h"
49
50
52using gcg::Weights;
53using gcg::GraphGCG;
54
55
56/* constraint handler properties */
57#define DEC_NAME "mst" /**< name of detector */
58#define DEC_DESC "detector based on MST clustering" /**< description of detector */
59#define DEC_PRIORITY 910 /**< priority of the constraint handler for separation */
60#define DEC_FREQCALLROUND 1 /**< frequency the detector gets called in detection loop, i.e. it is called in round r if and only if minCallRound <= r <= maxCallRound AND (r - minCallRound) mod freqCallRound == 0 */
61#define DEC_MAXCALLROUND INT_MAX /**< last round the detector gets called */
62#define DEC_MINCALLROUND 0 /**< first round the detector gets called */
63#define DEC_FREQCALLROUNDORIGINAL 1 /**< frequency the detector gets called in detection loop while detecting the original problem */
64#define DEC_MAXCALLROUNDORIGINAL INT_MAX /**< last round the detector gets called while detecting the original problem */
65#define DEC_MINCALLROUNDORIGINAL 0 /**< first round the detector gets called while detecting the original problem */
66#define DEC_DECCHAR 'M' /**< display character of detector */
67#define DEC_ENABLED FALSE /**< should the detection be enabled */
68#define DEC_ENABLEDFINISHING FALSE /**< should the finishing be enabled */
69#define DEC_ENABLEDPOSTPROCESSING FALSE /**< should the postprocessing be enabled */
70#define DEC_SKIP FALSE /**< should detector be skipped if other detectors found decompositions */
71#define DEC_USEFULRECALL FALSE /**< is it useful to call this detector on a descendant of the propagated partialdec */
72
73/* Default parameter settings*/
74#define DEFAULT_N_ITERATIONS 51
75#define DEFAULT_JOHNSON_ENABLE true
76#define DEFAULT_INTERSECTION_ENABLE false
77#define DEFAULT_JACCARD_ENABLE false
78#define DEFAULT_COSINE_ENABLE false
79#define DEFAULT_SIMPSON_ENABLE false
80#define DEFAULT_POSTPROC_ENABLE true
81#define MAX_N_BLOCKS 100
82
83/*
84 * Data structures
85 */
86
87/** detector handler data */
89{
90 SCIP_RESULT result; /**< result pointer to indicate success or failure */
92 int n_iterations;
93 int n_similarities; /**< number of active similarities */
100};
101
102
103/*
104 * Local methods
105 */
106
107static std::vector<double> getEpsList(int length, double mid, bool isintersection)
108{
109 int n1, n2;
110 if(isintersection)
111 {
112 n1 = (int) round((length+1) / 2.0);
113 n2 = n1;
114 }
115 else
116 {
117 n2 = (int) round((length+1) / 4.0);
118 n1 = abs(length - n2) + 1;
119 }
120
121 double s = mid;
122 double end1 = mid + 0.9; // lower boundary
123 double end2 = mid + 0.4; // upper boundary
124
125 double q1 = pow(end1/s, 1.0/(double)(n1-1));
126 double q2 = pow(end2/s, 1.0/(double)(n2-1));
127
128 std::vector<double> geom_seq1(n1-1);
129 std::vector<double> geom_seq2(n2);
130
131 int j = 0;
132 for(int i = n1 - 1; i > 0; i--)
133 {
134 geom_seq1[j] = 2*s-s*pow(q1, (double)i);
135 j++;
136 }
137 for(int i = 0; i < n2; i++)
138 {
139 geom_seq2[i] = s*pow(q2, (double)i);
140 }
141
142 geom_seq1.insert( geom_seq1.end(), geom_seq2.begin(), geom_seq2.end() );
143
144 assert((int)geom_seq1.size() == length);
145
146 return geom_seq1;
147}
148
149/*
150 * detector callback methods
151 */
152
153/** destructor of detector to free user data (called when GCG is exiting) */
154static
156{
157 GCG_DETECTORDATA* detectordata;
158
159 detectordata = GCGdetectorGetData(detector);
160 assert(detectordata != NULL);
161 assert(strcmp(GCGdetectorGetName(detector), DEC_NAME) == 0);
162
163 SCIPfreeMemory(GCGgetOrigprob(gcg), &detectordata);
164
165 return SCIP_OKAY;
166}
167
168/** destructor of detector to free detector data (called before the solving process begins) */
169static
171{
172 return SCIP_OKAY;
173}
174
175
176/** detection initialization function of detector (called before solving is about to begin) */
177static
179{ /*lint --e{715}*/
180
181 GCG_DETECTORDATA* detectordata;
182
183 detectordata = GCGdetectorGetData(detector);
184 assert(detectordata != NULL);
185 assert(strcmp(GCGdetectorGetName(detector), DEC_NAME) == 0);
186
187 detectordata->n_similarities = -1;
188 detectordata->found = FALSE;
189 return SCIP_OKAY;
190}
191
192/** are there conss and vars to be included by the graph and have the conss common vars included by the graph */
193static
195 gcg::DETPROBDATA* detprobdata,
196 gcg::PARTIALDECOMP* partialdec
197 )
198{
199 bool completible;
200
201 //have the open conss open vars?
202 for(int c = 0; c < partialdec->getNOpenconss() && !completible; ++c)
203 {
204 int cons = partialdec->getOpenconss()[c];
205 for(int v = 0; v < partialdec->getNOpenvars() && !completible; ++v)
206 {
207 int var = partialdec->getOpenvars()[v];
208 for(int i = 0; i < detprobdata->getNVarsForCons(cons) && !completible; ++i)
209 {
210 if(var == detprobdata->getVarsForCons(cons)[i])
211 {
212 completible = true;
213 }
214 }
215 }
216 }
217 if(!completible)
218 return false;
219
220 //have the open conss common open vars?
221 for(int c = 0; c < partialdec->getNOpenconss(); ++c)
222 {
223 int cons1 = partialdec->getOpenconss()[c];
224 for(int d = c + 1; d < partialdec->getNOpenconss(); ++d)
225 {
226 int cons2 = partialdec->getOpenconss()[d];
227 for(int v = 0; v < detprobdata->getNVarsForCons(cons1); ++v)
228 {
229 int var1 = detprobdata->getVarsForCons(cons1)[v];
230 if(!partialdec->isVarOpenvar(var1))
231 continue;
232 for(int w = 0; w < detprobdata->getNVarsForCons(cons2); ++w)
233 {
234 int var2 = detprobdata->getVarsForCons(cons2)[w];
235 if(var1 == var2)
236 return true;
237 }
238 }
239 }
240 }
241 return false;
242}
243
244
245//#define propagatePartialdecMST NULL
246
247static
248GCG_DECL_PROPAGATEPARTIALDEC(propagatePartialdecMST)
249{ /*lint --e{715}*/
251 int nnewpartialdecs;
252 gcg::PARTIALDECOMP* partialdec;
253 GCG_DETECTORDATA* detectordata = GCGdetectorGetData(detector);
254 std::vector<SCIP_Real> clockTimes1; /* vector containing times in seconds */
255 std::vector<SCIP_Real> clockTimes2; /* vector containing times in seconds */
256 std::vector< RowGraphWeighted<GraphGCG>*> graphs;
257 SCIP_CLOCK* overallClock;
258
259 assert(origprob != NULL);
260 assert(detectordata != NULL);
262
263 SCIP_CALL_ABORT( SCIPcreateClock(origprob, &overallClock) );
264 SCIP_CALL_ABORT( SCIPstartClock(origprob, overallClock) );
265
266 partialdec = partialdecdetectiondata->workonpartialdec;
267 partialdec->refineToBlocks();
268
269 if( !graphCompletible(partialdecdetectiondata->detprobdata, partialdec) )
270 {
271 partialdecdetectiondata->nnewpartialdecs = 0;
272 SCIP_CALL_ABORT( SCIPstopClock(origprob, overallClock) );
273 partialdecdetectiondata->detectiontime = SCIPgetClockTime(origprob, overallClock);
274 SCIP_CALL_ABORT(SCIPfreeClock(origprob, &overallClock) );
276 return SCIP_OKAY;
277 }
278
279 Weights w(1, 1, 1, 1, 1, 1);
280
281 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, "Detecting MST structure:");
282
283 time_t start, cp0, cp1, d_s, d_e;
284 time(&start);
285
286 std::vector<std::string> sim;
287 SCIP_CLOCK* temporaryClock;
288
289 SCIP_CALL_ABORT(SCIPcreateClock(origprob, &temporaryClock) );
290
291 if(detectordata->johnsonenable)
292 {
293 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
295 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec, gcg::DISTANCE_MEASURE::JOHNSON, gcg::WEIGHT_TYPE::DIST));
296 graphs.push_back(g);
297 sim.push_back("Johnson");
298 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
299 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
300 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
301 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
302 }
303 if(detectordata->intersectionenable)
304 {
305 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
307 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec, gcg::DISTANCE_MEASURE::INTERSECTION, gcg::WEIGHT_TYPE::DIST));
308 graphs.push_back(g);
309 sim.push_back("Intersection");
310 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
311 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
312 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
313 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
314 }
315 if(detectordata->jaccardenable)
316 {
317 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
319 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec, gcg::DISTANCE_MEASURE::JACCARD, gcg::WEIGHT_TYPE::DIST));
320 graphs.push_back(g);
321 sim.push_back("Jaccard");
322 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
323 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
324 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
325 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
326 }
327 if(detectordata->cosineenable)
328 {
329 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
331 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec,gcg::DISTANCE_MEASURE::COSINE, gcg::WEIGHT_TYPE::DIST));
332 graphs.push_back(g);
333 sim.push_back("Cosine");
334 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
335 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
336 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
337 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
338 }
339 if(detectordata->simpsonenable)
340 {
341 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
343 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec,gcg::DISTANCE_MEASURE::SIMPSON, gcg::WEIGHT_TYPE::DIST));
344 graphs.push_back(g);
345 sim.push_back("Simspon");
346 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
347 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
348 clockTimes1.push_back(SCIPgetClockTime(origprob, temporaryClock));
349 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
350 }
351 time(&cp0);
352 detectordata->n_similarities = (int) graphs.size();
353
354 double q = 10; // quantile to search for the percentile needed for the mid of the eps list
355 std::vector<double> mids(graphs.size()); // middle values for each eps list
356 std::vector<std::vector<double> > epsLists(graphs.size());
357 for(int i = 0; i < (int)graphs.size(); i++)
358 {
359 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
360 mids[i] = graphs.at(i)->getEdgeWeightPercentile(q);
361 if(i == 1 && detectordata->intersectionenable)
362 {
363 epsLists[i] = getEpsList(detectordata->n_iterations, mids[i], true); // case for intersection
364 }
365 else
366 {
367 epsLists[i] = getEpsList(detectordata->n_iterations, mids[i], false); // case for all except intersection
368 }
369 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock) );
370 clockTimes2.push_back(SCIPgetClockTime(origprob, temporaryClock));
371 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock) );
372 }
373
374 time(&cp1);
375
376 int nMaxPartialdecs = detectordata->n_iterations * (int) graphs.size();
377 const int max_blocks = std::min((int)round(0.3 * SCIPgetNConss(origprob)), MAX_N_BLOCKS);
378 char decinfo[SCIP_MAXSTRLEN];
379
380 SCIP_CALL( SCIPallocMemoryArray(origprob, &(partialdecdetectiondata->newpartialdecs), 2 * nMaxPartialdecs) );
381
382 nnewpartialdecs = 0;
383 time(&d_s);
384 for( int i = 0; i < (int)graphs.size(); i++ )
385 {
386 RowGraphWeighted<GraphGCG>* graph = graphs.at(i);
387 int old_n_blocks = -1;
388 int old_non_cl = -1;
389 std::vector<gcg::PARTIALDECOMP*> createddecomps;
390 std::vector<std::pair<double, SCIP_Real>> clockTimes3;
391 gcg::PARTIALDECOMP *decomp1 = NULL, *decomp2 = NULL;
392
393 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, "\n %s similarity: ", sim[i].c_str());
394 createddecomps.reserve(2 * epsLists[i].size());
395 clockTimes3.reserve(epsLists[i].size());
396
397 for( double eps : epsLists[i] )
398 {
399 if( eps <= 0.0 )
400 {
401 continue;
402 }
403 if( eps >= 1.0 )
404 {
405 break;
406 }
407
408 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
409 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
410
411 // run MST with different eps
412 SCIP_CALL( graph->computePartitionMSTForPartialGraph(partialdecdetectiondata->detprobdata, partialdec, eps, detectordata->postprocenable) );
413
414 int n_blocks;
415 int non_cl;
416 SCIP_CALL( graph->getNBlocks(n_blocks) );
417 SCIP_CALL( graph->nonClustered(non_cl) );
418
419 // skip the case if we have too many blocks (it means we must increase eps) or if the clustering is the same as the last one
420 if( n_blocks > max_blocks || n_blocks == 0 || (n_blocks == old_n_blocks && non_cl == old_non_cl) )
421 {
422 continue;
423 }
424 // stop. eps is already too big
425 if( n_blocks == 1 && non_cl == 0)
426 {
427 break;
428 }
429 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, "\n Blocks: %d, Master Conss: %d/%d, ", n_blocks, non_cl, SCIPgetNConss(origprob));
430 old_n_blocks = n_blocks;
431 old_non_cl = non_cl;
432
433 SCIP_CALL( graph->createPartialdecFromPartition(partialdec, &decomp1, &decomp2, partialdecdetectiondata->detprobdata));
434 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
435
436 if( decomp1 != NULL )
437 {
438 assert(decomp2 != NULL);
439 detectordata->found = TRUE;
440 createddecomps.push_back(decomp1);
441 createddecomps.push_back(decomp2);
442 clockTimes3.emplace_back(eps, SCIPgetClockTime(origprob, temporaryClock));
443 }
444 }
445
446 size_t ncreateddecomps = createddecomps.size();
447 for( unsigned int j = 0; j < ncreateddecomps; ++j )
448 {
449 double eps = clockTimes3[j / 2].first;
450 SCIP_Real epstime = clockTimes3[j / 2].second;
451 (void) SCIPsnprintf(decinfo, SCIP_MAXSTRLEN, "mst_%s_%f", sim[i].c_str(), eps);
452 createddecomps[j]->addDetectorChainInfo(decinfo);
453 createddecomps[j]->addClockTime(clockTimes1[i] / ncreateddecomps + clockTimes2[i] / ncreateddecomps + epstime / 2.0);
454 partialdecdetectiondata->newpartialdecs[nnewpartialdecs + j] = createddecomps[j];
455 }
456 nnewpartialdecs += (int) ncreateddecomps;
457
458 delete graphs.at(i);
459 graphs[i] = NULL;
460 }
461
462 SCIP_CALL( SCIPreallocMemoryArray(origprob, &(partialdecdetectiondata->newpartialdecs), nnewpartialdecs) );
463 partialdecdetectiondata->nnewpartialdecs = nnewpartialdecs;
464 SCIP_CALL_ABORT( SCIPstopClock(origprob, overallClock) );
465 partialdecdetectiondata->detectiontime = SCIPgetClockTime(origprob, overallClock);
466 SCIP_CALL_ABORT(SCIPfreeClock(origprob, &overallClock) );
467
468 time(&d_e);
469 double elapsed_graphs = difftime(cp0, start);
470 double elapsed_mst = difftime(d_e, d_s);
471
472 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, " done, %d similarities used, %d decompositions found.\n", detectordata->n_similarities, nnewpartialdecs);
473 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, "MST runtime: graphs: %.2lf, mst: %.2lf. \n", elapsed_graphs, elapsed_mst);
474
475 *result = nnewpartialdecs > 0 ? SCIP_SUCCESS: SCIP_DIDNOTFIND;
476 if( nnewpartialdecs == 0 )
477 {
478 SCIPfreeMemoryArrayNull(origprob, &(partialdecdetectiondata->newpartialdecs));
479 }
480
481 SCIP_CALL_ABORT(SCIPfreeClock(origprob, &temporaryClock) );
482 return SCIP_OKAY;
483}
484
485#define finishPartialdecMST NULL
486
487#define detectorPostprocessPartialdecMST NULL
488
489static
490GCG_DECL_SETPARAMAGGRESSIVE(setParamAggressiveMST)
491{
492 char setstr[SCIP_MAXSTRLEN];
493 const char* name = GCGdetectorGetName(detector);
495
496 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", name);
498
499 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", name);
501
502 return SCIP_OKAY;
503}
504
505
506static
507GCG_DECL_SETPARAMDEFAULT(setParamDefaultMST)
508{
509 char setstr[SCIP_MAXSTRLEN];
510 const char* name = GCGdetectorGetName(detector);
512
513 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", name);
515
516 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", name);
518
519 return SCIP_OKAY;
520}
521
522static
523GCG_DECL_SETPARAMFAST(setParamFastMST)
524{
525 char setstr[SCIP_MAXSTRLEN];
526 const char* name = GCGdetectorGetName(detector);
528
529 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", name);
531
532 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", name);
534
535 return SCIP_OKAY;
536}
537
538
539/*
540 * detector specific interface methods
541 */
542
543/** creates the handler for xyz detector and includes it in SCIP */
545 GCG* gcg /**< GCG data structure */
546 )
547{
548#if !defined(_WIN32) && !defined(_WIN64)
549 GCG_DETECTORDATA *detectordata = NULL;
551 assert(origprob != NULL);
552 assert(origprob != NULL);
553
554 SCIP_CALL( SCIPallocMemory(origprob, &detectordata) );
555
556 assert(detectordata != NULL);
557 detectordata->found = FALSE;
558
560 detectordata, freeMST, initMST, exitMST, propagatePartialdecMST, finishPartialdecMST, detectorPostprocessPartialdecMST, setParamAggressiveMST, setParamDefaultMST, setParamFastMST) );
561
562 /* add arrowheur presolver parameters */
563 SCIP_CALL( SCIPaddIntParam(origprob, "detection/detectors/mst/niterations", "Number of iterations to run mst with different eps.", &detectordata->n_iterations, FALSE, DEFAULT_N_ITERATIONS, 11, 1001, NULL, NULL) );
564 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/mst/johson", "Enable johson distance measure.", &detectordata->johnsonenable, FALSE, DEFAULT_JOHNSON_ENABLE, NULL, NULL ) );
565 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/mst/intersection", "Enable intersection distance measure.", &detectordata->intersectionenable, FALSE, DEFAULT_INTERSECTION_ENABLE, NULL, NULL ) );
566 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/mst/jaccard", "Enable jaccard distance measure.", &detectordata->jaccardenable, FALSE, DEFAULT_JACCARD_ENABLE, NULL, NULL) );
567 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/mst/cosine", "Enable cosine distance measure.", &detectordata->cosineenable, FALSE, DEFAULT_COSINE_ENABLE, NULL, NULL) );
568 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/mst/simpson", "Enable simpson distance measure.", &detectordata->simpsonenable, FALSE, DEFAULT_SIMPSON_ENABLE, NULL, NULL ) );
569 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/mst/postprocenable", "Enable post-processing step.", &detectordata->postprocenable, FALSE, DEFAULT_POSTPROC_ENABLE, NULL, NULL ) );
570
571#endif
572 return SCIP_OKAY;
573}
SCIP_VAR * w
RowGraphWeighted(GCG *gcg, Weights w)
GCG_EXPORT int getNVarsForCons(int consIndex)
returns the number of variables for a given constraint
GCG_EXPORT std::vector< int > & getVarsForCons(int consIndex)
returns the variable indices of the coefficient matrix for a constraint
class to manage partial decompositions
GCG_EXPORT int getNOpenvars()
Gets size of vector containing variables not assigned yet.
GCG_EXPORT int getNOpenconss()
Gets size of vector containing constraints not assigned yet.
GCG_EXPORT bool isVarOpenvar(int var)
Checks whether the var is an open var.
GCG_EXPORT void refineToBlocks()
refine partialdec with focus on blocks
GCG_EXPORT std::vector< int > & getOpenconss()
Gets vector containing constraints not assigned yet.
GCG_EXPORT std::vector< int > & getOpenvars()
Gets vector containing variables not assigned yet.
virtual SCIP_RETCODE nonClustered(int &_non_cl)
virtual SCIP_RETCODE createFromPartialMatrix(DETPROBDATA *detprobdata, PARTIALDECOMP *partialdec, DISTANCE_MEASURE dist, WEIGHT_TYPE w_type)
virtual SCIP_RETCODE getNBlocks(int &_n_blocks)
virtual SCIP_RETCODE computePartitionMSTForPartialGraph(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, double eps, bool postprocenable)
virtual SCIP_RETCODE createPartialdecFromPartition(PARTIALDECOMP *oldpartialdec, PARTIALDECOMP **firstpartialdec, PARTIALDECOMP **secondpartialdec, DETPROBDATA *detprobdata)
const char * GCGdetectorGetName(GCG_DETECTOR *detector)
returns the name of the provided detector
GCG_DETECTORDATA * GCGdetectorGetData(GCG_DETECTOR *detector)
returns the data of the provided 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)),)
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 DEFAULT_JOHNSON_ENABLE
#define DEFAULT_INTERSECTION_ENABLE
#define DEFAULT_JACCARD_ENABLE
#define DEFAULT_SIMPSON_ENABLE
#define DEFAULT_POSTPROC_ENABLE
#define DEFAULT_COSINE_ENABLE
#define DEFAULT_N_ITERATIONS
#define MAX_N_BLOCKS
static bool graphCompletible(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec)
Definition dec_mst.cpp:194
#define finishPartialdecMST
Definition dec_mst.cpp:485
#define detectorPostprocessPartialdecMST
Definition dec_mst.cpp:487
SCIP_RETCODE GCGincludeDetectorMST(GCG *gcg)
Definition dec_mst.cpp:544
static std::vector< double > getEpsList(int length, double mid, bool isintersection)
Definition dec_mst.cpp:107
detector for diagonal (bordered) structures via Minimum Spanning Tree clustering algorithm
#define SCIP_MAXSTRLEN
#define SCIP_Bool
#define SCIP_Real
#define SCIP_CALL_ABORT(x)
#define TRUE
#define FALSE
Implementation of the graph which supports both node and edge weights.
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
int SCIPgetNConss(SCIP *scip)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
#define SCIPfreeMemoryArrayNull(scip, ptr)
#define SCIPreallocMemoryArray(scip, ptr, newnum)
#define SCIPallocMemoryArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_RETCODE SCIPresetClock(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)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIPfreeMemory(GCGgetOrigprob(gcg), &divingdata)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIP * origprob
* result
SCIP_VAR * var
int j
int i
#define NULL
miscellaneous matrixgraph methods for structure detection
INLINE Rational & abs(Rational &r)
real eps
A row graph where each row is a node and rows are adjacent if they share a variable....
SCIP_Bool jaccardenable
SCIP_Bool cosineenable
SCIP_Bool johnsonenable
SCIP_Bool intersectionenable
SCIP_Bool simpsonenable
SCIP_Bool postprocenable
struct SCIP_Clock SCIP_CLOCK
#define GCG_DECL_FREEDETECTOR(x)
#define GCG_DECL_INITDETECTOR(x)
#define GCG_DECL_SETPARAMFAST(x)
#define GCG_DECL_SETPARAMDEFAULT(x)
#define GCG_DECL_EXITDETECTOR(x)
#define GCG_DECL_SETPARAMAGGRESSIVE(x)
#define GCG_DECL_PROPAGATEPARTIALDEC(x)
struct GCG_DetectorData GCG_DETECTORDATA
struct Gcg GCG
Definition type_gcg.h:44
SCIP_VERBLEVEL_NORMAL
SCIP_DIDNOTFIND
SCIP_SUCCESS
enum SCIP_Result SCIP_RESULT
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP