- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

AbcParams.h
Go to the documentation of this file.
1 /*===========================================================================*
2 * This file is part of the Abstract Library for Parallel Search (ALPS). *
3 * *
4 * ALPS is distributed under the Eclipse Public License as part of the *
5 * COIN-OR repository (http://www.coin-or.org). *
6 * *
7 * Authors: *
8 * *
9 * Yan Xu, Lehigh University *
10 * Ted Ralphs, Lehigh University *
11 * *
12 * Conceptual Design: *
13 * *
14 * Yan Xu, Lehigh University *
15 * Ted Ralphs, Lehigh University *
16 * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17 * Matthew Saltzman, Clemson University *
18 * *
19 * *
20 * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21 *===========================================================================*/
22
23 #ifndef AbcParams_h
24 #define AbcParams_h
25
26 #include "AlpsKnowledge.h"
27 #include "AlpsParameterBase.h"
28
29
30 //#############################################################################
31 //#############################################################################
32 //** Parameters used in Abc. */
33 class AbcParams : public AlpsParameterSet {
34 public:
37 enum boolParams{
39 cutDuringRampup,
40 //
41 endOfBoolParams
42 };
43
45 enum intParams{
47 statusInterval,
49 logLevel,
50 //
51 endOfIntParams
52 };
53
55 enum dblParams{
56 dblDummy,
57 //
58 endOfDblParams
59 };
60
62 enum strParams{
63 strDummy,
64 //
65 endOfStrParams
66 };
67
69 enum strArrayParams{
70 strArrayDummy,
71 //
72 endOfStrArrayParams
73 };
74
75 public:
81 AbcParams() :
82 AlpsParameterSet(
83 static_cast<int>(endOfBoolParams),
84 static_cast<int>(endOfIntParams),
85 static_cast<int>(endOfDblParams),
86 static_cast<int>(endOfStrParams),
87 static_cast<int>(endOfStrArrayParams)
88 )
89 {
90 createKeywordList();
91 setDefaultEntries();
92 }
97 virtual void createKeywordList();
99 virtual void setDefaultEntries();
103 public:
104 //===========================================================================
112 //===========================================================================
113
114
123 inline char
125 entry(const boolParams key) const { return bpar_[key]; }
127 inline int
128 entry(const intParams key) const { return ipar_[key]; }
130 inline double
131 entry(const dblParams key) const { return dpar_[key]; }
133 inline const std::string&
134 entry(const strParams key) const { return spar_[key]; }
136 inline const std::vector<std::string>&
137 entry(const strArrayParams key) const { return sapar_[key]; }
140 //---------------------------------------------------------------------------
142 void setEntry(const boolParams key, const char * val) {
143 bpar_[key] = atoi(val) ? true : false; }
145 void setEntry(const boolParams key, const char val) {
146 bpar_[key] = val ? true : false; }
148 void setEntry(const boolParams key, const bool val) {
149 bpar_[key] = val; }
151 void setEntry(const intParams key, const char * val) {
152 ipar_[key] = atoi(val); }
154 void setEntry(const intParams key, const int val) {
155 ipar_[key] = val; }
157 void setEntry(const dblParams key, const char * val) {
158 dpar_[key] = atof(val); }
160 void setEntry(const dblParams key, const double val) {
161 dpar_[key] = val; }
163 void setEntry(const strParams key, const char * val) {
164 spar_[key] = val; }
166 void setEntry(const strArrayParams key, const char *val) {
167 sapar_[key].push_back(val); }
168
169 //---------------------------------------------------------------------------
170
175 void pack(AlpsEncoded& buf) {
176 buf.writeRep(bpar_, endOfBoolParams)
177 .writeRep(ipar_, endOfIntParams)
178 .writeRep(dpar_, endOfDblParams);
179 for (int i = 0; i < endOfStrParams; ++i)
180 buf.writeRep(spar_[i]);
181 for (int i = 0; i < endOfStrArrayParams; ++i) {
182 buf.writeRep(sapar_[i].size());
183 for (size_t j = 0; j < sapar_[i].size(); ++j)
184 buf.writeRep(sapar_[i][j]);
185 }
186 }
188 void unpack(AlpsEncoded& buf) {
189 int dummy;
190 // No need to allocate the arrays, they are of fixed length
191 dummy = static_cast<int>(endOfBoolParams);
192 buf.readRep(bpar_, dummy, false);
193 dummy = static_cast<int>(endOfIntParams);
194 buf.readRep(ipar_, dummy, false);
195 dummy = static_cast<int>(endOfDblParams);
196 buf.readRep(dpar_, dummy, false);
197 for (int i = 0; i < endOfStrParams; ++i)
198 buf.readRep(spar_[i]);
199 for (int i = 0; i < endOfStrArrayParams; ++i) {
200 size_t str_size;
201 buf.readRep(str_size);
202 sapar_[i].reserve(str_size);
203 for (size_t j = 0; j < str_size; ++j){
204 // sapar_[i].unchecked_push_back(std::string());
205 sapar_[i].push_back(std::string());
206 buf.readRep(sapar_[i].back());
207 }
208 }
209 }
212 };
213
214 #endif
AbcParams::setEntry
void setEntry(const dblParams key, const char *val)
Definition: AbcParams.h:157
AlpsEncoded::readRep
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:173
AlpsEncoded::writeRep
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:163
AlpsParameterBase.h
AlpsParameterSet
This is the class serves as a holder for a set of parameters.
Definition: AlpsParameterBase.h:134
AbcParams::setEntry
void setEntry(const strArrayParams key, const char *val)
Definition: AbcParams.h:166
AbcParams::intParams
intParams
Integer paramters.
Definition: AbcParams.h:45
AbcParams::pack
void pack(AlpsEncoded &buf)
Pack the parameter set into the buffer (AlpsEncoded is used as buffer Here).
Definition: AbcParams.h:175
AlpsParameterSet::ipar_
int * ipar_
The integer parameters.
Definition: AlpsParameterBase.h:150
AbcParams::entry
char entry(const boolParams key) const
Definition: AbcParams.h:125
AbcParams::dblDummy
Definition: AbcParams.h:56
AbcParams
Definition: AbcParams.h:33
AbcParams::entry
int entry(const intParams key) const
Definition: AbcParams.h:128
AbcParams::endOfIntParams
Definition: AbcParams.h:51
AbcParams::cutDuringRampup
Whether generate cuts during rampup.
Definition: AbcParams.h:39
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
AbcParams::strParams
strParams
String parameters.
Definition: AbcParams.h:62
AbcParams::entry
const std::vector< std::string > & entry(const strArrayParams key) const
Definition: AbcParams.h:137
AbcParams::logLevel
Definition: AbcParams.h:49
AbcParams::setDefaultEntries
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
AbcParams::createKeywordList
virtual void createKeywordList()
Method for creating the list of keyword looked for in the parameter file.
AbcParams::setEntry
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition: AbcParams.h:142
AlpsParameterSet::spar_
std::string * spar_
The string (actually, std::string) parameters.
Definition: AlpsParameterBase.h:156
AbcParams::entry
const std::string & entry(const strParams key) const
Definition: AbcParams.h:134
AbcParams::strArrayDummy
Definition: AbcParams.h:70
AbcParams::entry
double entry(const dblParams key) const
Definition: AbcParams.h:131
AbcParams::strArrayParams
strArrayParams
There are no string array parameters.
Definition: AbcParams.h:69
AbcParams::AbcParams
AbcParams()
The default constructor creates a parameter set with from the template argument structure.
Definition: AbcParams.h:81
AlpsKnowledge.h
AlpsParameterSet::sapar_
std::vector< std::string > * sapar_
The keyword, parameter pairs.
Definition: AlpsParameterBase.h:160
AbcParams::endOfDblParams
Definition: AbcParams.h:58
AbcParams::setEntry
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition: AbcParams.h:148
AlpsParameterSet::bpar_
bool * bpar_
The bool parameters.
Definition: AlpsParameterBase.h:147
AbcParams::setEntry
void setEntry(const strParams key, const char *val)
Definition: AbcParams.h:163
AbcParams::endOfBoolParams
Definition: AbcParams.h:41
AbcParams::statusInterval
The interval (number of nodes) to report current search status.
Definition: AbcParams.h:47
AbcParams::strDummy
Definition: AbcParams.h:63
AbcParams::endOfStrArrayParams
Definition: AbcParams.h:72
AbcParams::setEntry
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition: AbcParams.h:145
AbcParams::endOfStrParams
Definition: AbcParams.h:65
AbcParams::setEntry
void setEntry(const dblParams key, const double val)
Definition: AbcParams.h:160
AbcParams::setEntry
void setEntry(const intParams key, const int val)
Definition: AbcParams.h:154
AlpsParameterSet::dpar_
double * dpar_
The double parameters.
Definition: AlpsParameterBase.h:153
AbcParams::setEntry
void setEntry(const intParams key, const char *val)
Definition: AbcParams.h:151
AbcParams::unpack
void unpack(AlpsEncoded &buf)
Unpack the parameter set from the buffer.
Definition: AbcParams.h:188
AbcParams::dblParams
dblParams
Double parameters.
Definition: AbcParams.h:55
AbcParams::boolParams
boolParams
Character parameters.
Definition: AbcParams.h:37