Scippy

GCG

Branch-and-Price & Column Generation for Everyone

bridge.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
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-2021 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
28 /**@file bridge.h
29  * @brief bridge
30  * @author Annika Thome
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #ifndef GCG_BRIDGE_H
36 #define GCG_BRIDGE_H
37 #include "objscip/objscip.h"
38 #include <vector>
39 
40 
41 namespace gcg
42 {
43 
44 class Bridge
45 {
46 public:
47  Bridge() {}
48  virtual ~Bridge() {}
49 
50  /** add n nodes in the graph at the same time. it is much faster than to call addNode() many times */
51  virtual SCIP_RETCODE addNNodes(int _n_nodes) = 0;
52 
53  /** add n nodes in the graph at the same time. it is much faster than to call addNode() many times. weights represent node weights */
54  virtual SCIP_RETCODE addNNodes(int _n_nodes, std::vector<int> weights) = 0;
55 
56  /** get number of nodes in the graph */
57  virtual int getNNodes() = 0;
58 
59  /** get number of edges in the graph */
60  virtual int getNEdges() = 0;
61 
62  /** get list of edges in the graph (not defined how edges are implemented) */
63  virtual SCIP_RETCODE getEdges(std::vector<void*>& edges) = 0;
64 
65  /** return whether a given pair of vertices is connected by an edge */
66  virtual SCIP_Bool isEdge(int i, int j) = 0;
67 
68  /** get number of neighbors of a given node */
69  virtual int getNNeighbors(int i) = 0;
70 
71  /** get a vector of all neighbors of a given node */
72  virtual std::vector<int> getNeighbors(int i) = 0;
73 
74  /** adds the node with the given weight to the graph */
75  virtual SCIP_RETCODE addNode(int i,int weight) = 0;
76 
77  /** adds the node with 0 weight to the graph */
78  virtual SCIP_RETCODE addNode() = 0;
79 
80  /** adds the weighted edge to the graph */
81  virtual SCIP_RETCODE addEdge(int i, int j, double weight) = 0;
82 
83  /** sets the weight of the edge in the graph */
84  virtual SCIP_RETCODE setEdge(int i, int j, double weight) = 0;
85 
86  /** returns the weight of the edge in the graph */
87  virtual double getEdgeWeight(int i, int j) = 0;
88 
89  virtual std::vector<std::pair<int, double> > getNeighborWeights(int i) {return std::vector<std::pair<int, double> >();};
90 
91  /** deletes the given node from the graph */
92  virtual SCIP_RETCODE deleteNode(int i) = 0;
93 
94  /** adds the edge to the graph */
95  virtual SCIP_RETCODE addEdge(int i, int j) = 0;
96 
97  /** deletes the edge from the graph */
98  virtual SCIP_RETCODE deleteEdge(int i, int j) = 0;
99 
100  /** return the weight of a node */
101  virtual int graphGetWeights(int i) = 0;
102 
103  /** flushes the data stuctures, if needed */
104  virtual SCIP_RETCODE flush() = 0;
105 
106  /** normalizes the edge weights, so that the biggest edge egiht in the graph is 1 */
107  virtual SCIP_RETCODE normalize() = 0;
108 
109  virtual double getEdgeWeightPercentile(double q) = 0;
110 
111 #ifdef WITH_GSL
112  /** function needed for MST clustering */
113  virtual void expand(int factor) = 0;
114 
115  /** function needed for MST clustering */
116  virtual void inflate(double factor) = 0;
117 
118  /** function needed for MST clustering */
119  virtual void colL1Norm() = 0;
120 
121  /** function needed for MST clustering */
122  virtual void prune() = 0;
123 
124  /** function needed for MST clustering */
125  virtual bool stopMCL(int iter) {return true;}
126 
127  virtual std::vector<int> getClustersMCL() {return std::vector<int>();}
128 
129  /** function needed for MST clustering */
130  virtual void initMCL() = 0;
131 
132  /** function needed for MST clustering */
133  virtual void clearMCL() = 0;
134 
135 #endif
136 
137 };
138 
139 
140 } /* namespace gcg*/
141 
142 #endif
virtual int graphGetWeights(int i)=0
virtual int getNNeighbors(int i)=0
virtual SCIP_RETCODE flush()=0
virtual SCIP_RETCODE deleteEdge(int i, int j)=0
virtual int getNNodes()=0
virtual SCIP_RETCODE addNode()=0
virtual double getEdgeWeightPercentile(double q)=0
virtual SCIP_RETCODE addNNodes(int _n_nodes)=0
virtual SCIP_RETCODE getEdges(std::vector< void * > &edges)=0
Bridge()
Definition: bridge.h:47
virtual SCIP_RETCODE setEdge(int i, int j, double weight)=0
virtual std::vector< std::pair< int, double > > getNeighborWeights(int i)
Definition: bridge.h:89
virtual SCIP_RETCODE addEdge(int i, int j, double weight)=0
virtual std::vector< int > getNeighbors(int i)=0
virtual SCIP_RETCODE deleteNode(int i)=0
virtual double getEdgeWeight(int i, int j)=0
virtual SCIP_Bool isEdge(int i, int j)=0
virtual ~Bridge()
Definition: bridge.h:48
virtual int getNEdges()=0
virtual SCIP_RETCODE normalize()=0