Alps 1.5.7
Loading...
Searching...
No Matches
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-2019, 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. */
37 public:
61
156
197
210
213 {
214 // The dummy is needed so the allocation won't try for 0 entries.
218 };
219
220 public:
221
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 {
238 }
241 virtual ~AlpsParams(){ }
242
243
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
269public:
270 //====================================================
282 //====================================================
283
284
293 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) {
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
This data structure is to contain the packed form of an encodable knowledge.
Definition AlpsEncoded.h:25
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
This is the class serves as a holder for a set of parameters.
std::vector< std::string > * sapar_
int * ipar_
The integer parameters.
bool * bpar_
The bool parameters.
double * dpar_
The double parameters.
std::string * spar_
The string (actually, std::string) parameters.
virtual void createKeywordList()
Method for creating the list of keyword looked for in the parameter file.
double entry(const dblParams key) const
Definition AlpsParams.h:297
void unpack(AlpsEncoded &buf)
Unpack the parameter set from buf.
Definition AlpsParams.h:355
intParams
Integer paramters.
Definition AlpsParams.h:64
@ searchStrategyRampUp
Definition AlpsParams.h:138
@ nodeLimit
The max number of nodes can be processed.
Definition AlpsParams.h:113
@ unitWorkNodes
The size/number of nodes of a unit work.
Definition AlpsParams.h:147
@ clockType
Type of clock when timing rampup, rampdown, etc.
Definition AlpsParams.h:71
@ bufSpare
The size of extra memory allocated to a message buffer.
Definition AlpsParams.h:67
@ hubInitNodeNum
The number of nodes initially generated by each hub.
Definition AlpsParams.h:77
@ masterReportInterval
The interval between master report system status.
Definition AlpsParams.h:98
@ mediumSize
The size of memory allocated for medium size message.
Definition AlpsParams.h:105
@ solLimit
The max num of solution can be stored in a solution pool.
Definition AlpsParams.h:144
@ largeSize
The size of memory allocated for large size message.
Definition AlpsParams.h:88
@ searchStrategy
Search strategy – best-first (0) – best-first-estimate (1) – breadth-first (2) – depth-first (3) – hy...
Definition AlpsParams.h:137
@ msgLevel
The level of printing messages on screen.
Definition AlpsParams.h:110
@ eliteSize
Number of the "elite" nodes that are used in determining workload.
Definition AlpsParams.h:74
@ processNum
The total number of processes that are launched for parallel code.
Definition AlpsParams.h:123
@ hubMsgLevel
Message level of the hub specific messages.
Definition AlpsParams.h:82
@ logFileLevel
The level of log file.
Definition AlpsParams.h:92
@ smallSize
The size of memory allocated for small size message.
Definition AlpsParams.h:141
@ hubWorkClusterSizeLimit
If the number of processes in a cluster is less than it, the hub also work as a worker.
Definition AlpsParams.h:102
@ workerMsgLevel
Message level of the worker specific messages.
Definition AlpsParams.h:152
@ printSystemStatus
Print system status: 0: do not print, 1: print.
Definition AlpsParams.h:119
@ masterInitNodeNum
The number of nodes initially generated by the master.
Definition AlpsParams.h:95
@ nodeLogInterval
Node log interval.
Definition AlpsParams.h:116
@ hubNum
The number of hubs.
Definition AlpsParams.h:85
@ staticBalanceScheme
Static load balancing scheme – root initialization (0) – spiral (1)
Definition AlpsParams.h:128
const std::string & entry(const strParams key) const
Definition AlpsParams.h:300
boolParams
Character parameters.
Definition AlpsParams.h:41
@ interClusterBalance
Master balances the workload of hubs: centralized.
Definition AlpsParams.h:50
@ printSolution
Print solution to screen and log if have a solution and msgLevel and logFileLevel permits.
Definition AlpsParams.h:57
@ checkMemory
Check memory.
Definition AlpsParams.h:44
@ endOfBoolParams
Definition AlpsParams.h:59
@ deleteDeadNode
Remove dead nodes or not.
Definition AlpsParams.h:47
@ intraClusterBalance
Hub balances the workload of workers: receiver initialized.
Definition AlpsParams.h:53
void setEntry(const intParams key, const int val)
Definition AlpsParams.h:321
const std::vector< std::string > & entry(const strArrayParams key) const
Definition AlpsParams.h:303
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
int entry(const intParams key) const
Definition AlpsParams.h:295
strArrayParams
There are no string array parameters.
Definition AlpsParams.h:213
@ endOfStrArrayParams
Definition AlpsParams.h:217
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition AlpsParams.h:315
void pack(AlpsEncoded &buf)
Pack the parameter set into buf.
Definition AlpsParams.h:341
void setEntry(const dblParams key, const char *val)
Definition AlpsParams.h:324
virtual ~AlpsParams()
Definition AlpsParams.h:241
strParams
String parameters.
Definition AlpsParams.h:200
@ instance
The instance to be solved.
Definition AlpsParams.h:203
@ logFile
The name of log file.
Definition AlpsParams.h:206
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition AlpsParams.h:312
dblParams
Double parameters.
Definition AlpsParams.h:159
@ donorThreshold
It is between 1.0 - infty.
Definition AlpsParams.h:168
@ unitWorkTime
The time length of a unit work.
Definition AlpsParams.h:190
@ masterBalancePeriod
The time period for master to do loading balance/termination check.
Definition AlpsParams.h:174
@ receiverThreshold
It is between 0.0 - 1.0.
Definition AlpsParams.h:181
@ changeWorkThreshold
The threshold of workload below which a worker will change the subtree that is working on.
Definition AlpsParams.h:163
@ timeLimit
The time limit (in seconds) of search.
Definition AlpsParams.h:184
@ tolerance
The numeric tolerance.
Definition AlpsParams.h:187
@ zeroLoad
If less than this number, it is considered zero workload.
Definition AlpsParams.h:193
@ hubReportPeriod
The time period (sec) for hubs to process messages.
Definition AlpsParams.h:171
@ needWorkThreshold
The threshold of workload below which a process will ask for workload Default: 2.
Definition AlpsParams.h:177
bool entry(const boolParams key) const
Definition AlpsParams.h:293
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition AlpsParams.h:309
AlpsParams & operator=(const AlpsParams &x)
Definition AlpsParams.h:244
void setEntry(const strParams key, const char *val)
Definition AlpsParams.h:330
void setEntry(const dblParams key, const double val)
Definition AlpsParams.h:327
void setEntry(const intParams key, const char *val)
Definition AlpsParams.h:318
void setEntry(const strArrayParams key, const char *val)
Definition AlpsParams.h:333
AlpsParams()
The default constructor creates a parameter set with from the template argument structure.
Definition AlpsParams.h:227