Alps  2.0.2
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  * Aykut Bulut, Lehigh University *
11  * Ted Ralphs, Lehigh University *
12  * *
13  * Conceptual Design: *
14  * *
15  * Yan Xu, Lehigh University *
16  * Ted Ralphs, Lehigh University *
17  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
18  * Matthew Saltzman, Clemson University *
19  * *
20  * *
21  * Copyright (C) 2001-2023, Lehigh University, Yan Xu, Aykut Bulut, and *
22  * Ted Ralphs. *
23  * All Rights Reserved. *
24  *===========================================================================*/
25 
26 
27 #ifndef AlpsParams_h_
28 #define AlpsParams_h_
29 
30 #include "AlpsKnowledge.h"
31 #include "AlpsParameterBase.h"
32 
33 // TODO: remove largeSize, mediumSize, smallSize
34 
35 //#############################################################################
36 
37 //class AlpsEncoded;
38 
39 //** Parameters used in Alps. */
40 class AlpsParams : public AlpsParameterSet {
41  public:
45  {
65  /***/
67  };
68 
70  enum intParams
71  {
162  };
163 
166  {
201  /***/
203  };
204 
207  {
216  };
217 
220  {
221  // The dummy is needed so the allocation won't try for 0 entries.
225  };
226 
227  public:
228 
236  static_cast<int>(endOfBoolParams),
237  static_cast<int>(endOfIntParams),
238  static_cast<int>(endOfDblParams),
239  static_cast<int>(endOfStrParams),
240  static_cast<int>(endOfStrArrayParams)
241  )
242  {
245  }
248  virtual ~AlpsParams(){ }
249 
250 
252  // no need to delete anything, since the size of (almost) everything is
253  // the same, just copy over
254  // -- The static_cast is needed to satisfy the more picky IBM Visual Age
255  // C++ compiler
256  std::copy(x.bpar_, x.bpar_ + static_cast<int>(endOfBoolParams),
257  bpar_);
258  std::copy(x.ipar_, x.ipar_ + static_cast<int>(endOfIntParams),
259  ipar_);
260  std::copy(x.dpar_, x.dpar_ + static_cast<int>(endOfDblParams),
261  dpar_);
262  std::copy(x.spar_, x.spar_ + static_cast<int>(endOfStrParams),
263  spar_);
264  std::copy(x.sapar_,
265  x.sapar_ + static_cast<int>(endOfStrArrayParams),
266  sapar_);
267  return *this;
268  }
269 
272  virtual void createKeywordList();
274  virtual void setDefaultEntries();
275 
276 public:
277  //====================================================
289  //====================================================
290 
291 
299  inline bool entry(const boolParams key) const { return bpar_[key]; }
302  inline int entry(const intParams key) const { return ipar_[key]; }
304  inline double entry(const dblParams key) const { return dpar_[key]; }
306  inline const std::string&
307  entry(const strParams key) const { return spar_[key]; }
309  inline const std::vector<std::string>&
310  entry(const strArrayParams key) const { return sapar_[key]; }
313  //----------------------------------------------------
314 
316  void setEntry(const boolParams key, const char * val) {
317  bpar_[key] = atoi(val) ? true : false; }
319  void setEntry(const boolParams key, const char val) {
320  bpar_[key] = val ? true : false; }
322  void setEntry(const boolParams key, const bool val) {
323  bpar_[key] = val; }
325  void setEntry(const intParams key, const char * val) {
326  ipar_[key] = atoi(val); }
328  void setEntry(const intParams key, const int val) {
329  ipar_[key] = val; }
331  void setEntry(const dblParams key, const char * val) {
332  dpar_[key] = atof(val); }
334  void setEntry(const dblParams key, const double val) {
335  dpar_[key] = val; }
337  void setEntry(const strParams key, const char * val) {
338  spar_[key] = val; }
340  void setEntry(const strArrayParams key, const char *val) {
341  sapar_[key].push_back(val); }
342 
343  //----------------------------------------------------
344 
348  void pack(AlpsEncoded& buf) {
352  for (int i = 0; i < endOfStrParams; ++i)
353  buf.writeRep(spar_[i]);
354  for (int i = 0; i < endOfStrArrayParams; ++i) {
355  buf.writeRep(sapar_[i].size());
356  for (size_t j = 0; j < sapar_[i].size(); ++j)
357  buf.writeRep(sapar_[i][j]);
358  }
359  }
360 
362  void unpack(AlpsEncoded& buf) {
363  int dummy;
364  // No need to allocate the arrays, they are of fixed length
365  dummy = static_cast<int>(endOfBoolParams);
366  buf.readRep(bpar_, dummy, false);
367  dummy = static_cast<int>(endOfIntParams);
368  buf.readRep(ipar_, dummy, false);
369  dummy = static_cast<int>(endOfDblParams);
370  buf.readRep(dpar_, dummy, false);
371  for (int i = 0; i < endOfStrParams; ++i)
372  buf.readRep(spar_[i]);
373  for (int i = 0; i < endOfStrArrayParams; ++i) {
374  size_t str_size;
375  buf.readRep(str_size);
376  sapar_[i].reserve(str_size);
377  for (size_t j = 0; j < str_size; ++j){
378  // sapar_[i].unchecked_push_back(std::string());
379  sapar_[i].push_back(std::string());
380  buf.readRep(sapar_[i].back());
381  }
382  }
383  }
385 };
386 
387 #endif
AlpsParams::printSystemStatus
@ printSystemStatus
Print system status: 0: do not print, 1: print.
Definition: AlpsParams.h:126
AlpsParams::hubInitNodeNum
@ hubInitNodeNum
The number of nodes initially generated by each hub.
Definition: AlpsParams.h:84
AlpsParams::receiverThreshold
@ receiverThreshold
It is between 0.0 - 1.0.
Definition: AlpsParams.h:188
AlpsParameterSet::dpar_
double * dpar_
The double parameters.
Definition: AlpsParameterBase.h:161
AlpsParams::entry
const std::vector< std::string > & entry(const strArrayParams key) const
Definition: AlpsParams.h:310
AlpsParameterSet
This is the class serves as a holder for a set of parameters.
Definition: AlpsParameterBase.h:138
AlpsParams::unitWorkTime
@ unitWorkTime
The time length of a unit work.
Definition: AlpsParams.h:197
AlpsKnowledge.h
AlpsParams::hubMsgLevel
@ hubMsgLevel
Message level of the hub specific messages.
Definition: AlpsParams.h:89
AlpsParams::masterBalancePeriod
@ masterBalancePeriod
The time period for master to do loading balance/termination check.
Definition: AlpsParams.h:181
AlpsParams::checkMemory
@ checkMemory
Check memory.
Definition: AlpsParams.h:48
AlpsParams::setDefaultEntries
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
AlpsParams::deletePrunedNodes
@ deletePrunedNodes
Warm start or not.
Definition: AlpsParams.h:64
AlpsParams::processNum
@ processNum
The total number of processes that are launched for parallel code.
Definition: AlpsParams.h:130
AlpsParams::instance
@ instance
The instance to be solved.
Definition: AlpsParams.h:210
AlpsParams
Definition: AlpsParams.h:40
AlpsParams::deleteDeadNode
@ deleteDeadNode
Remove dead nodes or not.
Definition: AlpsParams.h:51
AlpsParams::setEntry
void setEntry(const strParams key, const char *val)
Definition: AlpsParams.h:337
AlpsParams::setEntry
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition: AlpsParams.h:319
AlpsParams::searchStrategy
@ searchStrategy
Search strategy – best-first (0) – best-first-estimate (1) – breadth-first (2) – depth-first (3) – hy...
Definition: AlpsParams.h:144
AlpsParams::intParams
intParams
Integer paramters.
Definition: AlpsParams.h:70
AlpsParams::dblParams
dblParams
Double parameters.
Definition: AlpsParams.h:165
AlpsParams::hubWorkClusterSizeLimit
@ hubWorkClusterSizeLimit
If the number of processes in a cluster is less than it, the hub also work as a worker.
Definition: AlpsParams.h:109
AlpsParameterSet::spar_
std::string * spar_
The string (actually, std::string) parameters.
Definition: AlpsParameterBase.h:164
AlpsParams::nodeLimit
@ nodeLimit
The max number of nodes can be processed.
Definition: AlpsParams.h:120
AlpsParams::tolerance
@ tolerance
The numeric tolerance.
Definition: AlpsParams.h:194
AlpsParameterBase.h
AlpsParams::printSolution
@ printSolution
Print solution to screen and log if have a solution and msgLevel and logFileLevel permits.
Definition: AlpsParams.h:61
AlpsEncoded
Definition: AlpsEncoded.h:64
AlpsParams::largeSize
@ largeSize
The size of memory allocated for large size message.
Definition: AlpsParams.h:95
AlpsParams::setEntry
void setEntry(const intParams key, const int val)
Definition: AlpsParams.h:328
AlpsParams::unitWorkNodes
@ unitWorkNodes
The size/number of nodes of a unit work.
Definition: AlpsParams.h:154
AlpsParams::bufSpare
@ bufSpare
The size of extra memory allocated to a message buffer.
Definition: AlpsParams.h:74
AlpsParams::strArrayParams
strArrayParams
There are no string array parameters.
Definition: AlpsParams.h:219
AlpsParams::msgLevel
@ msgLevel
The level of printing messages on screen.
Definition: AlpsParams.h:117
AlpsParams::solLimit
@ solLimit
The max num of solution can be stored in a solution pool.
Definition: AlpsParams.h:151
AlpsParams::clockType
@ clockType
Type of clock when timing rampup, rampdown, etc.
Definition: AlpsParams.h:78
AlpsParams::~AlpsParams
virtual ~AlpsParams()
Definition: AlpsParams.h:248
AlpsEncoded::writeRep
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:201
AlpsParameterSet::ipar_
int * ipar_
The integer parameters.
Definition: AlpsParameterBase.h:158
AlpsEncoded::readRep
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:211
AlpsParams::endOfBoolParams
@ endOfBoolParams
Definition: AlpsParams.h:66
AlpsParams::setEntry
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition: AlpsParams.h:316
AlpsParams::strArrayDummy
@ strArrayDummy
Definition: AlpsParams.h:222
AlpsParams::endOfDblParams
@ endOfDblParams
Definition: AlpsParams.h:202
AlpsParams::masterReportInterval
@ masterReportInterval
The interval between master report system status.
Definition: AlpsParams.h:105
AlpsParams::unpack
void unpack(AlpsEncoded &buf)
Unpack the parameter set from buf.
Definition: AlpsParams.h:362
AlpsParams::eliteSize
@ eliteSize
Number of the "elite" nodes that are used in determining workload.
Definition: AlpsParams.h:81
AlpsParams::setEntry
void setEntry(const dblParams key, const char *val)
Definition: AlpsParams.h:331
AlpsParams::interClusterBalance
@ interClusterBalance
Master balances the workload of hubs: centralized.
Definition: AlpsParams.h:54
AlpsParams::setEntry
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition: AlpsParams.h:322
AlpsParams::logFile
@ logFile
The name of log file.
Definition: AlpsParams.h:213
AlpsParams::donorThreshold
@ donorThreshold
It is between 1.0 - infty.
Definition: AlpsParams.h:175
AlpsParams::entry
const std::string & entry(const strParams key) const
Definition: AlpsParams.h:307
AlpsParams::smallSize
@ smallSize
The size of memory allocated for small size message.
Definition: AlpsParams.h:148
AlpsParams::endOfStrArrayParams
@ endOfStrArrayParams
Definition: AlpsParams.h:224
AlpsParams::intraClusterBalance
@ intraClusterBalance
Hub balances the workload of workers: receiver initialized.
Definition: AlpsParams.h:57
AlpsParams::setEntry
void setEntry(const intParams key, const char *val)
Definition: AlpsParams.h:325
AlpsParams::entry
bool entry(const boolParams key) const
Definition: AlpsParams.h:300
AlpsParams::setEntry
void setEntry(const dblParams key, const double val)
Definition: AlpsParams.h:334
AlpsParams::timeLimit
@ timeLimit
The time limit (in seconds) of search.
Definition: AlpsParams.h:191
AlpsParameterSet::bpar_
bool * bpar_
The bool parameters.
Definition: AlpsParameterBase.h:155
AlpsParams::hubNum
@ hubNum
The number of hubs.
Definition: AlpsParams.h:92
AlpsParams::hubReportPeriod
@ hubReportPeriod
The time period (sec) for hubs to process messages.
Definition: AlpsParams.h:178
AlpsParams::changeWorkThreshold
@ changeWorkThreshold
The threshold of workload below which a worker will change the subtree that is working on.
Definition: AlpsParams.h:170
AlpsParams::staticBalanceScheme
@ staticBalanceScheme
Static load balancing scheme – root initialization (0) – spiral (1)
Definition: AlpsParams.h:135
AlpsParams::boolParams
boolParams
Character parameters.
Definition: AlpsParams.h:44
AlpsParams::entry
int entry(const intParams key) const
Definition: AlpsParams.h:302
AlpsParams::AlpsParams
AlpsParams()
The default constructor creates a parameter set with from the template argument structure.
Definition: AlpsParams.h:234
AlpsParams::workerMsgLevel
@ workerMsgLevel
Message level of the worker specific messages.
Definition: AlpsParams.h:159
AlpsParams::endOfStrParams
@ endOfStrParams
Definition: AlpsParams.h:215
AlpsParams::needWorkThreshold
@ needWorkThreshold
The threshold of workload below which a process will ask for workload Default: 2.
Definition: AlpsParams.h:184
AlpsParams::mediumSize
@ mediumSize
The size of memory allocated for medium size message.
Definition: AlpsParams.h:112
AlpsParams::masterInitNodeNum
@ masterInitNodeNum
The number of nodes initially generated by the master.
Definition: AlpsParams.h:102
AlpsParams::logFileLevel
@ logFileLevel
The level of log file.
Definition: AlpsParams.h:99
AlpsParams::pack
void pack(AlpsEncoded &buf)
Pack the parameter set into buf.
Definition: AlpsParams.h:348
AlpsParams::nodeLogInterval
@ nodeLogInterval
Node log interval.
Definition: AlpsParams.h:123
AlpsParams::searchStrategyRampUp
@ searchStrategyRampUp
Definition: AlpsParams.h:145
AlpsParams::endOfIntParams
@ endOfIntParams
Definition: AlpsParams.h:161
AlpsParams::strParams
strParams
String parameters.
Definition: AlpsParams.h:206
AlpsParams::createKeywordList
virtual void createKeywordList()
Method for creating the list of keyword looked for in the parameter file.
AlpsParams::setEntry
void setEntry(const strArrayParams key, const char *val)
Definition: AlpsParams.h:340
AlpsParams::entry
double entry(const dblParams key) const
Definition: AlpsParams.h:304
AlpsParameterSet::sapar_
std::vector< std::string > * sapar_
Definition: AlpsParameterBase.h:168
AlpsParams::operator=
AlpsParams & operator=(const AlpsParams &x)
Definition: AlpsParams.h:251
AlpsParams::zeroLoad
@ zeroLoad
If less than this number, it is considered zero workload.
Definition: AlpsParams.h:200