/home/coin/SVN-release/CoinAll-1.1.0/Blis/examples/VRP/VrpParams.h

Go to the documentation of this file.
00001 /*===========================================================================*
00002  * This file is part of a solver for the Vehicle Routing Problem             *
00003  * developed using the BiCePS Linear Integer Solver (BLIS).                  *
00004  *                                                                           *
00005  * This solver is distributed under the Common Public License as part of     * 
00006  * the COIN-OR repository (http://www.coin-or.org).                          *
00007  *                                                                           *
00008  * Authors: Yan Xu, Lehigh University                                        *
00009  *          Ted Ralphs, Lehigh University                                    *
00010  *                                                                           *
00011  * Copyright (C) 2007 Yan Xu and Ted Ralphs.                                 *
00012  * All Rights Reserved.                                                      *
00013  *===========================================================================*/
00014 
00015 #ifndef VrpParams_h
00016 #define VrpParams_h
00017 
00018 #include "AlpsKnowledge.h"
00019 #include "AlpsParameterBase.h"
00020 
00021 //#############################################################################
00022 
00023 //** Parameters used in Vrp. */
00024 class VrpParams : public AlpsParameterSet {
00025  public:
00028   enum boolParams{
00029      doGreedy,
00030      doExtraInRoot,
00031      tspProb,
00032      endOfBoolParams
00033   };
00034   
00036   enum intParams{
00037      numRoutes,
00038      verbosity,
00039      greedyNumTrials,
00040      whichConnectedRoutine,
00041      maxNumCutsInShrink,
00042      whichTspCuts,
00043      endOfIntParams
00044   };
00045 
00047   enum dblParams{
00049       endOfDblParams
00050   };
00051 
00053   enum strParams{
00054       strDummy,
00055       //
00056       endOfStrParams
00057   };
00058 
00060   enum strArrayParams{
00061       strArrayDummy,
00063       endOfStrArrayParams
00064   };
00065 
00066  public:
00072   VrpParams() :
00073     AlpsParameterSet(
00074                      static_cast<int>(endOfBoolParams),
00075                      static_cast<int>(endOfIntParams),
00076                      static_cast<int>(endOfDblParams),
00077                      static_cast<int>(endOfStrParams),
00078                      static_cast<int>(endOfStrArrayParams)
00079                      )
00080     {
00081       createKeywordList();
00082       setDefaultEntries();
00083     }
00088   virtual void createKeywordList();
00090   virtual void setDefaultEntries();
00094  public:
00095   //===========================================================================
00103   //===========================================================================
00104 
00105   
00114 
00115   inline bool entry(const boolParams key) const { return bpar_[key]; }
00117   inline int entry(const intParams key) const { return ipar_[key]; }
00119   inline double  entry(const dblParams key) const { return dpar_[key]; }
00121   inline const std::string&
00122     entry(const strParams key) const { return spar_[key]; }
00124   inline const std::vector<std::string>&
00125     entry(const strArrayParams key) const { return sapar_[key]; }
00128   //---------------------------------------------------------------------------
00130   void setEntry(const boolParams key, const char * val) {
00131           bpar_[key] = atoi(val) ? true : false; }
00133   void setEntry(const boolParams key, const char val) {
00134           bpar_[key] = val ? true : false; }
00136   void setEntry(const boolParams key, const bool val) {
00137     bpar_[key] = val; }
00139   void setEntry(const intParams key, const char * val) {
00140     ipar_[key] = atoi(val); }
00142   void setEntry(const intParams key, const int val) {
00143     ipar_[key] = val; }
00145   void setEntry(const dblParams key, const char * val) {
00146     dpar_[key] = atof(val); }
00148   void setEntry(const dblParams key, const double val) {
00149     dpar_[key] = val; }
00151   void setEntry(const strParams key, const char * val) {
00152     spar_[key] = val; }
00154   void setEntry(const strArrayParams key, const char *val) {
00155     sapar_[key].push_back(val); }
00156 
00157   //---------------------------------------------------------------------------
00158 
00163   void pack(AlpsEncoded& buf) {
00164     buf.writeRep(bpar_, endOfBoolParams)
00165       .writeRep(ipar_, endOfIntParams)
00166       .writeRep(dpar_, endOfDblParams);
00167     for (int i = 0; i < endOfStrParams; ++i)
00168       buf.writeRep(spar_[i]);
00169     for (int i = 0; i < endOfStrArrayParams; ++i) {
00170       buf.writeRep(sapar_[i].size());
00171       for (size_t j = 0; j < sapar_[i].size(); ++j)
00172         buf.writeRep(sapar_[i][j]);
00173     }
00174   }
00176   void unpack(AlpsEncoded& buf) {
00177     int dummy;
00178     // No need to allocate the arrays, they are of fixed length
00179     dummy = static_cast<int>(endOfBoolParams);
00180     buf.readRep(bpar_, dummy, false);
00181     dummy = static_cast<int>(endOfIntParams);
00182     buf.readRep(ipar_, dummy, false);
00183     dummy = static_cast<int>(endOfDblParams);
00184     buf.readRep(dpar_, dummy, false);
00185     for (int i = 0; i < endOfStrParams; ++i)
00186       buf.readRep(spar_[i]);
00187     for (int i = 0; i < endOfStrArrayParams; ++i) {
00188       size_t str_size;
00189       buf.readRep(str_size);
00190       sapar_[i].reserve(str_size);
00191       for (size_t j = 0; j < str_size; ++j){
00192         //      sapar_[i].unchecked_push_back(std::string());
00193         sapar_[i].push_back(std::string());
00194         buf.readRep(sapar_[i].back());
00195       }
00196     }
00197   }
00200 };
00201 
00202 #endif

Generated on Sun Nov 14 14:06:30 2010 for Coin-All by  doxygen 1.4.7