Scippy

GCG

Branch-and-Price & Column Generation for Everyone

dec_dbscan.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_dbscan.cpp
30 *
31 * @brief detector DBSCAN
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 DBSCAN 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 <string>
42#include <algorithm>
43#include <iostream>
44#include "gcg/dec_dbscan.h"
45#include "gcg/cons_decomp.h"
46#include "graph/matrixgraph.h"
48#include "graph/graph_gcg.h"
49#include "scip/clock.h"
50
52using gcg::Weights;
53using gcg::GraphGCG;
54
55
56/* constraint handler properties */
57#define DEC_NAME "dbscan" /**< name of detector */
58#define DEC_DESC "detector based on DBSCAN clustering" /**< description of detector */
59#define DEC_PRIORITY 901 /**< 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 'D' /**< 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
74/* Default parameter settings*/
75#define DEFAULT_N_ITERATIONS 51
76#define DEFAULT_JOHNSON_ENABLE true
77#define DEFAULT_INTERSECTION_ENABLE false
78#define DEFAULT_JACCARD_ENABLE false
79#define DEFAULT_COSINE_ENABLE false
80#define DEFAULT_SIMPSON_ENABLE false
81#define DEFAULT_POSTPROC_ENABLE true
82#define MAX_N_BLOCKS 100
83
84/*
85 * Data structures
86 */
87
88/** detector handler data */
90{
91 SCIP_RESULT result; /**< result pointer to indicate success or failure */
94 int n_similarities; /**< number of active similarities */
101};
102
103
104/*
105 * Local methods
106 */
107
108static std::vector<double> getEpsList(int length, double mid, bool isintersection)
109{
110 int n1, n2;
111 if(isintersection)
112 {
113 n1 = (int) round((length+1) / 2.0);
114 n2 = n1;
115 }
116 else
117 {
118 n2 = (int) round((length+1) / 4.0);
119 n1 = abs(length - n2) + 1;
120 }
121
122 double s = mid;
123 double end1 = mid + 0.9; // lower boundary
124 double end2 = mid + 0.4; // upper boundary
125
126 double q1 = pow(end1/s, 1.0/(double)(n1-1));
127 double q2 = pow(end2/s, 1.0/(double)(n2-1));
128
129 std::vector<double> geom_seq1(n1-1);
130 std::vector<double> geom_seq2(n2);
131
132 int j = 0;
133 for(int i = n1 - 1; i > 0; i--)
134 {
135 geom_seq1[j] = 2*s-s*pow(q1, (double)i);
136 j++;
137 }
138 for(int i = 0; i < n2; i++)
139 {
140 geom_seq2[i] = s*pow(q2, (double)i);
141 }
142
143 geom_seq1.insert( geom_seq1.end(), geom_seq2.begin(), geom_seq2.end() );
144
145 assert((int)geom_seq1.size() == length);
146
147 return geom_seq1;
148}
149
150/*
151 * detector callback methods
152 */
153
154/** destructor of detector to free user data (called when GCG is exiting) */
155static
157{
158 GCG_DETECTORDATA* detectordata;
159
160 detectordata = GCGdetectorGetData(detector);
161 assert(detectordata != NULL);
162 assert(strcmp(GCGdetectorGetName(detector), DEC_NAME) == 0);
163
164 SCIPfreeMemory(GCGgetOrigprob(gcg), &detectordata);
165
166 return SCIP_OKAY;
167}
168
169/** destructor of detector to free detector data (called before the solving process begins) */
170static
172{
173 return SCIP_OKAY;
174}
175
176
177/** detection initialization function of detector (called before solving is about to begin) */
178static
180{ /*lint --e{715}*/
181
182 GCG_DETECTORDATA* detectordata;
183
184 detectordata = GCGdetectorGetData(detector);
185 assert(detectordata != NULL);
186 assert(strcmp(GCGdetectorGetName(detector), DEC_NAME) == 0);
187
188 detectordata->n_similarities = -1;
189 detectordata->found = FALSE;
190 return SCIP_OKAY;
191}
192
193/** are there conss and vars to be included by the graph and have the conss common vars included by the graph */
194static
196 gcg::DETPROBDATA* detprobdata,
197 gcg::PARTIALDECOMP* partialdec
198 )
199{
200 bool completible;
201
202 //have the open conss open vars?
203 for(int c = 0; c < partialdec->getNOpenconss() && !completible; ++c)
204 {
205 int cons = partialdec->getOpenconss()[c];
206 for(int v = 0; v < partialdec->getNOpenvars() && !completible; ++v)
207 {
208 int var = partialdec->getOpenvars()[v];
209 for(int i = 0; i < detprobdata->getNVarsForCons(cons) && !completible; ++i)
210 {
211 if(var == detprobdata->getVarsForCons(cons)[i])
212 {
213 completible = true;
214 }
215 }
216 }
217 }
218 if(!completible)
219 return false;
220
221 //have the open conss common open vars?
222 for(int c = 0; c < partialdec->getNOpenconss(); ++c)
223 {
224 int cons1 = partialdec->getOpenconss()[c];
225 for(int d = c + 1; d < partialdec->getNOpenconss(); ++d)
226 {
227 int cons2 = partialdec->getOpenconss()[d];
228 for(int v = 0; v < detprobdata->getNVarsForCons(cons1); ++v)
229 {
230 int var1 = detprobdata->getVarsForCons(cons1)[v];
231 if(!partialdec->isVarOpenvar(var1))
232 continue;
233 for(int w = 0; w < detprobdata->getNVarsForCons(cons2); ++w)
234 {
235 int var2 = detprobdata->getVarsForCons(cons2)[w];
236 if(var1 == var2)
237 return true;
238 }
239 }
240 }
241 }
242 return false;
243}
244
245
246static
247GCG_DECL_PROPAGATEPARTIALDEC(propagatePartialdecDBSCAN)
248{ /*lint --e{715}*/
249
250 int nnewpartialdecs;
251 gcg::PARTIALDECOMP* partialdec;
252 GCG_DETECTORDATA* detectordata = GCGdetectorGetData(detector);
253 std::vector<SCIP_Real> clockTimes1; /* vector containing times in seconds */
254 std::vector<SCIP_Real> clockTimes2; /* vector containing times in seconds */
255 std::vector< RowGraphWeighted<GraphGCG>*> graphs;
256 SCIP_CLOCK* overallClock;
257 SCIP* origprob = GCGgetOrigprob(gcg);
258 assert(origprob != NULL);
259
260 assert(detectordata != NULL);
261 *result = SCIP_DIDNOTFIND;
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 delete partialdec;
272 partialdecdetectiondata->nnewpartialdecs = 0;
273 SCIP_CALL_ABORT( SCIPstopClock(origprob, overallClock) );
274 partialdecdetectiondata->detectiontime = SCIPgetClockTime(origprob, overallClock);
275 SCIP_CALL_ABORT(SCIPfreeClock(origprob, &overallClock) );
276 *result = SCIP_SUCCESS;
277 return SCIP_OKAY;
278 }
279
280 Weights w(1, 1, 1, 1, 1, 1);
281
282 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, "Detecting DBSCAN structure:");
283
284 time_t start, cp0, d_s, d_e;
285 time(&start);
286
287 std::vector<std::string> sim;
288 SCIP_CLOCK* temporaryClock;
289
290 SCIP_CALL_ABORT( SCIPcreateClock(origprob, &temporaryClock) );
291
292 if( detectordata->johnsonenable )
293 {
294 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
296 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec, gcg::DISTANCE_MEASURE::JOHNSON, gcg::WEIGHT_TYPE::DIST));
297 graphs.push_back(g);
298 sim.emplace_back("Johnson");
299 SCIP_CALL_ABORT( SCIPstopClock(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.emplace_back("Intersection");
310 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
311 clockTimes1.push_back(SCIPgetClockTime( origprob, temporaryClock));
312 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
313 }
314 if( detectordata->jaccardenable )
315 {
316 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
318 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec, gcg::DISTANCE_MEASURE::JACCARD, gcg::WEIGHT_TYPE::DIST));
319 graphs.push_back(g);
320 sim.emplace_back("Jaccard");
321 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
322 clockTimes1.push_back(SCIPgetClockTime( origprob, temporaryClock));
323 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
324 }
325 if( detectordata->cosineenable )
326 {
327 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
329 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec, gcg::DISTANCE_MEASURE::COSINE, gcg::WEIGHT_TYPE::DIST));
330 graphs.push_back(g);
331 sim.emplace_back("Cosine");
332 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
333 clockTimes1.push_back(SCIPgetClockTime( origprob, temporaryClock));
334 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
335 }
336 if( detectordata->simpsonenable )
337 {
338 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
340 SCIP_CALL( g->createFromPartialMatrix(partialdecdetectiondata->detprobdata, partialdec, gcg::DISTANCE_MEASURE::SIMPSON, gcg::WEIGHT_TYPE::DIST));
341 graphs.push_back(g);
342 sim.emplace_back("Simspon");
343 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
344 clockTimes1.push_back(SCIPgetClockTime( origprob, temporaryClock));
345 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
346 }
347 time(&cp0);
348 detectordata->n_similarities = (int) graphs.size();
349
350 double q = 10; // quantile to search for the percentile needed for the mid of the eps list
351 std::vector<double> mids(graphs.size()); // middle values for each eps list
352 std::vector<std::vector<double> > epsLists(graphs.size());
353 for( int i = 0; i < (int)graphs.size(); i++ )
354 {
355 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
356 mids[i] = graphs.at(i)->getEdgeWeightPercentile(q);
357 if( i == 1 && detectordata->intersectionenable )
358 {
359 epsLists[i] = getEpsList(detectordata->n_iterations, mids[i], true); // case for intersection
360 }
361 else
362 {
363 epsLists[i] = getEpsList(detectordata->n_iterations, mids[i], false); // case for all except intersection
364 }
365 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock) );
366 clockTimes2.push_back(SCIPgetClockTime( origprob, temporaryClock));
367 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock) );
368 }
369
370 int nMaxPartialdecs = detectordata->n_iterations * (int) graphs.size();
371 const int max_blocks = std::min((int)round(0.3 * SCIPgetNConss(origprob)), MAX_N_BLOCKS);
372 char decinfo[SCIP_MAXSTRLEN];
373
374 SCIP_CALL( SCIPallocMemoryArray(origprob, &(partialdecdetectiondata->newpartialdecs), 2 * nMaxPartialdecs) );
375 nnewpartialdecs = 0;
376 time(&d_s);
377 for( int i = 0; i < (int)graphs.size(); i++ )
378 {
379 RowGraphWeighted<GraphGCG>* graph = graphs.at(i);
380 int old_n_blocks = -1;
381 int old_non_cl = -1;
382 std::vector<gcg::PARTIALDECOMP*> createddecomps;
383 std::vector<std::pair<double, SCIP_Real>> clockTimes3;
384 gcg::PARTIALDECOMP *decomp1 = NULL, *decomp2 = NULL;
385
386 SCIP_CALL_ABORT( SCIPstartClock(origprob, temporaryClock) );
387 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, "\n %s similarity:", sim[i].c_str());
388 createddecomps.reserve(2 * epsLists[i].size());
389 clockTimes3.reserve(epsLists[i].size());
390
391 for( double eps : epsLists[i] )
392 {
393 if( eps <= 0.0 )
394 {
395 continue;
396 }
397 if( eps >= 1.0 )
398 {
399 break;
400 }
401
402 // run DBSCAN with different eps
403 SCIP_CALL( graph->computePartitionDBSCANForPartialGraph(partialdecdetectiondata->detprobdata, partialdec, eps, detectordata->postprocenable) );
404
405 int n_blocks;
406 int non_cl;
407 SCIP_CALL( graph->getNBlocks(n_blocks) );
408 SCIP_CALL( graph->nonClustered(non_cl) );
409
410 // 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
411 if( n_blocks > max_blocks || n_blocks == 0 || (n_blocks == old_n_blocks && non_cl == old_non_cl) )
412 {
413 continue;
414 }
415 // stop. eps is already too big
416 if( n_blocks == 1 && non_cl == 0)
417 {
418 break;
419 }
420 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, "\n Blocks: %d, Master Conss: %d/%d, ", n_blocks, non_cl, SCIPgetNConss(origprob));
421 old_n_blocks = n_blocks;
422 old_non_cl = non_cl;
423
424 SCIP_CALL( graph->createPartialdecFromPartition(partialdec, &decomp1, &decomp2, partialdecdetectiondata->detprobdata));
425 SCIP_CALL_ABORT( SCIPstopClock(origprob, temporaryClock ) );
426
427 if( decomp1 != NULL )
428 {
429 assert(decomp2 != NULL);
430 detectordata->found = TRUE;
431 createddecomps.push_back(decomp1);
432 createddecomps.push_back(decomp2);
433 clockTimes3.emplace_back(eps, SCIPgetClockTime(origprob, temporaryClock));
434 }
435
436 SCIP_CALL_ABORT( SCIPresetClock(origprob, temporaryClock ) );
437 }
438
439 size_t ncreateddecomps = createddecomps.size();
440 for( unsigned int j = 0; j < ncreateddecomps; ++j )
441 {
442 double eps = clockTimes3[j / 2].first;
443 SCIP_Real epstime = clockTimes3[j / 2].second;
444 (void) SCIPsnprintf(decinfo, SCIP_MAXSTRLEN, "dbscan_%s_%f", sim[i].c_str(), eps);
445 createddecomps[j]->addDetectorChainInfo(decinfo);
446 createddecomps[j]->addClockTime(clockTimes1[i] / ncreateddecomps + clockTimes2[i] / ncreateddecomps + epstime / 2.0);
447 partialdecdetectiondata->newpartialdecs[nnewpartialdecs + j] = createddecomps[j];
448 }
449 nnewpartialdecs += (int) ncreateddecomps;
450
451 delete graphs.at(i);
452 graphs[i] = NULL;
453 }
454
455 SCIP_CALL( SCIPreallocMemoryArray(origprob, &(partialdecdetectiondata->newpartialdecs), nnewpartialdecs) );
456 partialdecdetectiondata->nnewpartialdecs = nnewpartialdecs;
457 SCIP_CALL_ABORT( SCIPstopClock(origprob, overallClock) );
458 partialdecdetectiondata->detectiontime = SCIPgetClockTime(origprob, overallClock);
459 SCIP_CALL_ABORT(SCIPfreeClock(origprob, &overallClock) );
460
461 time(&d_e);
462 double elapsed_graphs = difftime(cp0, start);
463 double elapsed_dbscan = difftime(d_e, d_s);
464
465 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, " done, %d similarities used, %d partialdecs found.\n", detectordata->n_similarities, nnewpartialdecs);
466 SCIPverbMessage(origprob, SCIP_VERBLEVEL_NORMAL, NULL, "DBSCAN Runtime: graphs: %.2lf, dbscan: %.2lf. \n", elapsed_graphs, elapsed_dbscan);
467
468 *result = nnewpartialdecs > 0 ? SCIP_SUCCESS: SCIP_DIDNOTFIND;
469 if( nnewpartialdecs == 0 )
470 {
471 SCIPfreeMemoryArrayNull(origprob, &(partialdecdetectiondata->newpartialdecs));
472 }
473 SCIP_CALL_ABORT(SCIPfreeClock(origprob, &temporaryClock) );
474 return SCIP_OKAY;
475}
476
477#define finishPartialdecDBSCAN NULL
478#define detectorPostprocessPartialdecDBSCAN NULL
479
480static
481GCG_DECL_SETPARAMAGGRESSIVE(setParamAggressiveDBSCAN)
482{
483 char setstr[SCIP_MAXSTRLEN];
484 const char* name = GCGdetectorGetName(detector);
485 SCIP* origprob = GCGgetOrigprob(gcg);
486 assert(origprob != NULL);
487
488 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", name);
489 SCIP_CALL( SCIPsetBoolParam(origprob, setstr, FALSE) );
490
491 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", name);
492 SCIP_CALL( SCIPsetBoolParam(origprob, setstr, FALSE ) );
493
494 return SCIP_OKAY;
495}
496
497
498static
499GCG_DECL_SETPARAMDEFAULT(setParamDefaultDBSCAN)
500{
501 char setstr[SCIP_MAXSTRLEN];
502 const char* name = GCGdetectorGetName(detector);
503 SCIP* origprob = GCGgetOrigprob(gcg);
504 assert(origprob != NULL);
505
506 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", name);
507 SCIP_CALL( SCIPsetBoolParam(origprob, setstr, DEC_ENABLED) );
508
509 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", name);
510 SCIP_CALL( SCIPsetBoolParam(origprob, setstr, DEC_ENABLEDFINISHING ) );
511
512 return SCIP_OKAY;
513}
514
515static
516GCG_DECL_SETPARAMFAST(setParamFastDBSCAN)
517{
518 char setstr[SCIP_MAXSTRLEN];
519 const char* name = GCGdetectorGetName(detector);
520 SCIP* origprob = GCGgetOrigprob(gcg);
521 assert(origprob != NULL);
522
523 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", name);
524 SCIP_CALL( SCIPsetBoolParam(origprob, setstr, FALSE) );
525
526 (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", name);
527 SCIP_CALL( SCIPsetBoolParam(origprob, setstr, FALSE ) );
528
529
530 return SCIP_OKAY;
531}
532
533
534
535/*
536 * detector specific interface methods
537 */
538
539/** creates the handler for xyz detector and includes it in SCIP */
541 GCG* gcg /**< GCG data structure */
542 )
543{
544#if !defined(_WIN32) && !defined(_WIN64)
545 GCG_DETECTORDATA *detectordata = NULL;
546 SCIP* origprob = GCGgetOrigprob(gcg);
547 assert(origprob != NULL);
548 assert(origprob != NULL);
549
550 SCIP_CALL( SCIPallocMemory(origprob, &detectordata) );
551
552 assert(detectordata != NULL);
553 detectordata->found = FALSE;
554
556 detectordata, freeDBSCAN, initDBSCAN, exitDBSCAN, propagatePartialdecDBSCAN, finishPartialdecDBSCAN, detectorPostprocessPartialdecDBSCAN, setParamAggressiveDBSCAN, setParamDefaultDBSCAN, setParamFastDBSCAN) );
557
558 /* add arrowheur presolver parameters */
559 SCIP_CALL( SCIPaddIntParam(origprob, "detection/detectors/dbscan/niterations", "Number of iterations to run dbscan with different eps.", &detectordata->n_iterations, FALSE, DEFAULT_N_ITERATIONS, 11, 1001, NULL, NULL) );
560 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/dbscan/johson", "Enable johson distance measure.", &detectordata->johnsonenable, FALSE, DEFAULT_JOHNSON_ENABLE, NULL, NULL ) );
561 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/dbscan/intersection", "Enable intersection distance measure.", &detectordata->intersectionenable, FALSE, DEFAULT_INTERSECTION_ENABLE, NULL, NULL ) );
562 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/dbscan/jaccard", "Enable jaccard distance measure.", &detectordata->jaccardenable, FALSE, DEFAULT_JACCARD_ENABLE, NULL, NULL) );
563 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/dbscan/cosine", "Enable cosine distance measure.", &detectordata->cosineenable, FALSE, DEFAULT_COSINE_ENABLE, NULL, NULL) );
564 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/dbscan/simpson", "Enable simpson distance measure.", &detectordata->simpsonenable, FALSE, DEFAULT_SIMPSON_ENABLE, NULL, NULL ) );
565 SCIP_CALL( SCIPaddBoolParam(origprob, "detection/detectors/dbscan/postprocenable", "Enable post-processing step.", &detectordata->postprocenable, FALSE, DEFAULT_POSTPROC_ENABLE, NULL, NULL ) );
566
567#endif
568 return SCIP_OKAY;
569}
SCIP_VAR * 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 computePartitionDBSCANForPartialGraph(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, double eps, bool postprocenable)
virtual SCIP_RETCODE getNBlocks(int &_n_blocks)
virtual SCIP_RETCODE createPartialdecFromPartition(PARTIALDECOMP *oldpartialdec, PARTIALDECOMP **firstpartialdec, PARTIALDECOMP **secondpartialdec, DETPROBDATA *detprobdata)
Definition: rowgraph_def.h:134
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)),)
constraint handler for structure detection
static GCG_DECL_EXITDETECTOR(exitDBSCAN)
Definition: dec_dbscan.cpp:171
static bool graphCompletible(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec)
Definition: dec_dbscan.cpp:195
#define DEFAULT_JOHNSON_ENABLE
Definition: dec_dbscan.cpp:76
#define DEC_MAXCALLROUND
Definition: dec_dbscan.cpp:61
#define DEC_MINCALLROUNDORIGINAL
Definition: dec_dbscan.cpp:65
#define DEFAULT_INTERSECTION_ENABLE
Definition: dec_dbscan.cpp:77
#define DEC_ENABLEDFINISHING
Definition: dec_dbscan.cpp:68
#define detectorPostprocessPartialdecDBSCAN
Definition: dec_dbscan.cpp:478
#define DEC_ENABLED
Definition: dec_dbscan.cpp:67
#define DEFAULT_JACCARD_ENABLE
Definition: dec_dbscan.cpp:78
static GCG_DECL_SETPARAMDEFAULT(setParamDefaultDBSCAN)
Definition: dec_dbscan.cpp:499
static GCG_DECL_INITDETECTOR(initDBSCAN)
Definition: dec_dbscan.cpp:179
#define DEFAULT_SIMPSON_ENABLE
Definition: dec_dbscan.cpp:80
#define DEFAULT_POSTPROC_ENABLE
Definition: dec_dbscan.cpp:81
#define DEC_DECCHAR
Definition: dec_dbscan.cpp:66
#define DEC_NAME
Definition: dec_dbscan.cpp:57
SCIP_RETCODE GCGincludeDetectorDBSCAN(GCG *gcg)
Definition: dec_dbscan.cpp:540
#define DEC_MINCALLROUND
Definition: dec_dbscan.cpp:62
#define DEC_ENABLEDPOSTPROCESSING
Definition: dec_dbscan.cpp:69
#define DEFAULT_COSINE_ENABLE
Definition: dec_dbscan.cpp:79
#define DEC_DESC
Definition: dec_dbscan.cpp:58
static GCG_DECL_SETPARAMAGGRESSIVE(setParamAggressiveDBSCAN)
Definition: dec_dbscan.cpp:481
#define DEC_FREQCALLROUND
Definition: dec_dbscan.cpp:60
#define DEC_PRIORITY
Definition: dec_dbscan.cpp:59
static GCG_DECL_FREEDETECTOR(freeDBSCAN)
Definition: dec_dbscan.cpp:156
static GCG_DECL_SETPARAMFAST(setParamFastDBSCAN)
Definition: dec_dbscan.cpp:516
#define DEC_USEFULRECALL
Definition: dec_dbscan.cpp:71
static std::vector< double > getEpsList(int length, double mid, bool isintersection)
Definition: dec_dbscan.cpp:108
#define DEC_SKIP
Definition: dec_dbscan.cpp:70
#define DEC_MAXCALLROUNDORIGINAL
Definition: dec_dbscan.cpp:64
#define DEFAULT_N_ITERATIONS
Definition: dec_dbscan.cpp:75
#define DEC_FREQCALLROUNDORIGINAL
Definition: dec_dbscan.cpp:63
#define finishPartialdecDBSCAN
Definition: dec_dbscan.cpp:477
static GCG_DECL_PROPAGATEPARTIALDEC(propagatePartialdecDBSCAN)
Definition: dec_dbscan.cpp:247
#define MAX_N_BLOCKS
Definition: dec_dbscan.cpp:82
detector for diagonal (bordered) structures via DBSCAN clustering algorithm
#define SCIP_MAXSTRLEN
#define SCIP_Bool
#define SCIP_Real
#define SCIP_CALL_ABORT(x)
#define SCIP_CALL(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)
#define SCIPfreeMemory(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,...)
#define NULL
miscellaneous matrixgraph methods for structure detection
@ INTERSECTION
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
Definition: dec_dbscan.cpp:97
SCIP_Bool cosineenable
Definition: dec_dbscan.cpp:98
SCIP_Bool johnsonenable
Definition: dec_dbscan.cpp:95
SCIP_Bool intersectionenable
Definition: dec_dbscan.cpp:96
SCIP_Bool simpsonenable
Definition: dec_dbscan.cpp:99
SCIP_Bool found
Definition: dec_dbscan.cpp:92
SCIP_RESULT result
Definition: dec_dbscan.cpp:91
SCIP_Bool postprocenable
Definition: dec_dbscan.cpp:100
Definition: struct_gcg.h:55
SCIP_VERBLEVEL_NORMAL
SCIP_DIDNOTFIND
SCIP_SUCCESS
enum SCIP_Result SCIP_RESULT
SCIP_OKAY
enum SCIP_Retcode SCIP_RETCODE