Scippy

GCG

Branch-and-Price & Column Generation for Everyone

hypercolgraph.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 hypercolgraph.h
29  * @brief Column hypergraph
30  * @author Martin Bergner
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #ifndef GCG_HYPERCOLGRAPH_H_
36 #define GCG_HYPERCOLGRAPH_H_
37 
38 #include "matrixgraph.h"
39 #include "hypergraph.h"
40 #include "class_partialdecomp.h"
41 #include "class_detprobdata.h"
42 
43 namespace gcg
44 {
45 template <class T>
47 {
48 
49 private:
50  Hypergraph<T> graph;
51 protected:
52  class function {
53  int diff;
54  public:
55  function(int i):diff(i) {}
56  int operator()(int i) { return i-diff;}
57  };
58 
59 public:
61  SCIP* scip, /**< SCIP data structure */
62  Weights w /**< weights for the given graph */
63  );
64 
65  virtual ~HypercolGraph();
66 
67  /** writes the graph to the given file.
68  * The format is graph dependent
69  */
70  SCIP_RETCODE writeToFile(
71  int fd, /**< filename where the graph should be written to */
72  SCIP_Bool edgeweights /**< whether to write edgeweights */
73  );
74 
75  /** return the number of nodes */
76  virtual int getNNodes();
77 
78  /** return the number of edges (or hyperedges) */
79  virtual int getNEdges();
80 
81  virtual std::vector<int> getNeighbors(
82  int i
83  )
84  {
85  return this->graph.getNeighbors(i);
86  }
87 
88  virtual std::vector<int> getHyperedgeNodes(
89  int i
90  );
91 
92  /**
93  * reads the partition from the given file.
94  * The format is graph dependent. The default is a file with one line for each node a
95  */
96  virtual SCIP_RETCODE readPartition(
97  const char* filename /**< filename where the partition is stored */
98  )
99  {
100  SCIP_CALL( this->graph.readPartition(filename) );
101  return SCIP_OKAY;
102  }
103 
104  virtual SCIP_RETCODE createFromMatrix(
105  SCIP_CONS** conss, /**< constraints for which graph should be created */
106  SCIP_VAR** vars, /**< variables for which graph should be created */
107  int nconss_, /**< number of constraints */
108  int nvars_ /**< number of variables */
109  );
110 
111  /** creates a graph with open constraints and open variables of the partialdec */
112  virtual SCIP_RETCODE createFromPartialMatrix(
113  DETPROBDATA* detprobdata, /**< detection process information and data */
114  PARTIALDECOMP* partialdec /**< partial decomposition to use for graph */
115  );
116 
117  virtual SCIP_RETCODE createDecompFromPartition(
118  DEC_DECOMP** decomp /**< decomposition structure to generate */
119  );
120 
121  /** creates a new partialdec by dint of a graph created with all constraints and variables */
122  virtual SCIP_RETCODE createPartialdecFromPartition(
123  PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec created by dint of the graph */
124  PARTIALDECOMP** secondpartialdec, /**< pointer to buffer the new partialdec whose border is amplified by dint of the graph */
125  DETPROBDATA* detprobdata /**< detection process information and data */
126  );
127 
128  /** amplifies a partialdec by dint of a graph created with open constraints and open variables of the partialdec */
129  virtual SCIP_RETCODE createPartialdecFromPartition(
130  PARTIALDECOMP* oldpartialdec, /**< partialdec which should be amplifies */
131  PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec amplified by dint of the graph */
132  PARTIALDECOMP** secondpartialdec, /**< pinter to buffer the new partialdec whose border is amplified by dint of the graph */
133  DETPROBDATA* detprobdata /**< detection process information and data */
134  );
135 };
136 
137 } /* namespace gcg */
138 #endif /* GCG_HYPERCOLGRAPH_H_ */
miscellaneous matrixgraph methods for structure detection
virtual std::vector< int > getHyperedgeNodes(int i)
std::vector< int > getNeighbors(int i)
virtual SCIP_RETCODE createFromMatrix(SCIP_CONS **conss, SCIP_VAR **vars, int nconss_, int nvars_)
virtual SCIP_RETCODE createPartialdecFromPartition(PARTIALDECOMP **firstpartialdec, PARTIALDECOMP **secondpartialdec, DETPROBDATA *detprobdata)
HypercolGraph(SCIP *scip, Weights w)
SCIP_RETCODE writeToFile(int fd, SCIP_Bool edgeweights)
virtual std::vector< int > getNeighbors(int i)
Definition: hypercolgraph.h:81
virtual SCIP_RETCODE readPartition(const char *filename)
Definition: hypercolgraph.h:96
SCIP_RETCODE readPartition(const char *filename)
miscellaneous hypergraph methods for structure detection
class to manage partial decompositions
class storing (potentially incomplete) decompositions
virtual SCIP_RETCODE createFromPartialMatrix(DETPROBDATA *detprobdata, PARTIALDECOMP *partialdec)
virtual int getNEdges()
class storing partialdecs and the problem matrix
virtual SCIP_RETCODE createDecompFromPartition(DEC_DECOMP **decomp)
virtual int getNNodes()