Alps 1.5.12
Loading...
Searching...
No Matches
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-2023, 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. */
37 public:
64
159
200
213
216 {
217 // The dummy is needed so the allocation won't try for 0 entries.
221 };
222
223 public:
224
232 static_cast<int>(endOfBoolParams),
233 static_cast<int>(endOfIntParams),
234 static_cast<int>(endOfDblParams),
235 static_cast<int>(endOfStrParams),
236 static_cast<int>(endOfStrArrayParams)
237 )
238 {
241 }
242
243
244 virtual ~AlpsParams(){ /**/ }
245
246
248 // no need to delete anything, since the size of (almost) everything is
249 // the same, just copy over
250 // -- The static_cast is needed to satisfy the more picky IBM Visual Age
251 // C++ compiler
252 std::copy(x.bpar_, x.bpar_ + static_cast<int>(endOfBoolParams),
253 bpar_);
254 std::copy(x.ipar_, x.ipar_ + static_cast<int>(endOfIntParams),
255 ipar_);
256 std::copy(x.dpar_, x.dpar_ + static_cast<int>(endOfDblParams),
257 dpar_);
258 std::copy(x.spar_, x.spar_ + static_cast<int>(endOfStrParams),
259 spar_);
260 std::copy(x.sapar_,
261 x.sapar_ + static_cast<int>(endOfStrArrayParams),
262 sapar_);
263 return *this;
264 }
265
268 virtual void createKeywordList();
270 virtual void setDefaultEntries();
271
272public:
273 //====================================================
285 //====================================================
286
287
296 inline bool entry(const boolParams key) const { return bpar_[key]; }
298 inline int entry(const intParams key) const { return ipar_[key]; }
300 inline double entry(const dblParams key) const { return dpar_[key]; }
302 inline const std::string&
303 entry(const strParams key) const { return spar_[key]; }
305 inline const std::vector<std::string>&
306 entry(const strArrayParams key) const { return sapar_[key]; }
308
309 //----------------------------------------------------
310
312 void setEntry(const boolParams key, const char * val) {
313 bpar_[key] = atoi(val) ? true : false; }
314
315 void setEntry(const boolParams key, const char val) {
316 bpar_[key] = val ? true : false; }
317
318 void setEntry(const boolParams key, const bool val) {
319 bpar_[key] = val; }
320
321 void setEntry(const intParams key, const char * val) {
322 ipar_[key] = atoi(val); }
323
324 void setEntry(const intParams key, const int val) {
325 ipar_[key] = val; }
326
327 void setEntry(const dblParams key, const char * val) {
328 dpar_[key] = atof(val); }
329
330 void setEntry(const dblParams key, const double val) {
331 dpar_[key] = val; }
332
333 void setEntry(const strParams key, const char * val) {
334 spar_[key] = val; }
335
336 void setEntry(const strArrayParams key, const char *val) {
337 sapar_[key].push_back(val); }
338
339 //----------------------------------------------------
340
344 void pack(AlpsEncoded& buf) {
348 for (int i = 0; i < endOfStrParams; ++i)
349 buf.writeRep(spar_[i]);
350 for (int i = 0; i < endOfStrArrayParams; ++i) {
351 buf.writeRep(sapar_[i].size());
352 for (size_t j = 0; j < sapar_[i].size(); ++j)
353 buf.writeRep(sapar_[i][j]);
354 }
355 }
356
358 void unpack(AlpsEncoded& buf) {
359 int dummy;
360 // No need to allocate the arrays, they are of fixed length
361 dummy = static_cast<int>(endOfBoolParams);
362 buf.readRep(bpar_, dummy, false);
363 dummy = static_cast<int>(endOfIntParams);
364 buf.readRep(ipar_, dummy, false);
365 dummy = static_cast<int>(endOfDblParams);
366 buf.readRep(dpar_, dummy, false);
367 for (int i = 0; i < endOfStrParams; ++i)
368 buf.readRep(spar_[i]);
369 for (int i = 0; i < endOfStrArrayParams; ++i) {
370 size_t str_size;
371 buf.readRep(str_size);
372 sapar_[i].reserve(str_size);
373 for (size_t j = 0; j < str_size; ++j){
374 // sapar_[i].unchecked_push_back(std::string());
375 sapar_[i].push_back(std::string());
376 buf.readRep(sapar_[i].back());
377 }
378 }
379 }
380
381};
382
383#endif
384
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.
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:300
void unpack(AlpsEncoded &buf)
Unpack the parameter set from buf.
Definition AlpsParams.h:358
intParams
Integer paramters.
Definition AlpsParams.h:67
@ searchStrategyRampUp
Definition AlpsParams.h:141
@ nodeLimit
The max number of nodes can be processed.
Definition AlpsParams.h:116
@ unitWorkNodes
The size/number of nodes of a unit work.
Definition AlpsParams.h:150
@ clockType
Type of clock when timing rampup, rampdown, etc.
Definition AlpsParams.h:74
@ bufSpare
The size of extra memory allocated to a message buffer.
Definition AlpsParams.h:70
@ hubInitNodeNum
The number of nodes initially generated by each hub.
Definition AlpsParams.h:80
@ masterReportInterval
The interval between master report system status.
Definition AlpsParams.h:101
@ mediumSize
The size of memory allocated for medium size message.
Definition AlpsParams.h:108
@ solLimit
The max num of solution can be stored in a solution pool.
Definition AlpsParams.h:147
@ largeSize
The size of memory allocated for large size message.
Definition AlpsParams.h:91
@ searchStrategy
Search strategy – best-first (0) – best-first-estimate (1) – breadth-first (2) – depth-first (3) – hy...
Definition AlpsParams.h:140
@ msgLevel
The level of printing messages on screen.
Definition AlpsParams.h:113
@ eliteSize
Number of the "elite" nodes that are used in determining workload.
Definition AlpsParams.h:77
@ processNum
The total number of processes that are launched for parallel code.
Definition AlpsParams.h:126
@ hubMsgLevel
Message level of the hub specific messages.
Definition AlpsParams.h:85
@ logFileLevel
The level of log file.
Definition AlpsParams.h:95
@ smallSize
The size of memory allocated for small size message.
Definition AlpsParams.h:144
@ hubWorkClusterSizeLimit
If the number of processes in a cluster is less than it, the hub also work as a worker.
Definition AlpsParams.h:105
@ workerMsgLevel
Message level of the worker specific messages.
Definition AlpsParams.h:155
@ printSystemStatus
Print system status: 0: do not print, 1: print.
Definition AlpsParams.h:122
@ masterInitNodeNum
The number of nodes initially generated by the master.
Definition AlpsParams.h:98
@ nodeLogInterval
Node log interval.
Definition AlpsParams.h:119
@ hubNum
The number of hubs.
Definition AlpsParams.h:88
@ staticBalanceScheme
Static load balancing scheme – root initialization (0) – spiral (1)
Definition AlpsParams.h:131
const std::string & entry(const strParams key) const
Definition AlpsParams.h:303
boolParams
Character parameters.
Definition AlpsParams.h:41
@ interClusterBalance
Master balances the workload of hubs: centralized.
Definition AlpsParams.h:50
@ deletePrunedNodes
Warm start or not.
Definition AlpsParams.h:60
@ printSolution
Print solution to screen and log if have a solution and msgLevel and logFileLevel permits.
Definition AlpsParams.h:57
@ checkMemory
Check memory.
Definition AlpsParams.h:44
@ endOfBoolParams
Definition AlpsParams.h:62
@ deleteDeadNode
Remove dead nodes or not.
Definition AlpsParams.h:47
@ intraClusterBalance
Hub balances the workload of workers: receiver initialized.
Definition AlpsParams.h:53
void setEntry(const intParams key, const int val)
Definition AlpsParams.h:324
const std::vector< std::string > & entry(const strArrayParams key) const
Definition AlpsParams.h:306
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
int entry(const intParams key) const
Definition AlpsParams.h:298
strArrayParams
There are no string array parameters.
Definition AlpsParams.h:216
@ endOfStrArrayParams
Definition AlpsParams.h:220
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition AlpsParams.h:318
void pack(AlpsEncoded &buf)
Pack the parameter set into buf.
Definition AlpsParams.h:344
void setEntry(const dblParams key, const char *val)
Definition AlpsParams.h:327
virtual ~AlpsParams()
Definition AlpsParams.h:244
strParams
String parameters.
Definition AlpsParams.h:203
@ instance
The instance to be solved.
Definition AlpsParams.h:206
@ logFile
The name of log file.
Definition AlpsParams.h:209
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition AlpsParams.h:315
dblParams
Double parameters.
Definition AlpsParams.h:162
@ donorThreshold
It is between 1.0 - infty.
Definition AlpsParams.h:171
@ unitWorkTime
The time length of a unit work.
Definition AlpsParams.h:193
@ masterBalancePeriod
The time period for master to do loading balance/termination check.
Definition AlpsParams.h:177
@ receiverThreshold
It is between 0.0 - 1.0.
Definition AlpsParams.h:184
@ changeWorkThreshold
The threshold of workload below which a worker will change the subtree that is working on.
Definition AlpsParams.h:166
@ timeLimit
The time limit (in seconds) of search.
Definition AlpsParams.h:187
@ tolerance
The numeric tolerance.
Definition AlpsParams.h:190
@ zeroLoad
If less than this number, it is considered zero workload.
Definition AlpsParams.h:196
@ hubReportPeriod
The time period (sec) for hubs to process messages.
Definition AlpsParams.h:174
@ needWorkThreshold
The threshold of workload below which a process will ask for workload Default: 2.
Definition AlpsParams.h:180
bool entry(const boolParams key) const
Definition AlpsParams.h:296
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition AlpsParams.h:312
AlpsParams & operator=(const AlpsParams &x)
Definition AlpsParams.h:247
void setEntry(const strParams key, const char *val)
Definition AlpsParams.h:333
void setEntry(const dblParams key, const double val)
Definition AlpsParams.h:330
void setEntry(const intParams key, const char *val)
Definition AlpsParams.h:321
void setEntry(const strArrayParams key, const char *val)
Definition AlpsParams.h:336
AlpsParams()
The default constructor creates a parameter set with from the template argument structure.
Definition AlpsParams.h:230