Scippy

GCG

Branch-and-Price & Column Generation for Everyone

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