- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Alps-1.3.0/Alps/src/AlpsParams.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the Abstract Library for Parallel Search (ALPS).     *
    00003  *                                                                           *
    00004  * ALPS is distributed under the Eclipse Public License as part of the       *
    00005  * COIN-OR repository (http://www.coin-or.org).                              *
    00006  *                                                                           *
    00007  * Authors:                                                                  *
    00008  *                                                                           *
    00009  *          Yan Xu, Lehigh University                                        *
    00010  *          Ted Ralphs, Lehigh University                                    *
    00011  *                                                                           *
    00012  * Conceptual Design:                                                        *
    00013  *                                                                           *
    00014  *          Yan Xu, Lehigh University                                        *
    00015  *          Ted Ralphs, Lehigh University                                    *
    00016  *          Laszlo Ladanyi, IBM T.J. Watson Research Center                  *
    00017  *          Matthew Saltzman, Clemson University                             *
    00018  *                                                                           *
    00019  *                                                                           *
    00020  * Copyright (C) 2001-2011, Lehigh University, Yan Xu, and Ted Ralphs.       *
    00021  *===========================================================================*/
    00022
    00023 #ifndef AlpsParams_h
    00024 #define AlpsParams_h
    00025
    00026 #include "AlpsKnowledge.h"
    00027 #include "AlpsParameterBase.h"
    00028
    00029 // TODO: remove largeSize, mediumSize, smallSize
    00030
    00031 //#############################################################################
    00032
    00033 //class AlpsEncoded;
    00034
    00035 //** Parameters used in Alps. */
    00036 class AlpsParams : public AlpsParameterSet {
    00037  public:
    00040   enum boolParams
    00041   {
    00044       checkMemory,
    00047       deleteDeadNode,
    00050       interClusterBalance,
    00053       intraClusterBalance,
    00057       printSolution,
    00058       /***/
    00059       endOfBoolParams
    00060   };
    00061
    00063   enum intParams
    00064   {
    00067       bufSpare,
    00071       clockType,
    00074       eliteSize,
    00077       hubInitNodeNum,
    00082       hubMsgLevel,
    00085       hubNum,
    00088       largeSize,
    00092       logFileLevel,
    00095       masterInitNodeNum,
    00098       masterReportInterval,
    00102       hubWorkClusterSizeLimit,
    00105       mediumSize,
    00110       msgLevel,
    00113       nodeLimit,
    00116       nodeLogInterval,
    00119       printSystemStatus,
    00123       processNum,
    00128       staticBalanceScheme,
    00137       searchStrategy,
    00138       searchStrategyRampUp,
    00141       smallSize,
    00144       solLimit,
    00147       unitWorkNodes,
    00152       workerMsgLevel,
    00154       endOfIntParams
    00155   };
    00156
    00158   enum dblParams
    00159   {
    00163       changeWorkThreshold,
    00168       donorThreshold,
    00171       hubReportPeriod,
    00174       masterBalancePeriod,
    00177       needWorkThreshold,
    00181       receiverThreshold,
    00184       timeLimit,
    00187       tolerance,
    00190       unitWorkTime,
    00193       zeroLoad,
    00194       /***/
    00195       endOfDblParams
    00196   };
    00197
    00199   enum strParams
    00200   {
    00203       instance,
    00206       logFile,
    00208       endOfStrParams
    00209   };
    00210
    00212   enum strArrayParams
    00213   {
    00214       // The dummy is needed so the allocation won't try for 0 entries.
    00215       strArrayDummy,
    00217       endOfStrArrayParams
    00218   };
    00219
    00220  public:
    00221
    00227   AlpsParams() :
    00228       AlpsParameterSet(
    00229           static_cast<int>(endOfBoolParams),
    00230           static_cast<int>(endOfIntParams),
    00231           static_cast<int>(endOfDblParams),
    00232           static_cast<int>(endOfStrParams),
    00233           static_cast<int>(endOfStrArrayParams)
    00234           )
    00235   {
    00236       createKeywordList();
    00237       setDefaultEntries();
    00238   }
    00241       virtual ~AlpsParams(){  }
    00242
    00243
    00244       AlpsParams& operator=(const AlpsParams& x) {
    00245           // no need to delete anything, since the size of (almost) everything is
    00246           // the same, just copy over
    00247           // -- The static_cast is needed to satisfy the more picky IBM Visual Age
    00248           //    C++ compiler
    00249           std::copy(x.bpar_, x.bpar_ + static_cast<int>(endOfBoolParams),
    00250                     bpar_);
    00251           std::copy(x.ipar_, x.ipar_ + static_cast<int>(endOfIntParams),
    00252                     ipar_);
    00253           std::copy(x.dpar_, x.dpar_ + static_cast<int>(endOfDblParams),
    00254                     dpar_);
    00255           std::copy(x.spar_, x.spar_ + static_cast<int>(endOfStrParams),
    00256                     spar_);
    00257           std::copy(x.sapar_,
    00258                     x.sapar_ + static_cast<int>(endOfStrArrayParams),
    00259                     sapar_);
    00260           return *this;
    00261       }
    00262
    00265       virtual void createKeywordList();
    00267       virtual void setDefaultEntries();
    00268
    00269 public:
    00270       //====================================================
    00282       //====================================================
    00283
    00284
    00292
    00293       inline bool entry(const boolParams key) const { return bpar_[key]; }
    00295       inline int entry(const intParams key) const { return ipar_[key]; }
    00297       inline double entry(const dblParams key) const { return dpar_[key]; }
    00299       inline const std::string&
    00300           entry(const strParams key) const { return spar_[key]; }
    00302       inline const std::vector<std::string>&
    00303           entry(const strArrayParams key) const { return sapar_[key]; }
    00306       //----------------------------------------------------
    00307
    00309       void setEntry(const boolParams key, const char * val) {
    00310                   bpar_[key] = atoi(val) ? true : false; }
    00312       void setEntry(const boolParams key, const char val) {
    00313                   bpar_[key] = val ? true : false; }
    00315       void setEntry(const boolParams key, const bool val) {
    00316           bpar_[key] = val; }
    00318       void setEntry(const intParams key, const char * val) {
    00319           ipar_[key] = atoi(val); }
    00321       void setEntry(const intParams key, const int val) {
    00322           ipar_[key] = val; }
    00324       void setEntry(const dblParams key, const char * val) {
    00325           dpar_[key] = atof(val); }
    00327       void setEntry(const dblParams key, const double val) {
    00328           dpar_[key] = val; }
    00330       void setEntry(const strParams key, const char * val) {
    00331           spar_[key] = val; }
    00333       void setEntry(const strArrayParams key, const char *val) {
    00334           sapar_[key].push_back(val); }
    00335
    00336       //----------------------------------------------------
    00337
    00341       void pack(AlpsEncoded& buf) {
    00342           buf.writeRep(bpar_, endOfBoolParams)
    00343               .writeRep(ipar_, endOfIntParams)
    00344               .writeRep(dpar_, endOfDblParams);
    00345           for (int i = 0; i < endOfStrParams; ++i)
    00346               buf.writeRep(spar_[i]);
    00347           for (int i = 0; i < endOfStrArrayParams; ++i) {
    00348               buf.writeRep(sapar_[i].size());
    00349               for (size_t j = 0; j < sapar_[i].size(); ++j)
    00350                   buf.writeRep(sapar_[i][j]);
    00351           }
    00352       }
    00353
    00355       void unpack(AlpsEncoded& buf) {
    00356           int dummy;
    00357           // No need to allocate the arrays, they are of fixed length
    00358           dummy = static_cast<int>(endOfBoolParams);
    00359           buf.readRep(bpar_, dummy, false);
    00360           dummy = static_cast<int>(endOfIntParams);
    00361           buf.readRep(ipar_, dummy, false);
    00362           dummy = static_cast<int>(endOfDblParams);
    00363           buf.readRep(dpar_, dummy, false);
    00364           for (int i = 0; i < endOfStrParams; ++i)
    00365               buf.readRep(spar_[i]);
    00366           for (int i = 0; i < endOfStrArrayParams; ++i) {
    00367               size_t str_size;
    00368               buf.readRep(str_size);
    00369               sapar_[i].reserve(str_size);
    00370               for (size_t j = 0; j < str_size; ++j){
    00371                   //    sapar_[i].unchecked_push_back(std::string());
    00372                   sapar_[i].push_back(std::string());
    00373                   buf.readRep(sapar_[i].back());
    00374               }
    00375           }
    00376       }
    00378 };
    00379
    00380 #endif
    00381