GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
class_indexpartition.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_indexpartition.h
30 * @brief generalization of ConsPartition and VarPartition
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_INDEXPARTITION_H__
38#define GCG_CLASS_INDEXPARTITION_H__
39
40#include "gcg/gcg.h"
41#include <vector>
42#include <string>
43
44
45namespace gcg
46{
47
48/** @ingroup PARTITIONS
49 * @{
50 */
51
53{
54
55protected:
56 GCG* gcg; /**< GCG data structure */
57
58private:
59 std::string name; /**< name of the partition */
60 int nClasses; /**< number of classes the partition provides */
61 int nIndices; /**< number of indices */
62 std::vector<int> indicesToClasses; /**< index i is assigned to class indicesToClasses[i] (-1 if not assigned)*/
63 std::vector<std::string> classNames; /**< name of class k is classNames[k] */
64 std::vector<std::string> classDescriptions; /**< information text describing class k is classDescriptions[k] */
65 std::vector<int> classDecompInfo; /**< decomposition information of class k is classDecompInfo[k] */
66
67
68protected:
69
70 /** constructor */
72 GCG* gcgstruct, /**< GCG data structure */
73 const char* name, /**< name of partition (will be copied) */
74 int nClasses, /**< initial number of classes */
75 int nIndices /**< number of indices to be classified */
76 );
77
78 /** copy constructor */
80 const IndexPartition* toCopy /**< IndexPartition to be copied */
81 );
82
83
84 /** destructor */
85 virtual ~IndexPartition();
86
87 /** 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 );
92
93 /** assigns an index to a class */
95 int index, /**< index to be assigned */
96 int classindex /**< index of the class */
97 );
98
99 /** returns a vector containing all possible subsets of the given classindices */
100 std::vector<std::vector<int>> getAllSubsets(
101 std::vector<int>& classindices /**< classindices to be considered */
102 );
103
104 /** returns the decomposition info of the a class */
106 int classindex /**< index of the class */
107 );
108
109 /** returns the name of the class an index is assigned to */
110 const char* getClassNameOfIndex(
111 int index
112 );
113
114 /** returns the index of the class an index is assigned to */
115 int getClassOfIndex(
116 int index
117 );
118
119 /** returns vector containing the assigned class of each index */
120 std::vector<int>& getIndicesToClasses(
121 );
122
123 /** returns the number of indices */
124 int getNIndices(
125 );
126
127 /** returns a vector with the numbers of indices that are assigned to the classes */
128 std::vector<int> getNIndicesOfClasses(
129 );
130
131 /** returns whether an index is already assigned to a class */
133 int index
134 );
135
136 /** sets the decomposition info of the a class */
138 int classindex, /**< index of the class */
139 int decompInfo /**< decomposition info */
140 );
141
142
143public:
144
145 /** returns true if the other partition has an equivalent index structure,
146 * meaning that the partition of the set of constraints is the same ignoring the concrete classindices, classnames, etc. */
148 bool isDuplicateOf(
149 IndexPartition* otherPartition /**< other partition to be checked */
150 );
151
152 /** returns the information text of a class */
154 const char* getClassDescription(
155 int classindex /**< index of class */
156 );
157
158 /** returns the name of a class */
160 const char* getClassName(
161 int classindex /**< index of class */
162 );
163
164 /** returns the name of the partition */
166 const char* getName(
167 );
168
169
170 /** returns the number of classes the partition provides */
172 int getNClasses(
173 );
174
175 /** returns a class index mapping for creating a new partition
176 * the enlarged class is always the class with index 0
177 * returns empty vector if the current number of classes is lower than an upper bound
178 * or greater than 2*(upper bound) */
180 std::vector<int> reduceClasses(
181 int maxNumberOfClasses /**< upper bound */
182 );
183
184 /** removes all classes which do not have any assigned index (classindices may change)
185 * returns number of removed classes */
188 );
189
190 /** sets the information text of a class */
193 int classindex, /**< index of class */
194 const char* desc /**< description of class (will be copied) */
195 );
196
197 /** sets the name of a class */
199 void setClassName(
200 int classindex, /**< index of class */
201 const char* name /**< name of class (will be copied) */
202 );
203
204};
205
206/** @} */
207} /* namespace gcg */
208#endif /* SRC_CLASS_INDEXPARTITION_H_ */
GCG_EXPORT std::vector< int > reduceClasses(int maxNumberOfClasses)
GCG_EXPORT const char * getClassName(int classindex)
std::vector< int > getNIndicesOfClasses()
GCG_EXPORT const char * getName()
std::vector< int > & getIndicesToClasses()
IndexPartition(GCG *gcgstruct, const char *name, int nClasses, int nIndices)
GCG_EXPORT void setClassDescription(int classindex, const char *desc)
void assignIndexToClass(int index, int classindex)
int getClassDecompInfo(int classindex)
GCG_EXPORT bool isDuplicateOf(IndexPartition *otherPartition)
bool isIndexClassified(int index)
GCG_EXPORT const char * getClassDescription(int classindex)
GCG_EXPORT int removeEmptyClasses()
int addClass(const char *name, const char *desc)
const char * getClassNameOfIndex(int index)
GCG_EXPORT void setClassName(int classindex, const char *name)
std::vector< std::vector< int > > getAllSubsets(std::vector< int > &classindices)
void setClassDecompInfo(int classindex, int decompInfo)
#define GCG_EXPORT
Definition def.h:59
GCG interface methods.
struct Gcg GCG
Definition type_gcg.h:44