GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
rowgraph_weighted.h
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 rowgraph_weighted.h
30 * @brief A row graph where each row is a node and rows are adjacent if they share a variable.
31 * The edges are weighted according to specified similarity measure.
32 * @author Igor Pesic
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
37#ifndef GCG_ROWGRAPH_WEIGHTED_H_
38#define GCG_ROWGRAPH_WEIGHTED_H_
39
40#include "graph/graph.h"
41#include "graph/rowgraph.h"
42
43namespace gcg {
44
54
56{
57 SIM = 0,
58 DIST = 1
59};
61
62
63template <class T>
65{
66private:
67 int n_blocks;
68 int non_cl;
69
70 /** removes the colliding rows from the clusters (should be used just after clustering)
71 * Method: Assign labels to columns and remove conss where column label doesn't match the conss label.
72 */
73 virtual SCIP_RETCODE postProcess(std::vector<int>& labels, bool enabled);
74
75 virtual SCIP_RETCODE postProcessForPartialGraph(gcg::DETPROBDATA* detprobdata, gcg::PARTIALDECOMP* partialdec, std::vector<int>& labels, bool enabled);
76
77 /** removes the colliding rows from the clusters (should be used just after clustering)
78 * Method: solve the stable set problem with greedy heuristic
79 * NOTE: this function is obsolete because the new version of postProcess has the same results, and is faster
80 */
81 virtual SCIP_RETCODE postProcessStableSet(std::vector<int>& labels, bool enabled);
82
83 virtual SCIP_RETCODE postProcessStableSetForPartialGraph(gcg::DETPROBDATA* detprobdata, gcg::PARTIALDECOMP* partialdec, std::vector<int>& labels, bool enabled);
84
85public:
87 GCG* gcg, /**< GCG data structure */
88 Weights w /**< weights for the given graph */
89 );
90 virtual ~RowGraphWeighted();
91
92 // we need this to avoid the warning of hidding the parent function
94
96 SCIP_CONS** conss, /**< constraints for which graph should be created */
97 SCIP_VAR** vars, /**< variables for which graph should be created */
98 int nconss_, /**< number of constraints */
99 int nvars_, /**< number of variables */
100 DISTANCE_MEASURE dist, /**< Here we define the distance measure between two rows */
101 WEIGHT_TYPE w_type /**< Depending on the algorithm we can build distance or similarity graph */
102 );
103
104 // we need this to avoid the warning of hidding the parent function
106
107 /** creates a graph with open constraints and open variables of the partialdec */
109 DETPROBDATA* detprobdata, /**< detection process information and data */
110 PARTIALDECOMP* partialdec, /**< partial decomposition to use for matrix */
111 DISTANCE_MEASURE dist, /**< Here we define the distance measure between two rows */
112 WEIGHT_TYPE w_type /**< Depending on the algorithm we can build distance or similarity graph */
113 );
114
115 static double calculateSimilarity(
116 int a, /**< number of common variables in two rows */
117 int b, /**< number of variables that appear only in the 2nd row */
118 int c, /**< number of variables that appear only in the 1st row */
119 DISTANCE_MEASURE dist, /**< Here we define the distance measure between two rows */
120 WEIGHT_TYPE w_type, /**< Depending on the algorithm we can build distance or similarity graph */
121 bool itself /**< true if we calculate similarity between the row itself */
122 );
123
124 /** return a partition of the nodes with the help of DBSCAN */
125 virtual SCIP_RETCODE computePartitionDBSCAN(double eps, bool postprocenable);
126
127 /** return a partition of the nodes with the help of DBSCAN */
128 virtual SCIP_RETCODE computePartitionDBSCANForPartialGraph(gcg::DETPROBDATA* detprobdata, gcg::PARTIALDECOMP* partialdec, double eps, bool postprocenable);
129
130 /** return a partition of the nodes with the help of MST */
131 virtual SCIP_RETCODE computePartitionMST(double eps, bool postprocenable);
132
133 /** return a partition of the nodes with the help of MST */
134 virtual SCIP_RETCODE computePartitionMSTForPartialGraph(gcg::DETPROBDATA* detprobdata, gcg::PARTIALDECOMP* partialdec, double eps, bool postprocenable);
135
136 /** return a partition of the nodes with the help of MST */
137 virtual SCIP_RETCODE computePartitionMCL(int& stoppedAfter, double inflatefactor, bool postprocenable);
138
139 /** return a partition of the nodes with the help of MST */
140 virtual SCIP_RETCODE computePartitionMCLForPartialGraph(gcg::DETPROBDATA* detprobdata, gcg::PARTIALDECOMP* partialdec, int& stoppedAfter, double inflatefactor, bool postprocenable);
141
142 /** return the number of clusters after post-processing */
143 virtual SCIP_RETCODE getNBlocks(int& _n_blocks);
144
145 virtual SCIP_RETCODE nonClustered(int& _non_cl);
146
147 virtual double getEdgeWeightPercentile(double q);
148
149
150};
151
152} /* namespace gcg */
153#endif /* GCG_ROWGRAPH_WEIGHTED_H_ */
SCIP_VAR * w
SCIP_VAR * a
SCIP_VAR ** b
class to manage partial decompositions
virtual SCIP_RETCODE computePartitionMCL(int &stoppedAfter, double inflatefactor, bool postprocenable)
virtual SCIP_RETCODE nonClustered(int &_non_cl)
virtual SCIP_RETCODE createFromPartialMatrix(DETPROBDATA *detprobdata, PARTIALDECOMP *partialdec, DISTANCE_MEASURE dist, WEIGHT_TYPE w_type)
static double calculateSimilarity(int a, int b, int c, DISTANCE_MEASURE dist, WEIGHT_TYPE w_type, bool itself)
virtual SCIP_RETCODE computePartitionDBSCANForPartialGraph(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, double eps, bool postprocenable)
virtual SCIP_RETCODE getNBlocks(int &_n_blocks)
virtual SCIP_RETCODE createFromMatrix(SCIP_CONS **conss, SCIP_VAR **vars, int nconss_, int nvars_, DISTANCE_MEASURE dist, WEIGHT_TYPE w_type)
virtual SCIP_RETCODE computePartitionMSTForPartialGraph(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, double eps, bool postprocenable)
virtual SCIP_RETCODE computePartitionMST(double eps, bool postprocenable)
virtual SCIP_RETCODE computePartitionDBSCAN(double eps, bool postprocenable)
virtual SCIP_RETCODE computePartitionMCLForPartialGraph(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, int &stoppedAfter, double inflatefactor, bool postprocenable)
RowGraphWeighted(GCG *gcg, Weights w)
virtual double getEdgeWeightPercentile(double q)
miscellaneous graph methods for structure detection
SCIP_VAR ** vars
enum DistanceMeasure DISTANCE_MEASURE
enum WeightType WEIGHT_TYPE
real eps
A row graph where each row is a node and rows are adjacent if they share a variable.
struct SCIP_Cons SCIP_CONS
struct Gcg GCG
Definition type_gcg.h:44
enum SCIP_Retcode SCIP_RETCODE
struct SCIP_Var SCIP_VAR