Scippy

GCG

Branch-and-Price & Column Generation for Everyone

hyperrowcolgraph.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 hyperrowcolgraph.h
29  * @brief A hypergraph with row and column nodes
30  * @author Martin Bergner
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #ifndef GCG_HYPERROWCOLGRAPH_H_
36 #define GCG_HYPERROWCOLGRAPH_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 template <class T>
45 class HyperrowcolGraph: public MatrixGraph<T>
46 {
47 private:
48  Graph<T> graph;
49 public:
51  SCIP* scip, /**< SCIP data structure */
52  Weights w /**< weights for the given graph */
53  );
54  virtual ~HyperrowcolGraph();
55 
56  SCIP_RETCODE createFromMatrix(
57  SCIP_CONS** conss, /**< constraints for which graph should be created */
58  SCIP_VAR** vars, /**< variables for which graph should be created */
59  int nconss, /**< number of constraints */
60  int nvars /**< number of variables */
61  );
62 
63  /** creates a graph with open constraints and open variables of the partialdec */
64  virtual SCIP_RETCODE createFromPartialMatrix(
65  DETPROBDATA* detprobdata, /**< detection process information and data */
66  PARTIALDECOMP* partialdec /**< partial decomposition to use for matrix */
67  );
68 
69  /** writes the graph to the given file.
70  * The format is graph dependent
71  */
72  virtual SCIP_RETCODE writeToFile(
73  int fd, /**< file descriptor where the graph should be written to */
74  SCIP_Bool writeweights /**< whether to write weights */
75  );
76 
77 
78  virtual SCIP_RETCODE createDecompFromPartition(
79  DEC_DECOMP** decomp /**< decomposition structure to generate */
80  );
81 
82  /** creates a new partialdec by dint of a graph created with all constraints and variables */
83  virtual SCIP_RETCODE createPartialdecFromPartition(
84  PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec created by dint of the graph */
85  PARTIALDECOMP** secondpartialdec, /**< pointer to buffer the new partialdec whose border is amplified by dint of the graph */
86  DETPROBDATA* detprobdata /**< detection process information and data */
87  );
88 
89  /** amplifies a partialdec by dint of a graph created with open constraints and open variables of the partialdec */
90  virtual SCIP_RETCODE createPartialdecFromPartition(
91  PARTIALDECOMP* oldpartialdec, /**< partialdec which should be amplifies */
92  PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec amplified by dint of the graph */
93  PARTIALDECOMP** secondpartialdec, /**< pinter to buffer the new partialdec whose border is amplified by dint of the graph */
94  DETPROBDATA* detprobdata /**< detection process information and data */
95  );
96 
97  /**
98  * reads the partition from the given file.
99  * The format is graph dependent. The default is a file with one line for each node a
100  */
101  virtual SCIP_RETCODE readPartition(
102  const char* filename /**< filename where the partition is stored */
103  );
104 
105  virtual std::vector<int> getNeighbors(
106  int i
107  );
108 
109  virtual std::vector<int> getHyperedgeNodes(
110  int i
111  );
112 
113  std::vector<int> getConsNonzeroNodes(
114  int i
115  );
116 
117  std::vector<int> getVarNonzeroNodes(
118  int i
119  );
120 
121 };
122 
123 } /* namespace gcg */
124 #endif /* GCG_HYPERROWCOLGRAPH_H_ */
miscellaneous matrixgraph methods for structure detection
virtual SCIP_RETCODE readPartition(const char *filename)
std::vector< int > getConsNonzeroNodes(int i)
virtual SCIP_RETCODE writeToFile(int fd, SCIP_Bool writeweights)
virtual SCIP_RETCODE createDecompFromPartition(DEC_DECOMP **decomp)
virtual std::vector< int > getHyperedgeNodes(int i)
virtual SCIP_RETCODE createPartialdecFromPartition(PARTIALDECOMP **firstpartialdec, PARTIALDECOMP **secondpartialdec, DETPROBDATA *detprobdata)
miscellaneous hypergraph methods for structure detection
virtual SCIP_RETCODE createFromPartialMatrix(DETPROBDATA *detprobdata, PARTIALDECOMP *partialdec)
class to manage partial decompositions
std::vector< int > getVarNonzeroNodes(int i)
HyperrowcolGraph(SCIP *scip, Weights w)
class storing (potentially incomplete) decompositions
virtual std::vector< int > getNeighbors(int i)
SCIP_RETCODE createFromMatrix(SCIP_CONS **conss, SCIP_VAR **vars, int nconss, int nvars)
class storing partialdecs and the problem matrix