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

- File List
- File Members

AlpsParams.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 AlpsParams_h
24 #define AlpsParams_h
25
26 #include "AlpsKnowledge.h"
27 #include "AlpsParameterBase.h"
28
29 // TODO: remove largeSize, mediumSize, smallSize
30
31 //#############################################################################
32
33 //class AlpsEncoded;
34
35 //** Parameters used in Alps. */
36 class AlpsParams : public AlpsParameterSet {
37 public:
40 enum boolParams
41 {
44 checkMemory,
47 deleteDeadNode,
50 interClusterBalance,
53 intraClusterBalance,
57 printSolution,
58 /***/
59 endOfBoolParams
60 };
61
63 enum intParams
64 {
67 bufSpare,
71 clockType,
74 eliteSize,
77 hubInitNodeNum,
82 hubMsgLevel,
85 hubNum,
88 largeSize,
92 logFileLevel,
95 masterInitNodeNum,
98 masterReportInterval,
102 hubWorkClusterSizeLimit,
105 mediumSize,
110 msgLevel,
113 nodeLimit,
116 nodeLogInterval,
119 printSystemStatus,
123 processNum,
128 staticBalanceScheme,
137 searchStrategy,
138 searchStrategyRampUp,
141 smallSize,
144 solLimit,
147 unitWorkNodes,
152 workerMsgLevel,
154 endOfIntParams
155 };
156
158 enum dblParams
159 {
163 changeWorkThreshold,
168 donorThreshold,
171 hubReportPeriod,
174 masterBalancePeriod,
177 needWorkThreshold,
181 receiverThreshold,
184 timeLimit,
187 tolerance,
190 unitWorkTime,
193 zeroLoad,
194 /***/
195 endOfDblParams
196 };
197
199 enum strParams
200 {
203 instance,
206 logFile,
208 endOfStrParams
209 };
210
212 enum strArrayParams
213 {
214 // The dummy is needed so the allocation won't try for 0 entries.
215 strArrayDummy,
217 endOfStrArrayParams
218 };
219
220 public:
221
227 AlpsParams() :
228 AlpsParameterSet(
229 static_cast<int>(endOfBoolParams),
230 static_cast<int>(endOfIntParams),
231 static_cast<int>(endOfDblParams),
232 static_cast<int>(endOfStrParams),
233 static_cast<int>(endOfStrArrayParams)
234 )
235 {
236 createKeywordList();
237 setDefaultEntries();
238 }
241 virtual ~AlpsParams(){ }
242
243
244 AlpsParams& operator=(const AlpsParams& x) {
245 // no need to delete anything, since the size of (almost) everything is
246 // the same, just copy over
247 // -- The static_cast is needed to satisfy the more picky IBM Visual Age
248 // C++ compiler
249 std::copy(x.bpar_, x.bpar_ + static_cast<int>(endOfBoolParams),
250 bpar_);
251 std::copy(x.ipar_, x.ipar_ + static_cast<int>(endOfIntParams),
252 ipar_);
253 std::copy(x.dpar_, x.dpar_ + static_cast<int>(endOfDblParams),
254 dpar_);
255 std::copy(x.spar_, x.spar_ + static_cast<int>(endOfStrParams),
256 spar_);
257 std::copy(x.sapar_,
258 x.sapar_ + static_cast<int>(endOfStrArrayParams),
259 sapar_);
260 return *this;
261 }
262
265 virtual void createKeywordList();
267 virtual void setDefaultEntries();
268
269 public:
270 //====================================================
282 //====================================================
283
284
292 inline bool entry(const boolParams key) const { return bpar_[key]; }
295 inline int entry(const intParams key) const { return ipar_[key]; }
297 inline double entry(const dblParams key) const { return dpar_[key]; }
299 inline const std::string&
300 entry(const strParams key) const { return spar_[key]; }
302 inline const std::vector<std::string>&
303 entry(const strArrayParams key) const { return sapar_[key]; }
306 //----------------------------------------------------
307
309 void setEntry(const boolParams key, const char * val) {
310 bpar_[key] = atoi(val) ? true : false; }
312 void setEntry(const boolParams key, const char val) {
313 bpar_[key] = val ? true : false; }
315 void setEntry(const boolParams key, const bool val) {
316 bpar_[key] = val; }
318 void setEntry(const intParams key, const char * val) {
319 ipar_[key] = atoi(val); }
321 void setEntry(const intParams key, const int val) {
322 ipar_[key] = val; }
324 void setEntry(const dblParams key, const char * val) {
325 dpar_[key] = atof(val); }
327 void setEntry(const dblParams key, const double val) {
328 dpar_[key] = val; }
330 void setEntry(const strParams key, const char * val) {
331 spar_[key] = val; }
333 void setEntry(const strArrayParams key, const char *val) {
334 sapar_[key].push_back(val); }
335
336 //----------------------------------------------------
337
341 void pack(AlpsEncoded& buf) {
342 buf.writeRep(bpar_, endOfBoolParams)
343 .writeRep(ipar_, endOfIntParams)
344 .writeRep(dpar_, endOfDblParams);
345 for (int i = 0; i < endOfStrParams; ++i)
346 buf.writeRep(spar_[i]);
347 for (int i = 0; i < endOfStrArrayParams; ++i) {
348 buf.writeRep(sapar_[i].size());
349 for (size_t j = 0; j < sapar_[i].size(); ++j)
350 buf.writeRep(sapar_[i][j]);
351 }
352 }
353
355 void unpack(AlpsEncoded& buf) {
356 int dummy;
357 // No need to allocate the arrays, they are of fixed length
358 dummy = static_cast<int>(endOfBoolParams);
359 buf.readRep(bpar_, dummy, false);
360 dummy = static_cast<int>(endOfIntParams);
361 buf.readRep(ipar_, dummy, false);
362 dummy = static_cast<int>(endOfDblParams);
363 buf.readRep(dpar_, dummy, false);
364 for (int i = 0; i < endOfStrParams; ++i)
365 buf.readRep(spar_[i]);
366 for (int i = 0; i < endOfStrArrayParams; ++i) {
367 size_t str_size;
368 buf.readRep(str_size);
369 sapar_[i].reserve(str_size);
370 for (size_t j = 0; j < str_size; ++j){
371 // sapar_[i].unchecked_push_back(std::string());
372 sapar_[i].push_back(std::string());
373 buf.readRep(sapar_[i].back());
374 }
375 }
376 }
378 };
379
380 #endif
381
AlpsParams::entry
int entry(const intParams key) const
Definition: AlpsParams.h:295
AlpsParams::printSystemStatus
Print system status: 0: do not print, 1: print.
Definition: AlpsParams.h:119
AlpsParams::endOfBoolParams
Definition: AlpsParams.h:59
AlpsParams::processNum
The total number of processes that are launched for parallel code.
Definition: AlpsParams.h:123
AlpsParams::unitWorkTime
The time length of a unit work.
Definition: AlpsParams.h:190
AlpsParams::zeroLoad
If less than this number, it is considered zero workload.
Definition: AlpsParams.h:193
AlpsParams::pack
void pack(AlpsEncoded &buf)
Pack the parameter set into buf.
Definition: AlpsParams.h:341
AlpsParams::changeWorkThreshold
The threshold of workload below which a worker will change the subtree that is working on...
Definition: AlpsParams.h:163
AlpsEncoded::readRep
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:173
AlpsParams::clockType
Type of clock when timing rampup, rampdown, etc.
Definition: AlpsParams.h:71
AlpsEncoded::writeRep
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:163
AlpsParams::unpack
void unpack(AlpsEncoded &buf)
Unpack the parameter set from buf.
Definition: AlpsParams.h:355
AlpsParams::tolerance
The numeric tolerance.
Definition: AlpsParams.h:187
AlpsParams::setEntry
void setEntry(const strArrayParams key, const char *val)
Definition: AlpsParams.h:333
AlpsParameterBase.h
AlpsParameterSet
This is the class serves as a holder for a set of parameters.
Definition: AlpsParameterBase.h:134
AlpsParams::intParams
intParams
Integer paramters.
Definition: AlpsParams.h:63
AlpsParams::AlpsParams
AlpsParams()
The default constructor creates a parameter set with from the template argument structure.
Definition: AlpsParams.h:227
AlpsParams::setEntry
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition: AlpsParams.h:312
AlpsParams::needWorkThreshold
The threshold of workload below which a process will ask for workload Default: 2. ...
Definition: AlpsParams.h:177
AlpsParams::setEntry
void setEntry(const dblParams key, const char *val)
Definition: AlpsParams.h:324
AlpsParams::staticBalanceScheme
Static load balancing scheme – root initialization (0) – spiral (1)
Definition: AlpsParams.h:128
AlpsParams::eliteSize
Number of the &quot;elite&quot; nodes that are used in determining workload.
Definition: AlpsParams.h:74
AlpsParams::endOfDblParams
Definition: AlpsParams.h:195
AlpsParameterSet::ipar_
int * ipar_
The integer parameters.
Definition: AlpsParameterBase.h:150
AlpsParams::setEntry
void setEntry(const intParams key, const char *val)
Definition: AlpsParams.h:318
AlpsParams::operator=
AlpsParams & operator=(const AlpsParams &x)
Definition: AlpsParams.h:244
AlpsParams::entry
const std::vector< std::string > & entry(const strArrayParams key) const
Definition: AlpsParams.h:303
AlpsParams::entry
const std::string & entry(const strParams key) const
Definition: AlpsParams.h:300
AlpsParams::instance
The instance to be solved.
Definition: AlpsParams.h:203
AlpsParams::donorThreshold
It is between 1.0 - infty.
Definition: AlpsParams.h:168
AlpsParams::hubInitNodeNum
The number of nodes initially generated by each hub.
Definition: AlpsParams.h:77
AlpsParams::setEntry
void setEntry(const strParams key, const char *val)
Definition: AlpsParams.h:330
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
AlpsParams::setEntry
void setEntry(const dblParams key, const double val)
Definition: AlpsParams.h:327
AlpsParams::nodeLimit
The max number of nodes can be processed.
Definition: AlpsParams.h:113
AlpsParams::masterReportInterval
The interval between master report system status.
Definition: AlpsParams.h:98
AlpsParams::logFile
The name of log file.
Definition: AlpsParams.h:206
AlpsParams::intraClusterBalance
Hub balances the workload of workers: receiver initialized.
Definition: AlpsParams.h:53
AlpsParams::bufSpare
The size of extra memory allocated to a message buffer.
Definition: AlpsParams.h:67
AlpsParams::strArrayDummy
Definition: AlpsParams.h:215
AlpsParameterSet::spar_
std::string * spar_
The string (actually, std::string) parameters.
Definition: AlpsParameterBase.h:156
AlpsParams::deleteDeadNode
Remove dead nodes or not.
Definition: AlpsParams.h:47
AlpsParams::setEntry
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition: AlpsParams.h:315
AlpsParams::hubMsgLevel
Message level of the hub specific messages.
Definition: AlpsParams.h:82
AlpsParams::timeLimit
The time limit (in seconds) of search.
Definition: AlpsParams.h:184
AlpsParams::searchStrategyRampUp
Definition: AlpsParams.h:138
AlpsParams::hubWorkClusterSizeLimit
If the number of processes in a cluster is less than it, the hub also work as a worker.
Definition: AlpsParams.h:102
AlpsParams::endOfIntParams
Definition: AlpsParams.h:154
AlpsParams::solLimit
The max num of solution can be stored in a solution pool.
Definition: AlpsParams.h:144
AlpsParams::searchStrategy
Search strategy – best-first (0) – best-first-estimate (1) – breadth-first (2) – depth-first (3) – hy...
Definition: AlpsParams.h:137
AlpsParams::receiverThreshold
It is between 0.0 - 1.0.
Definition: AlpsParams.h:181
AlpsParams::setDefaultEntries
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
AlpsParams::endOfStrArrayParams
Definition: AlpsParams.h:217
AlpsKnowledge.h
AlpsParameterSet::sapar_
std::vector< std::string > * sapar_
The keyword, parameter pairs.
Definition: AlpsParameterBase.h:160
AlpsParams::endOfStrParams
Definition: AlpsParams.h:208
AlpsParams::setEntry
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition: AlpsParams.h:309
AlpsParameterSet::bpar_
bool * bpar_
The bool parameters.
Definition: AlpsParameterBase.h:147
AlpsParams::strArrayParams
strArrayParams
There are no string array parameters.
Definition: AlpsParams.h:212
AlpsParams::mediumSize
The size of memory allocated for medium size message.
Definition: AlpsParams.h:105
AlpsParams::hubReportPeriod
The time period (sec) for hubs to process messages.
Definition: AlpsParams.h:171
AlpsParams::entry
bool entry(const boolParams key) const
Definition: AlpsParams.h:293
AlpsParams::dblParams
dblParams
Double parameters.
Definition: AlpsParams.h:158
AlpsParams::setEntry
void setEntry(const intParams key, const int val)
Definition: AlpsParams.h:321
AlpsParams::createKeywordList
virtual void createKeywordList()
Method for creating the list of keyword looked for in the parameter file.
AlpsParams::entry
double entry(const dblParams key) const
Definition: AlpsParams.h:297
AlpsParams::~AlpsParams
virtual ~AlpsParams()
Definition: AlpsParams.h:241
AlpsParams::masterBalancePeriod
The time period for master to do loading balance/termination check.
Definition: AlpsParams.h:174
AlpsParams::checkMemory
Check memory.
Definition: AlpsParams.h:44
AlpsParameterSet::dpar_
double * dpar_
The double parameters.
Definition: AlpsParameterBase.h:153
AlpsParams::smallSize
The size of memory allocated for small size message.
Definition: AlpsParams.h:141
AlpsParams::largeSize
The size of memory allocated for large size message.
Definition: AlpsParams.h:88
AlpsParams::nodeLogInterval
Node log interval.
Definition: AlpsParams.h:116
AlpsParams::strParams
strParams
String parameters.
Definition: AlpsParams.h:199
AlpsParams::hubNum
The number of hubs.
Definition: AlpsParams.h:85
AlpsParams::unitWorkNodes
The size/number of nodes of a unit work.
Definition: AlpsParams.h:147
AlpsParams
Definition: AlpsParams.h:36
AlpsParams::boolParams
boolParams
Character parameters.
Definition: AlpsParams.h:40
AlpsParams::workerMsgLevel
Message level of the worker specific messages.
Definition: AlpsParams.h:152
AlpsParams::printSolution
Print solution to screen and log if have a solution and msgLevel and logFileLevel permits...
Definition: AlpsParams.h:57
AlpsParams::masterInitNodeNum
The number of nodes initially generated by the master.
Definition: AlpsParams.h:95
AlpsParams::interClusterBalance
Master balances the workload of hubs: centralized.
Definition: AlpsParams.h:50
AlpsParams::msgLevel
The level of printing messages on screen.
Definition: AlpsParams.h:110
AlpsParams::logFileLevel
The level of log file.
Definition: AlpsParams.h:92