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 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 bridge.h
30 * @brief bridge
31 * @author Annika Thome
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36#ifndef GCG_BRIDGE_H
37#define GCG_BRIDGE_H
38#include "objscip/objscip.h"
39#include <vector>
40
41
42namespace gcg
43{
44
45class Bridge
46{
47public:
48 Bridge() {}
49 virtual ~Bridge() {}
50
51 /** add n nodes in the graph at the same time. it is much faster than to call addNode() many times */
52 virtual SCIP_RETCODE addNNodes(int _n_nodes) = 0;
53
54 /** add n nodes in the graph at the same time. it is much faster than to call addNode() many times. weights represent node weights */
55 virtual SCIP_RETCODE addNNodes(int _n_nodes, std::vector<int> weights) = 0;
56
57 /** get number of nodes in the graph */
58 virtual int getNNodes() = 0;
59
60 /** get number of edges in the graph */
61 virtual int getNEdges() = 0;
62
63 /** get list of edges in the graph (not defined how edges are implemented) */
64 virtual SCIP_RETCODE getEdges(std::vector<void*>& edges) = 0;
65
66 /** return whether a given pair of vertices is connected by an edge */
67 virtual SCIP_Bool isEdge(int i, int j) = 0;
68
69 /** get number of neighbors of a given node */
70 virtual int getNNeighbors(int i) = 0;
71
72 /** get a vector of all neighbors of a given node */
73 virtual std::vector<int> getNeighbors(int i) = 0;
74
75 /** adds the node with the given weight to the graph */
76 virtual SCIP_RETCODE addNode(int i,int weight) = 0;
77
78 /** adds the node with 0 weight to the graph */
79 virtual SCIP_RETCODE addNode() = 0;
80
81 /** adds the weighted edge to the graph */
82 virtual SCIP_RETCODE addEdge(int i, int j, double weight) = 0;
83
84 /** sets the weight of the edge in the graph */
85 virtual SCIP_RETCODE setEdge(int i, int j, double weight) = 0;
86
87 /** returns the weight of the edge in the graph */
88 virtual double getEdgeWeight(int i, int j) = 0;
89
90 virtual std::vector<std::pair<int, double> > getNeighborWeights(int i) {return std::vector<std::pair<int, double> >();};
91
92 /** deletes the given node from the graph */
93 virtual SCIP_RETCODE deleteNode(int i) = 0;
94
95 /** adds the edge to the graph */
96 virtual SCIP_RETCODE addEdge(int i, int j) = 0;
97
98 /** deletes the edge from the graph */
99 virtual SCIP_RETCODE deleteEdge(int i, int j) = 0;
100
101 /** return the weight of a node */
102 virtual int graphGetWeights(int i) = 0;
103
104 /** flushes the data stuctures, if needed */
105 virtual SCIP_RETCODE flush() = 0;
106
107 /** normalizes the edge weights, so that the biggest edge egiht in the graph is 1 */
108 virtual SCIP_RETCODE normalize() = 0;
109
110 virtual double getEdgeWeightPercentile(double q) = 0;
111
112#ifdef WITH_GSL
113 /** function needed for MST clustering */
114 virtual void expand(int factor) = 0;
115
116 /** function needed for MST clustering */
117 virtual void inflate(double factor) = 0;
118
119 /** function needed for MST clustering */
120 virtual void colL1Norm() = 0;
121
122 /** function needed for MST clustering */
123 virtual void prune() = 0;
124
125 /** function needed for MST clustering */
126 virtual bool stopMCL(int iter) {return true;}
127
128 virtual std::vector<int> getClustersMCL() {return std::vector<int>();}
129
130 /** function needed for MST clustering */
131 virtual void initMCL() = 0;
132
133 /** function needed for MST clustering */
134 virtual void clearMCL() = 0;
135
136#endif
137
138};
139
140
141} /* namespace gcg*/
142
143#endif
virtual int getNNeighbors(int i)=0
virtual double getEdgeWeightPercentile(double q)=0
virtual ~Bridge()
Definition: bridge.h:49
virtual SCIP_RETCODE getEdges(std::vector< void * > &edges)=0
virtual SCIP_RETCODE setEdge(int i, int j, double weight)=0
virtual SCIP_RETCODE deleteNode(int i)=0
virtual SCIP_RETCODE deleteEdge(int i, int j)=0
virtual SCIP_RETCODE addNNodes(int _n_nodes)=0
virtual int graphGetWeights(int i)=0
virtual double getEdgeWeight(int i, int j)=0
virtual int getNEdges()=0
virtual SCIP_Bool isEdge(int i, int j)=0
virtual SCIP_RETCODE addNNodes(int _n_nodes, std::vector< int > weights)=0
virtual SCIP_RETCODE addEdge(int i, int j, double weight)=0
virtual std::vector< int > getNeighbors(int i)=0
virtual SCIP_RETCODE addEdge(int i, int j)=0
virtual int getNNodes()=0
virtual SCIP_RETCODE flush()=0
virtual SCIP_RETCODE addNode()=0
virtual SCIP_RETCODE addNode(int i, int weight)=0
virtual std::vector< std::pair< int, double > > getNeighborWeights(int i)
Definition: bridge.h:90
virtual SCIP_RETCODE normalize()=0
Bridge()
Definition: bridge.h:48
#define SCIP_Bool
enum SCIP_Retcode SCIP_RETCODE