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 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 class_varpartition.h
30 * @brief class representing a partition of a set of variables
31 * @author Julius Hense
32 *
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
37#ifndef GCG_CLASS_VARPARTITION_H__
38#define GCG_CLASS_VARPARTITION_H__
39
40
42
43namespace gcg
44{
45
46/** @ingroup PARTITIONS
47 * @{
48 */
49
51{
52 ALL = 0,
54 MASTER = 2,
55 BLOCK = 3
56};
58
59
61{
62
63public:
64
65 /** constructor */
68 GCG* gcgstruct, /**< GCG data structure */
69 const char* name, /**< name of partition (will be copied) */
70 int nClasses, /**< initial number of classes */
71 int nVars /**< number of variables to be classified */
72 );
73
74 /** copy constructor */
77 const VarPartition* toCopy /**< VarPartition to be copied */
78 );
79
80
81 /** destructor */
84
85
86 /** creates a new class, returns index of the class */
88 int addClass(
89 const char* name, /**< name of the class (will be copied) */
90 const char* desc, /**< description of the class (will be copied) */
91 VAR_DECOMPINFO decompInfo /**< decomposition code of the class */
92 );
93
94 /** assigns a variable to a class */
97 int varindex, /**< index of the variable */
98 int classindex /**< index of the class */
99 );
100
101 /** returns a vector containing all possible subsets of the chosen classindices */
103 std::vector<std::vector<int>> getAllSubsets(
104 bool all, /**< true, if ALL classes should be considered */
105 bool linking, /**< true, if LINKING classes should be considered */
106 bool master, /**< true, if MASTER classes should be considered */
107 bool block /**< true, if BLOCK classes should be considered */
108 );
109
110 /** returns the decomposition info of a class */
113 int classindex /**< index of class */
114 );
115
116 /** returns the name of the class a variable is assigned to */
118 const char* getClassNameOfVar(
119 int varindex /**< index of variable */
120 );
121
122
123 /** returns the index of the class a variable is assigned to */
125 int getClassOfVar(
126 int varindex /**< index of variable */
127 );
128
129 /** returns vector containing the assigned class of each variable */
131 const int* getVarsToClasses(
132 );
133
134 /** returns the number of variables */
136 int getNVars(
137 );
138
139 /** returns a vector with the numbers of variables that are assigned to the classes */
141 std::vector<int> getNVarsOfClasses(
142 );
143
144 /** returns whether a variable is already assigned to a class */
146 bool isVarClassified(
147 int varindex /**< index of variable */
148 );
149
150
151 /** returns partition with reduced number of classes
152 * if the current number of classes is greater than an upper bound
153 * and lower than 2*(upper bound) (returns NULL otherwise) */
156 int maxNumberOfClasses /**< upper bound */
157 );
158
159 /** sets the decomposition code of a class */
162 int classindex, /**< index of class */
163 VAR_DECOMPINFO decompInfo /**< decomposition code of class */
164 );
165
166};
167
168/**@} */
169} /* namespace gcg */
170#endif /* GCG_CLASS_VARPARTITION_H__ */
generalization of ConsPartition and VarPartition
GCG_EXPORT void setClassDecompInfo(int classindex, VAR_DECOMPINFO decompInfo)
GCG_EXPORT int getClassOfVar(int varindex)
GCG_EXPORT VarPartition * reduceClasses(int maxNumberOfClasses)
GCG_EXPORT bool isVarClassified(int varindex)
GCG_EXPORT void assignVarToClass(int varindex, int classindex)
GCG_EXPORT ~VarPartition()
GCG_EXPORT const char * getClassNameOfVar(int varindex)
GCG_EXPORT std::vector< int > getNVarsOfClasses()
GCG_EXPORT VAR_DECOMPINFO getClassDecompInfo(int classindex)
GCG_EXPORT VarPartition(GCG *gcgstruct, const char *name, int nClasses, int nVars)
GCG_EXPORT int getNVars()
GCG_EXPORT std::vector< std::vector< int > > getAllSubsets(bool all, bool linking, bool master, bool block)
GCG_EXPORT int addClass(const char *name, const char *desc, VAR_DECOMPINFO decompInfo)
GCG_EXPORT const int * getVarsToClasses()
#define GCG_EXPORT
Definition: def.h:59
enum VarClassDecompInfo VAR_DECOMPINFO
Definition: struct_gcg.h:55