Scippy

GCG

Branch-and-Price & Column Generation for Everyone

graph_tclique.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 graph_tclique.cpp
30 * @brief interface to the SCIP tclique graph library
31 * @author Annika Thome
32 * @author Martin Bergner
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36/*lint -e39*/
37#include <cassert>
38#include "graph/graph_tclique.h"
39
40#define TCLIQUE_CALL_EXC(x) do \
41 { \
42 SCIP_Bool _restat_; \
43 if( (_restat_ = (x)) != TRUE ) \
44 { \
45 SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
46 throw std::exception(); \
47 } \
48 } \
49 while( FALSE )
50
51#define TCLIQUE_CALL(x) do \
52 { \
53 SCIP_Bool _restat_; \
54 if( (_restat_ = (x)) != TRUE ) \
55 { \
56 SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
57 return SCIP_ERROR; \
58 } \
59 } \
60 while( FALSE )
61
62
63namespace gcg {
64
66{
68}
69
71{
72 return SCIP_INVALIDCALL;
73}
74
75SCIP_RETCODE GraphTclique::addNNodes(int _n_nodes, std::vector<int> weights)
76{
77 return SCIP_INVALIDCALL;
78}
79
80
82{
83 tcliqueFree(&graph);
84}
85
87{
88 return tcliqueGetNNodes(graph);
89}
90
92{
93 return tcliqueGetNEdges(graph);
94}
95
96SCIP_RETCODE GraphTclique::getEdges(std::vector<void*>& edges)
97{
98 return SCIP_INVALIDCALL;
99}
100
101
103{
104 assert(i >= 0);
105 assert(j >= 0);
106
107 return tcliqueIsEdge(graph, i, j);
108}
109
111{
112 assert( i >= 0);
113 return int( tcliqueGetLastAdjedge(graph,i)-tcliqueGetFirstAdjedge(graph, i)+1 );
114}
115
116std::vector<int> GraphTclique::getNeighbors(int i)
117{
118 assert(i >= 0);
119 std::vector<int> part(tcliqueGetFirstAdjedge(graph, i), tcliqueGetLastAdjedge(graph,i)+1);
120 return part;
121}
122
124{
125 assert(i >= getNNodes());
126 TCLIQUE_CALL( tcliqueAddNode(graph,i,weight) );
127 return SCIP_OKAY;
128}
129
131{
132 return SCIP_INVALIDCALL;
133}
134
136{ /*lint -e715*/
137 return SCIP_ERROR;
138}
139
141{
142 assert(i >=0);
143 assert(i < getNNodes());
144 assert(j >=0);
145 assert(j < getNNodes());
146
147 TCLIQUE_CALL( tcliqueAddEdge(graph,i,j) );
148 return SCIP_OKAY;
149
150}
151
152SCIP_RETCODE GraphTclique::addEdge(int i, int j, double weight)
153{
154 return SCIP_INVALIDCALL;
155}
156
157SCIP_RETCODE GraphTclique::setEdge(int i, int j, double weight)
158{
159 return SCIP_INVALIDCALL;
160}
161
162double GraphTclique::getEdgeWeight(int i, int j)
163{
164 return 0.0;
165}
166
167std::vector<std::pair<int, double> > GraphTclique::getNeighborWeights(int i)
168{
169 return std::vector<std::pair<int, double> >();
170}
171
173{ /*lint -e715*/
174 return SCIP_ERROR;
175}
176
177
179{
180 TCLIQUE_CALL( tcliqueFlush(graph) );
181
182 return SCIP_OKAY;
183}
184
186{
187 assert( i >= 0);
188 assert( i <= getNNodes());
189 const TCLIQUE_WEIGHT* weights;
190 weights = tcliqueGetWeights(graph);
191 return weights[i];
192}
193
195 // this function is used only in GraphGCG
196 return SCIP_INVALIDCALL;
197}
198
200{
201 return 0.0;
202}
203
204
205} /* namespace gcg */
virtual SCIP_RETCODE addEdge(int i, int j)
virtual SCIP_RETCODE addNNodes(int _n_nodes)
virtual std::vector< int > getNeighbors(int i)
virtual std::vector< std::pair< int, double > > getNeighborWeights(int i)
virtual SCIP_RETCODE flush()
virtual int getNEdges()
virtual SCIP_RETCODE deleteEdge(int i, int j)
virtual int getNNeighbors(int i)
virtual int graphGetWeights(int i)
virtual SCIP_RETCODE setEdge(int i, int j, double weight)
virtual SCIP_RETCODE normalize()
virtual SCIP_RETCODE addNode()
virtual SCIP_RETCODE getEdges(std::vector< void * > &edges)
virtual SCIP_RETCODE deleteNode(int i)
virtual double getEdgeWeightPercentile(double q)
virtual double getEdgeWeight(int i, int j)
virtual int getNNodes()
virtual SCIP_Bool isEdge(int i, int j)
virtual ~GraphTclique()
#define SCIP_Bool
#define TCLIQUE_CALL_EXC(x)
#define TCLIQUE_CALL(x)
interface to the SCIP tclique graph library
int tcliqueGetNEdges(TCLIQUE_GRAPH *tcliquegraph)
int * tcliqueGetLastAdjedge(TCLIQUE_GRAPH *tcliquegraph, int node)
void tcliqueFree(TCLIQUE_GRAPH **tcliquegraph)
int TCLIQUE_WEIGHT
int * tcliqueGetFirstAdjedge(TCLIQUE_GRAPH *tcliquegraph, int node)
TCLIQUE_Bool tcliqueFlush(TCLIQUE_GRAPH *tcliquegraph)
TCLIQUE_Bool tcliqueCreate(TCLIQUE_GRAPH **tcliquegraph)
TCLIQUE_Bool tcliqueAddNode(TCLIQUE_GRAPH *tcliquegraph, int node, TCLIQUE_WEIGHT weight)
TCLIQUE_Bool tcliqueAddEdge(TCLIQUE_GRAPH *tcliquegraph, int node1, int node2)
SCIP_OKAY
SCIP_INVALIDCALL
SCIP_ERROR
enum SCIP_Retcode SCIP_RETCODE