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

- File List
- File Members

# /home/coin/svn-release/Alps-1.4.8/Alps/examples/Abc/AbcParams.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-2013, Lehigh University, Yan Xu, and Ted Ralphs.       *
    00021  *===========================================================================*/
    00022
    00023 #ifndef AbcParams_h
    00024 #define AbcParams_h
    00025
    00026 #include "AlpsKnowledge.h"
    00027 #include "AlpsParameterBase.h"
    00028
    00029
    00030 //#############################################################################
    00031 //#############################################################################
    00032 //** Parameters used in Abc. */
    00033 class AbcParams : public AlpsParameterSet {
    00034  public:
    00037   enum boolParams{
    00039     cutDuringRampup,
    00040     //
    00041     endOfBoolParams
    00042   };
    00043
    00045   enum intParams{
    00047       statusInterval,
    00049       logLevel,
    00050       //
    00051       endOfIntParams
    00052   };
    00053
    00055   enum dblParams{
    00056     dblDummy,
    00057     //
    00058     endOfDblParams
    00059   };
    00060
    00062   enum strParams{
    00063     strDummy,
    00064     //
    00065     endOfStrParams
    00066   };
    00067
    00069   enum strArrayParams{
    00070     strArrayDummy,
    00071     //
    00072     endOfStrArrayParams
    00073   };
    00074
    00075  public:
    00081   AbcParams() :
    00082     AlpsParameterSet(
    00083     static_cast<int>(endOfBoolParams),
    00084     static_cast<int>(endOfIntParams),
    00085     static_cast<int>(endOfDblParams),
    00086     static_cast<int>(endOfStrParams),
    00087     static_cast<int>(endOfStrArrayParams)
    00088     )
    00089     {
    00090       createKeywordList();
    00091       setDefaultEntries();
    00092     }
    00097   virtual void createKeywordList();
    00099   virtual void setDefaultEntries();
    00103  public:
    00104   //===========================================================================
    00112   //===========================================================================
    00113
    00114
    00123
    00124   inline char
    00125     entry(const boolParams key) const { return bpar_[key]; }
    00127   inline int
    00128     entry(const intParams key) const { return ipar_[key]; }
    00130   inline double
    00131     entry(const dblParams key) const { return dpar_[key]; }
    00133   inline const std::string&
    00134     entry(const strParams key) const { return spar_[key]; }
    00136   inline const std::vector<std::string>&
    00137     entry(const strArrayParams key) const { return sapar_[key]; }
    00140   //---------------------------------------------------------------------------
    00142   void setEntry(const boolParams key, const char * val) {
    00143     bpar_[key] = atoi(val) ? true : false; }
    00145   void setEntry(const boolParams key, const char val) {
    00146           bpar_[key] = val ? true : false; }
    00148   void setEntry(const boolParams key, const bool val) {
    00149     bpar_[key] = val; }
    00151   void setEntry(const intParams key, const char * val) {
    00152     ipar_[key] = atoi(val); }
    00154   void setEntry(const intParams key, const int val) {
    00155     ipar_[key] = val; }
    00157   void setEntry(const dblParams key, const char * val) {
    00158     dpar_[key] = atof(val); }
    00160   void setEntry(const dblParams key, const double val) {
    00161     dpar_[key] = val; }
    00163   void setEntry(const strParams key, const char * val) {
    00164     spar_[key] = val; }
    00166   void setEntry(const strArrayParams key, const char *val) {
    00167     sapar_[key].push_back(val); }
    00168
    00169   //---------------------------------------------------------------------------
    00170
    00175   void pack(AlpsEncoded& buf) {
    00176     buf.writeRep(bpar_, endOfBoolParams)
    00177       .writeRep(ipar_, endOfIntParams)
    00178       .writeRep(dpar_, endOfDblParams);
    00179     for (int i = 0; i < endOfStrParams; ++i)
    00180       buf.writeRep(spar_[i]);
    00181     for (int i = 0; i < endOfStrArrayParams; ++i) {
    00182       buf.writeRep(sapar_[i].size());
    00183       for (size_t j = 0; j < sapar_[i].size(); ++j)
    00184         buf.writeRep(sapar_[i][j]);
    00185     }
    00186   }
    00188   void unpack(AlpsEncoded& buf) {
    00189     int dummy;
    00190     // No need to allocate the arrays, they are of fixed length
    00191     dummy = static_cast<int>(endOfBoolParams);
    00192     buf.readRep(bpar_, dummy, false);
    00193     dummy = static_cast<int>(endOfIntParams);
    00194     buf.readRep(ipar_, dummy, false);
    00195     dummy = static_cast<int>(endOfDblParams);
    00196     buf.readRep(dpar_, dummy, false);
    00197     for (int i = 0; i < endOfStrParams; ++i)
    00198       buf.readRep(spar_[i]);
    00199     for (int i = 0; i < endOfStrArrayParams; ++i) {
    00200       size_t str_size;
    00201       buf.readRep(str_size);
    00202       sapar_[i].reserve(str_size);
    00203       for (size_t j = 0; j < str_size; ++j){
    00204         //      sapar_[i].unchecked_push_back(std::string());
    00205         sapar_[i].push_back(std::string());
    00206         buf.readRep(sapar_[i].back());
    00207       }
    00208     }
    00209   }
    00212 };
    00213
    00214 #endif