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:
41  {
58  /***/
60  };
61 
63  enum intParams
64  {
155  };
156 
159  {
194  /***/
196  };
197 
200  {
209  };
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 
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) {
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 
int entry(const intParams key) const
Definition: AlpsParams.h:295
Print system status: 0: do not print, 1: print.
Definition: AlpsParams.h:119
The total number of processes that are launched for parallel code.
Definition: AlpsParams.h:123
The time length of a unit work.
Definition: AlpsParams.h:190
If less than this number, it is considered zero workload.
Definition: AlpsParams.h:193
void pack(AlpsEncoded &buf)
Pack the parameter set into buf.
Definition: AlpsParams.h:341
The threshold of workload below which a worker will change the subtree that is working on...
Definition: AlpsParams.h:163
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:173
Type of clock when timing rampup, rampdown, etc.
Definition: AlpsParams.h:71
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:163
void unpack(AlpsEncoded &buf)
Unpack the parameter set from buf.
Definition: AlpsParams.h:355
The numeric tolerance.
Definition: AlpsParams.h:187
void setEntry(const strArrayParams key, const char *val)
Definition: AlpsParams.h:333
This is the class serves as a holder for a set of parameters.
intParams
Integer paramters.
Definition: AlpsParams.h:63
AlpsParams()
The default constructor creates a parameter set with from the template argument structure.
Definition: AlpsParams.h:227
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition: AlpsParams.h:312
The threshold of workload below which a process will ask for workload Default: 2. ...
Definition: AlpsParams.h:177
void setEntry(const dblParams key, const char *val)
Definition: AlpsParams.h:324
Static load balancing scheme – root initialization (0) – spiral (1)
Definition: AlpsParams.h:128
Number of the &quot;elite&quot; nodes that are used in determining workload.
Definition: AlpsParams.h:74
int * ipar_
The integer parameters.
void setEntry(const intParams key, const char *val)
Definition: AlpsParams.h:318
AlpsParams & operator=(const AlpsParams &x)
Definition: AlpsParams.h:244
const std::vector< std::string > & entry(const strArrayParams key) const
Definition: AlpsParams.h:303
const std::string & entry(const strParams key) const
Definition: AlpsParams.h:300
The instance to be solved.
Definition: AlpsParams.h:203
It is between 1.0 - infty.
Definition: AlpsParams.h:168
The number of nodes initially generated by each hub.
Definition: AlpsParams.h:77
void setEntry(const strParams key, const char *val)
Definition: AlpsParams.h:330
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
void setEntry(const dblParams key, const double val)
Definition: AlpsParams.h:327
The max number of nodes can be processed.
Definition: AlpsParams.h:113
The interval between master report system status.
Definition: AlpsParams.h:98
The name of log file.
Definition: AlpsParams.h:206
Hub balances the workload of workers: receiver initialized.
Definition: AlpsParams.h:53
The size of extra memory allocated to a message buffer.
Definition: AlpsParams.h:67
std::string * spar_
The string (actually, std::string) parameters.
Remove dead nodes or not.
Definition: AlpsParams.h:47
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition: AlpsParams.h:315
Message level of the hub specific messages.
Definition: AlpsParams.h:82
The time limit (in seconds) of search.
Definition: AlpsParams.h:184
If the number of processes in a cluster is less than it, the hub also work as a worker.
Definition: AlpsParams.h:102
The max num of solution can be stored in a solution pool.
Definition: AlpsParams.h:144
Search strategy – best-first (0) – best-first-estimate (1) – breadth-first (2) – depth-first (3) – hy...
Definition: AlpsParams.h:137
It is between 0.0 - 1.0.
Definition: AlpsParams.h:181
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
std::vector< std::string > * sapar_
The keyword, parameter pairs.
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition: AlpsParams.h:309
bool * bpar_
The bool parameters.
strArrayParams
There are no string array parameters.
Definition: AlpsParams.h:212
The size of memory allocated for medium size message.
Definition: AlpsParams.h:105
The time period (sec) for hubs to process messages.
Definition: AlpsParams.h:171
bool entry(const boolParams key) const
Definition: AlpsParams.h:293
dblParams
Double parameters.
Definition: AlpsParams.h:158
void setEntry(const intParams key, const int val)
Definition: AlpsParams.h:321
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
virtual ~AlpsParams()
Definition: AlpsParams.h:241
The time period for master to do loading balance/termination check.
Definition: AlpsParams.h:174
Check memory.
Definition: AlpsParams.h:44
double * dpar_
The double parameters.
The size of memory allocated for small size message.
Definition: AlpsParams.h:141
The size of memory allocated for large size message.
Definition: AlpsParams.h:88
Node log interval.
Definition: AlpsParams.h:116
strParams
String parameters.
Definition: AlpsParams.h:199
The number of hubs.
Definition: AlpsParams.h:85
The size/number of nodes of a unit work.
Definition: AlpsParams.h:147
boolParams
Character parameters.
Definition: AlpsParams.h:40
Message level of the worker specific messages.
Definition: AlpsParams.h:152
Print solution to screen and log if have a solution and msgLevel and logFileLevel permits...
Definition: AlpsParams.h:57
The number of nodes initially generated by the master.
Definition: AlpsParams.h:95
Master balances the workload of hubs: centralized.
Definition: AlpsParams.h:50
The level of printing messages on screen.
Definition: AlpsParams.h:110
The level of log file.
Definition: AlpsParams.h:92