Alps 1.5.12
Loading...
Searching...
No Matches
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-2019, 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. */
34 public:
43
53
60
67
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 }
93
94
97 virtual void createKeywordList();
99 virtual void setDefaultEntries();
101
102
103 public:
104 //===========================================================================
112 //===========================================================================
113
114
124 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]; }
139
140 //---------------------------------------------------------------------------
142 void setEntry(const boolParams key, const char * val) {
143 bpar_[key] = atoi(val) ? true : false; }
144
145 void setEntry(const boolParams key, const char val) {
146 bpar_[key] = val ? true : false; }
147
148 void setEntry(const boolParams key, const bool val) {
149 bpar_[key] = val; }
150
151 void setEntry(const intParams key, const char * val) {
152 ipar_[key] = atoi(val); }
153
154 void setEntry(const intParams key, const int val) {
155 ipar_[key] = val; }
156
157 void setEntry(const dblParams key, const char * val) {
158 dpar_[key] = atof(val); }
159
160 void setEntry(const dblParams key, const double val) {
161 dpar_[key] = val; }
162
163 void setEntry(const strParams key, const char * val) {
164 spar_[key] = val; }
165
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 }
187
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 }
210
211
212};
213
214#endif
const std::vector< std::string > & entry(const strArrayParams key) const
Definition AbcParams.h:137
void unpack(AlpsEncoded &buf)
Unpack the parameter set from the buffer.
Definition AbcParams.h:188
void setEntry(const intParams key, const char *val)
Definition AbcParams.h:151
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition AbcParams.h:142
void setEntry(const dblParams key, const char *val)
Definition AbcParams.h:157
virtual void createKeywordList()
Method for creating the list of keyword looked for in the parameter file.
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
strParams
String parameters.
Definition AbcParams.h:62
@ endOfStrParams
Definition AbcParams.h:65
AbcParams()
The default constructor creates a parameter set with from the template argument structure.
Definition AbcParams.h:81
strArrayParams
There are no string array parameters.
Definition AbcParams.h:69
@ strArrayDummy
Definition AbcParams.h:70
@ endOfStrArrayParams
Definition AbcParams.h:72
const std::string & entry(const strParams key) const
Definition AbcParams.h:134
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition AbcParams.h:148
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition AbcParams.h:145
void setEntry(const intParams key, const int val)
Definition AbcParams.h:154
void setEntry(const strArrayParams key, const char *val)
Definition AbcParams.h:166
double entry(const dblParams key) const
Definition AbcParams.h:131
void setEntry(const strParams key, const char *val)
Definition AbcParams.h:163
void setEntry(const dblParams key, const double val)
Definition AbcParams.h:160
dblParams
Double parameters.
Definition AbcParams.h:55
@ endOfDblParams
Definition AbcParams.h:58
boolParams
Character parameters.
Definition AbcParams.h:37
@ cutDuringRampup
Whether generate cuts during rampup.
Definition AbcParams.h:39
@ endOfBoolParams
Definition AbcParams.h:41
char entry(const boolParams key) const
Definition AbcParams.h:125
int entry(const intParams key) const
Definition AbcParams.h:128
intParams
Integer paramters.
Definition AbcParams.h:45
@ statusInterval
The interval (number of nodes) to report current search status.
Definition AbcParams.h:47
@ endOfIntParams
Definition AbcParams.h:51
void pack(AlpsEncoded &buf)
Pack the parameter set into the buffer (AlpsEncoded is used as buffer Here).
Definition AbcParams.h:175
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_ .
std::vector< std::string > * sapar_
int * ipar_
The integer parameters.
AlpsParameterSet(int c, int i, int d, int s, int sa)
The constructor allocate memory for parameters.
bool * bpar_
The bool parameters.
double * dpar_
The double parameters.
std::string * spar_
The string (actually, std::string) parameters.