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  * 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 AbcParams_h
24 #define AbcParams_h
25 
26 #include "AlpsKnowledge.h"
27 #include "AlpsParameterBase.h"
28 
29 
30 //#############################################################################
31 //#############################################################################
32 //** Parameters used in Abc. */
33 class AbcParams : public AlpsParameterSet {
34  public:
37  enum boolParams{
40  //
42  };
43 
45  enum intParams{
50  //
52  };
53 
55  enum dblParams{
57  //
59  };
60 
62  enum strParams{
64  //
66  };
67 
71  //
73  };
74 
75  public:
83  static_cast<int>(endOfBoolParams),
84  static_cast<int>(endOfIntParams),
85  static_cast<int>(endOfDblParams),
86  static_cast<int>(endOfStrParams),
87  static_cast<int>(endOfStrArrayParams)
88  )
89  {
92  }
97  virtual void createKeywordList();
99  virtual void setDefaultEntries();
103  public:
104  //===========================================================================
112  //===========================================================================
113 
114 
123  inline char
125  entry(const boolParams key) const { return bpar_[key]; }
127  inline int
128  entry(const intParams key) const { return ipar_[key]; }
130  inline double
131  entry(const dblParams key) const { return dpar_[key]; }
133  inline const std::string&
134  entry(const strParams key) const { return spar_[key]; }
136  inline const std::vector<std::string>&
137  entry(const strArrayParams key) const { return sapar_[key]; }
140  //---------------------------------------------------------------------------
142  void setEntry(const boolParams key, const char * val) {
143  bpar_[key] = atoi(val) ? true : false; }
145  void setEntry(const boolParams key, const char val) {
146  bpar_[key] = val ? true : false; }
148  void setEntry(const boolParams key, const bool val) {
149  bpar_[key] = val; }
151  void setEntry(const intParams key, const char * val) {
152  ipar_[key] = atoi(val); }
154  void setEntry(const intParams key, const int val) {
155  ipar_[key] = val; }
157  void setEntry(const dblParams key, const char * val) {
158  dpar_[key] = atof(val); }
160  void setEntry(const dblParams key, const double val) {
161  dpar_[key] = val; }
163  void setEntry(const strParams key, const char * val) {
164  spar_[key] = val; }
166  void setEntry(const strArrayParams key, const char *val) {
167  sapar_[key].push_back(val); }
168 
169  //---------------------------------------------------------------------------
170 
175  void pack(AlpsEncoded& buf) {
179  for (int i = 0; i < endOfStrParams; ++i)
180  buf.writeRep(spar_[i]);
181  for (int i = 0; i < endOfStrArrayParams; ++i) {
182  buf.writeRep(sapar_[i].size());
183  for (size_t j = 0; j < sapar_[i].size(); ++j)
184  buf.writeRep(sapar_[i][j]);
185  }
186  }
188  void unpack(AlpsEncoded& buf) {
189  int dummy;
190  // No need to allocate the arrays, they are of fixed length
191  dummy = static_cast<int>(endOfBoolParams);
192  buf.readRep(bpar_, dummy, false);
193  dummy = static_cast<int>(endOfIntParams);
194  buf.readRep(ipar_, dummy, false);
195  dummy = static_cast<int>(endOfDblParams);
196  buf.readRep(dpar_, dummy, false);
197  for (int i = 0; i < endOfStrParams; ++i)
198  buf.readRep(spar_[i]);
199  for (int i = 0; i < endOfStrArrayParams; ++i) {
200  size_t str_size;
201  buf.readRep(str_size);
202  sapar_[i].reserve(str_size);
203  for (size_t j = 0; j < str_size; ++j){
204  // sapar_[i].unchecked_push_back(std::string());
205  sapar_[i].push_back(std::string());
206  buf.readRep(sapar_[i].back());
207  }
208  }
209  }
212 };
213 
214 #endif
void setEntry(const dblParams key, const char *val)
Definition: AbcParams.h:157
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:173
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:163
This is the class serves as a holder for a set of parameters.
void setEntry(const strArrayParams key, const char *val)
Definition: AbcParams.h:166
intParams
Integer paramters.
Definition: AbcParams.h:45
void pack(AlpsEncoded &buf)
Pack the parameter set into the buffer (AlpsEncoded is used as buffer Here).
Definition: AbcParams.h:175
int * ipar_
The integer parameters.
char entry(const boolParams key) const
Definition: AbcParams.h:125
int entry(const intParams key) const
Definition: AbcParams.h:128
Whether generate cuts during rampup.
Definition: AbcParams.h:39
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
strParams
String parameters.
Definition: AbcParams.h:62
const std::vector< std::string > & entry(const strArrayParams key) const
Definition: AbcParams.h:137
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
virtual void createKeywordList()
Method for creating the list of keyword looked for in the parameter file.
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition: AbcParams.h:142
std::string * spar_
The string (actually, std::string) parameters.
const std::string & entry(const strParams key) const
Definition: AbcParams.h:134
double entry(const dblParams key) const
Definition: AbcParams.h:131
strArrayParams
There are no string array parameters.
Definition: AbcParams.h:69
AbcParams()
The default constructor creates a parameter set with from the template argument structure.
Definition: AbcParams.h:81
std::vector< std::string > * sapar_
The keyword, parameter pairs.
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition: AbcParams.h:148
bool * bpar_
The bool parameters.
void setEntry(const strParams key, const char *val)
Definition: AbcParams.h:163
The interval (number of nodes) to report current search status.
Definition: AbcParams.h:47
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition: AbcParams.h:145
void setEntry(const dblParams key, const double val)
Definition: AbcParams.h:160
void setEntry(const intParams key, const int val)
Definition: AbcParams.h:154
double * dpar_
The double parameters.
void setEntry(const intParams key, const char *val)
Definition: AbcParams.h:151
void unpack(AlpsEncoded &buf)
Unpack the parameter set from the buffer.
Definition: AbcParams.h:188
dblParams
Double parameters.
Definition: AbcParams.h:55
boolParams
Character parameters.
Definition: AbcParams.h:37