Scippy

GCG

Branch-and-Price & Column Generation for Everyone

class_varpartition.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_varpartition.h
29  * @brief class representing a partition of a set of variables
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_VARPARTITION_H__
37 #define GCG_CLASS_VARPARTITION_H__
38 
39 #include "class_indexpartition.h"
40 
41 namespace gcg
42 {
43 
45 {
46  ALL = 0,
47  LINKING = 1,
48  MASTER = 2,
49  BLOCK = 3
50 };
52 
53 
55 {
56 
57 public:
58 
59  /** constructor */
61  SCIP* scip, /**< scip data structure */
62  const char* name, /**< name of partition (will be copied) */
63  int nClasses, /**< initial number of classes */
64  int nVars /**< number of variables to be classified */
65  );
66 
67  /** copy constructor */
69  const VarPartition* toCopy /**< VarPartition to be copied */
70  );
71 
72 
73  /** destructor */
74  ~VarPartition();
75 
76 
77  /** creates a new class, returns index of the class */
78  int addClass(
79  const char* name, /**< name of the class (will be copied) */
80  const char* desc, /**< description of the class (will be copied) */
81  VAR_DECOMPINFO decompInfo /**< decomposition code of the class */
82  );
83 
84  /** assigns a variable to a class */
85  void assignVarToClass(
86  int varindex, /**< index of the variable */
87  int classindex /**< index of the class */
88  );
89 
90  /** returns a vector containing all possible subsets of the chosen classindices */
91  std::vector<std::vector<int>> getAllSubsets(
92  bool all, /**< true, if ALL classes should be considered */
93  bool linking, /**< true, if LINKING classes should be considered */
94  bool master, /**< true, if MASTER classes should be considered */
95  bool block /**< true, if BLOCK classes should be considered */
96  );
97 
98  /** returns the decomposition info of a class */
100  int classindex /**< index of class */
101  );
102 
103  /** returns the name of the class a variable is assigned to */
104  const char* getClassNameOfVar(
105  int varindex /**< index of variable */
106  );
107 
108 
109  /** returns the index of the class a variable is assigned to */
110  int getClassOfVar(
111  int varindex /**< index of variable */
112  );
113 
114  /** returns vector containing the assigned class of each variable */
115  const int* getVarsToClasses(
116  );
117 
118  /** returns the number of variables */
119  int getNVars(
120  );
121 
122  /** returns a vector with the numbers of variables that are assigned to the classes */
123  std::vector<int> getNVarsOfClasses(
124  );
125 
126  /** returns whether a variable is already assigned to a class */
127  bool isVarClassified(
128  int varindex /**< index of variable */
129  );
130 
131 
132  /** returns partition with reduced number of classes
133  * if the current number of classes is greater than an upper bound
134  * and lower than 2*(upper bound) (returns NULL otherwise) */
136  int maxNumberOfClasses /**< upper bound */
137  );
138 
139  /** sets the decomposition code of a class */
140  void setClassDecompInfo(
141  int classindex, /**< index of class */
142  VAR_DECOMPINFO decompInfo /**< decomposition code of class */
143  );
144 
145 };
146 
147 
148 } /* namespace gcg */
149 #endif /* GCG_CLASS_VARPARTITION_H__ */
int addClass(const char *name, const char *desc, VAR_DECOMPINFO decompInfo)
int getClassOfVar(int varindex)
bool isVarClassified(int varindex)
generalization of ConsPartition and VarPartition
VarPartition(SCIP *scip, const char *name, int nClasses, int nVars)
enum VarClassDecompInfo VAR_DECOMPINFO
VarPartition * reduceClasses(int maxNumberOfClasses)
void assignVarToClass(int varindex, int classindex)
const char * getClassNameOfVar(int varindex)
const int * getVarsToClasses()
void setClassDecompInfo(int classindex, VAR_DECOMPINFO decompInfo)
std::vector< std::vector< int > > getAllSubsets(bool all, bool linking, bool master, bool block)
std::vector< int > getNVarsOfClasses()
VAR_DECOMPINFO getClassDecompInfo(int classindex)