Alps  2.0.2
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  * 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-2019, Lehigh University, Yan Xu, Aykut Bulut, and *
22  * Ted Ralphs. *
23  * All Rights Reserved. *
24  *===========================================================================*/
25 
26 
27 #ifndef AbcParams_h
28 #define AbcParams_h
29 
30 #include "AlpsKnowledge.h"
31 #include "AlpsParameterBase.h"
32 
33 
34 //#############################################################################
35 //#############################################################################
36 //** Parameters used in Abc. */
37 class AbcParams : public AlpsParameterSet {
38  public:
41  enum boolParams{
44  //
46  };
47 
49  enum intParams{
53  logLevel,
54  //
56  };
57 
59  enum dblParams{
60  dblDummy,
61  //
63  };
64 
66  enum strParams{
67  strDummy,
68  //
70  };
71 
75  //
77  };
78 
79  public:
87  static_cast<int>(endOfBoolParams),
88  static_cast<int>(endOfIntParams),
89  static_cast<int>(endOfDblParams),
90  static_cast<int>(endOfStrParams),
91  static_cast<int>(endOfStrArrayParams)
92  )
93  {
96  }
101  virtual void createKeywordList();
103  virtual void setDefaultEntries();
107  public:
108  //===========================================================================
116  //===========================================================================
117 
118 
127  inline char
129  entry(const boolParams key) const { return bpar_[key]; }
131  inline int
132  entry(const intParams key) const { return ipar_[key]; }
134  inline double
135  entry(const dblParams key) const { return dpar_[key]; }
137  inline const std::string&
138  entry(const strParams key) const { return spar_[key]; }
140  inline const std::vector<std::string>&
141  entry(const strArrayParams key) const { return sapar_[key]; }
144  //---------------------------------------------------------------------------
146  void setEntry(const boolParams key, const char * val) {
147  bpar_[key] = atoi(val) ? true : false; }
149  void setEntry(const boolParams key, const char val) {
150  bpar_[key] = val ? true : false; }
152  void setEntry(const boolParams key, const bool val) {
153  bpar_[key] = val; }
155  void setEntry(const intParams key, const char * val) {
156  ipar_[key] = atoi(val); }
158  void setEntry(const intParams key, const int val) {
159  ipar_[key] = val; }
161  void setEntry(const dblParams key, const char * val) {
162  dpar_[key] = atof(val); }
164  void setEntry(const dblParams key, const double val) {
165  dpar_[key] = val; }
167  void setEntry(const strParams key, const char * val) {
168  spar_[key] = val; }
170  void setEntry(const strArrayParams key, const char *val) {
171  sapar_[key].push_back(val); }
172 
173  //---------------------------------------------------------------------------
174 
179  void pack(AlpsEncoded& buf) {
183  for (int i = 0; i < endOfStrParams; ++i)
184  buf.writeRep(spar_[i]);
185  for (int i = 0; i < endOfStrArrayParams; ++i) {
186  buf.writeRep(sapar_[i].size());
187  for (size_t j = 0; j < sapar_[i].size(); ++j)
188  buf.writeRep(sapar_[i][j]);
189  }
190  }
192  void unpack(AlpsEncoded& buf) {
193  int dummy;
194  // No need to allocate the arrays, they are of fixed length
195  dummy = static_cast<int>(endOfBoolParams);
196  buf.readRep(bpar_, dummy, false);
197  dummy = static_cast<int>(endOfIntParams);
198  buf.readRep(ipar_, dummy, false);
199  dummy = static_cast<int>(endOfDblParams);
200  buf.readRep(dpar_, dummy, false);
201  for (int i = 0; i < endOfStrParams; ++i)
202  buf.readRep(spar_[i]);
203  for (int i = 0; i < endOfStrArrayParams; ++i) {
204  size_t str_size;
205  buf.readRep(str_size);
206  sapar_[i].reserve(str_size);
207  for (size_t j = 0; j < str_size; ++j){
208  // sapar_[i].unchecked_push_back(std::string());
209  sapar_[i].push_back(std::string());
210  buf.readRep(sapar_[i].back());
211  }
212  }
213  }
216 };
217 
218 #endif
AbcParams::endOfIntParams
@ endOfIntParams
Definition: AbcParams.h:55
AbcParams::dblDummy
@ dblDummy
Definition: AbcParams.h:60
AbcParams::setEntry
void setEntry(const strParams key, const char *val)
Definition: AbcParams.h:167
AlpsParameterSet::dpar_
double * dpar_
The double parameters.
Definition: AlpsParameterBase.h:161
AlpsParameterSet
This is the class serves as a holder for a set of parameters.
Definition: AlpsParameterBase.h:138
AlpsKnowledge.h
AbcParams::entry
const std::string & entry(const strParams key) const
Definition: AbcParams.h:138
AbcParams
Definition: AbcParams.h:37
AbcParams::entry
char entry(const boolParams key) const
Definition: AbcParams.h:129
AbcParams::setEntry
void setEntry(const dblParams key, const char *val)
Definition: AbcParams.h:161
AbcParams::createKeywordList
virtual void createKeywordList()
Method for creating the list of keyword looked for in the parameter file.
AlpsParameterSet::spar_
std::string * spar_
The string (actually, std::string) parameters.
Definition: AlpsParameterBase.h:164
AlpsParameterBase.h
AlpsEncoded
Definition: AlpsEncoded.h:64
AbcParams::setEntry
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition: AbcParams.h:152
AbcParams::setEntry
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition: AbcParams.h:149
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
AbcParams::setEntry
void setEntry(const intParams key, const char *val)
Definition: AbcParams.h:155
AbcParams::AbcParams
AbcParams()
The default constructor creates a parameter set with from the template argument structure.
Definition: AbcParams.h:85
AbcParams::setDefaultEntries
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
AbcParams::logLevel
@ logLevel
Definition: AbcParams.h:53
AbcParams::entry
int entry(const intParams key) const
Definition: AbcParams.h:132
AbcParams::setEntry
void setEntry(const intParams key, const int val)
Definition: AbcParams.h:158
AbcParams::intParams
intParams
Integer paramters.
Definition: AbcParams.h:49
AbcParams::unpack
void unpack(AlpsEncoded &buf)
Unpack the parameter set from the buffer.
Definition: AbcParams.h:192
AbcParams::cutDuringRampup
@ cutDuringRampup
Whether generate cuts during rampup.
Definition: AbcParams.h:43
AbcParams::strArrayDummy
@ strArrayDummy
Definition: AbcParams.h:74
AbcParams::endOfStrArrayParams
@ endOfStrArrayParams
Definition: AbcParams.h:76
AbcParams::setEntry
void setEntry(const strArrayParams key, const char *val)
Definition: AbcParams.h:170
AlpsParameterSet::bpar_
bool * bpar_
The bool parameters.
Definition: AlpsParameterBase.h:155
AbcParams::dblParams
dblParams
Double parameters.
Definition: AbcParams.h:59
AbcParams::setEntry
void setEntry(const dblParams key, const double val)
Definition: AbcParams.h:164
AbcParams::endOfDblParams
@ endOfDblParams
Definition: AbcParams.h:62
AbcParams::strDummy
@ strDummy
Definition: AbcParams.h:67
AbcParams::statusInterval
@ statusInterval
The interval (number of nodes) to report current search status.
Definition: AbcParams.h:51
AbcParams::endOfBoolParams
@ endOfBoolParams
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:179
AbcParams::entry
const std::vector< std::string > & entry(const strArrayParams key) const
Definition: AbcParams.h:141
AbcParams::entry
double entry(const dblParams key) const
Definition: AbcParams.h:135
AbcParams::setEntry
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition: AbcParams.h:146
AbcParams::endOfStrParams
@ endOfStrParams
Definition: AbcParams.h:69
AbcParams::strArrayParams
strArrayParams
There are no string array parameters.
Definition: AbcParams.h:73
AbcParams::boolParams
boolParams
Character parameters.
Definition: AbcParams.h:41
AbcParams::strParams
strParams
String parameters.
Definition: AbcParams.h:66
AlpsParameterSet::sapar_
std::vector< std::string > * sapar_
Definition: AlpsParameterBase.h:168