Scippy

GCG

Branch-and-Price & Column Generation for Everyone

matrixgraph.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 matrixgraph.h
30 * @brief miscellaneous matrixgraph methods for structure detection
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_MATRIXGRAPH_H_
39#define GCG_MATRIXGRAPH_H_
40#include "objscip/objscip.h"
41#include "tclique/tclique.h"
42#include "graph/weights.h"
43#include "gcg/pub_decomp.h"
44#include "graph/bridge.h"
48#include <exception>
49#include <vector>
50#include <string>
51
52namespace gcg {
53
54template <class T>
56public:
57 std::string name;
58protected:
60 int nconss;
61 int nvars;
66
67public:
68 /** Constructor */
70 GCG* gcgstruct, /**< GCG data structure */
71 Weights w /**< weights for the given graph */
72 );
73
74 /** Destructor */
75 virtual ~MatrixGraph();
76
77 /** writes the graph to the given file.
78 * The format is graph dependent
79 */
81 int fd, /**< file descriptor where the graph should be written to */
82 SCIP_Bool writeweights /**< whether to write weights */
83 )
84 {
85 SCIP_CALL(graphiface->writeToFile(fd, writeweights) );
86 return SCIP_OKAY;
87 }
88
89
91 GCG_DECOMP** decomp /**< decomposition structure to generate */
92 )
93 {
94 return SCIP_ERROR;
95 }
96
97
98
99 /** amplifies a partialdec by dint of a graph created with open constraints and open variables of the partialdec */
101 PARTIALDECOMP* oldpartialdec, /**< partialdec which should be amplifies */
102 PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec amplified by dint of the graph (can be NULL) */
103 PARTIALDECOMP** secondpartialdec, /**< pinter to buffer the new partialdec whose border is amplified by dint of the graph (can be NULL) */
104 DETPROBDATA* detprobdata /**< detection process information and data */
105 )
106 {
107 return SCIP_ERROR;
108 }
109
110 /**
111 * reads the partition from the given file.
112 * The format is graph dependent. The default is a file with one line for each node a
113 */
115 const char* filename /**< filename where the partition is stored */
116 )
117 {
118 SCIP_CALL( graphiface->readPartition(filename) );
119 return SCIP_OKAY;
120 }
121
122 /** set the number of dummy nodes */
123 void setDummynodes(int dummynodes_)
124 {
125 dummynodes = dummynodes_;
126 }
127
128 int getDummynodes() const
129 {
130 return dummynodes;
131 }
132
133 /** return a partition of the nodes */
134 virtual std::vector<int> getPartition()
135 {
136 return graphiface->getPartition();
137 }
138
140 SCIP_CONS** conss, /**< constraints for which graph should be created */
141 SCIP_VAR** vars, /**< variables for which graph should be created */
142 int nconss_, /**< number of constraints */
143 int nvars_ /**< number of variables */
144 ) { return SCIP_ERROR; }
145
146 /** creates a graph with open constraints and open variables of the partialdec */
148 DETPROBDATA* detprobdata,
149 PARTIALDECOMP* partialdec
150 ) { return SCIP_ERROR; }
151
152
153 virtual int getNNonzeroes() const
154 {
155 return nnonzeroes;
156 }
157};
158
159}
160
161#endif
bridge
class storing partialdecs and the problem matrix
class storing (potentially incomplete) decompositions
virtual SCIP_RETCODE readPartition(const char *filename)=0
virtual std::vector< int > getPartition() const
virtual SCIP_RETCODE writeToFile(int fd, SCIP_Bool writeweights)=0
virtual SCIP_RETCODE createFromPartialMatrix(DETPROBDATA *detprobdata, PARTIALDECOMP *partialdec)
Definition: matrixgraph.h:147
virtual std::vector< int > getPartition()
Definition: matrixgraph.h:134
virtual SCIP_RETCODE createFromMatrix(SCIP_CONS **conss, SCIP_VAR **vars, int nconss_, int nvars_)
Definition: matrixgraph.h:139
int getDummynodes() const
Definition: matrixgraph.h:128
virtual SCIP_RETCODE readPartition(const char *filename)
Definition: matrixgraph.h:114
virtual ~MatrixGraph()
virtual SCIP_RETCODE createDecompFromPartition(GCG_DECOMP **decomp)
Definition: matrixgraph.h:90
MatrixGraph(GCG *gcgstruct, Weights w)
virtual int getNNonzeroes() const
Definition: matrixgraph.h:153
virtual SCIP_RETCODE createPartialdecFromPartition(PARTIALDECOMP *oldpartialdec, PARTIALDECOMP **firstpartialdec, PARTIALDECOMP **secondpartialdec, DETPROBDATA *detprobdata)
Definition: matrixgraph.h:100
virtual SCIP_RETCODE writeToFile(int fd, SCIP_Bool writeweights)
Definition: matrixgraph.h:80
std::string name
Definition: matrixgraph.h:57
void setDummynodes(int dummynodes_)
Definition: matrixgraph.h:123
GraphInterface * graphiface
Definition: matrixgraph.h:64
class to manage partial decompositions
#define SCIP_CALL(x)
miscellaneous graph interface methods
public methods for working with decomposition structures
Definition: struct_gcg.h:55
SCIP_OKAY
SCIP_ERROR
enum SCIP_Retcode SCIP_RETCODE
weight class for graphs