Scippy

GCG

Branch-and-Price & Column Generation for Everyone

class_conspartition.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 class_conspartition.h
29  * @brief class representing a partition of a set of constraints
30  * @author Julius Hense
31  *
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 #ifndef GCG_CLASS_CONSPARTITION_H__
37 #define GCG_CLASS_CONSPARTITION_H__
38 
39 #include "class_indexpartition.h"
40 
41 namespace gcg
42 {
43 
45 {
46  BOTH = 0, /**< assign class to master or pricing problem */
47  ONLY_MASTER = 1, /**< assign class only to master problem */
48  ONLY_PRICING = 2 /**< assign class only to pricing problem */
49 };
51 
52 
54 {
55 
56 public:
57 
58  /** constructor */
60  SCIP* scip, /**< scip data structure */
61  const char* name, /**< name of partition (will be copied) */
62  int nClasses, /**< initial number of classes */
63  int nConss /**< number of constraints to be classified */
64  );
65 
66  /** copy constructor */
68  const ConsPartition* toCopy /**< ConsPartition to be copied */
69  );
70 
71 
72  /** destructor */
74 
75 
76  /** creates a new class, returns index of the class */
77  int addClass(
78  const char* name, /**< name of the class (will be copied) */
79  const char* desc, /**< description of the class (will be copied) */
80  CONS_DECOMPINFO decompInfo /**< decomposition code of the class */
81  );
82 
83  /** assigns a constraint to a class */
84  void assignConsToClass(
85  int consindex, /**< index of the constraint */
86  int classindex /**< index of the class */
87  );
88 
89  /** returns a vector containing all possible subsets of the chosen classindices */
90  std::vector<std::vector<int>> getAllSubsets(
91  bool both, /**< true, if BOTH classes should be considered */
92  bool only_master, /**< true, if ONLY_MASTER classes should be considered */
93  bool only_pricing /**< true, if ONLY_PRICING classes should be considered */
94  );
95 
96  /** returns the decomposition info of a class */
98  int classindex /**< index of class */
99  );
100 
101  /** returns the name of the class a constraint is assigned to */
102  const char* getClassNameOfCons(
103  int consindex /**< index of constraint */
104  );
105 
106 
107  /** returns the index of the class a constraint is assigned to */
108  int getClassOfCons(
109  int consindex /**< index of constraint */
110  );
111 
112  /** returns vector containing the assigned class of each constraint */
113  const int* getConssToClasses(
114  );
115 
116  /** returns the number of constraints */
117  int getNConss(
118  );
119 
120  /** returns a vector with the numbers of constraints that are assigned to the classes */
121  std::vector<int> getNConssOfClasses(
122  );
123 
124  /** returns whether a constraint is already assigned to a class */
125  bool isConsClassified(
126  int consindex /**< index of constraint */
127  );
128 
129 
130  /** returns partition with reduced number of classes
131  * if the current number of classes is greater than an upper bound
132  * and lower than 2*(upper bound) (returns NULL otherwise) */
134  int maxNumberOfClasses /**< upper bound */
135  );
136 
137  /** sets the decomposition code of a class */
138  void setClassDecompInfo(
139  int classindex, /**< index of class */
140  CONS_DECOMPINFO decompInfo /**< decomposition code of class */
141  );
142 
143 };
144 
145 
146 } /* namespace gcg */
147 #endif /* GCG_CLASS_CONSPARTITION_H__ */
bool isConsClassified(int consindex)
enum ConsClassDecompInfo CONS_DECOMPINFO
void assignConsToClass(int consindex, int classindex)
void setClassDecompInfo(int classindex, CONS_DECOMPINFO decompInfo)
const int * getConssToClasses()
generalization of ConsPartition and VarPartition
std::vector< int > getNConssOfClasses()
CONS_DECOMPINFO getClassDecompInfo(int classindex)
int addClass(const char *name, const char *desc, CONS_DECOMPINFO decompInfo)
int getClassOfCons(int consindex)
const char * getClassNameOfCons(int consindex)
ConsPartition * reduceClasses(int maxNumberOfClasses)
ConsPartition(SCIP *scip, const char *name, int nClasses, int nConss)
std::vector< std::vector< int > > getAllSubsets(bool both, bool only_master, bool only_pricing)