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

- File List
- File Members

VrpParams.h
Go to the documentation of this file.
1 /*===========================================================================*
2 * This file is part of a solver for the Vehicle Routing Problem *
3 * developed using the BiCePS Linear Integer Solver (BLIS). *
4 * *
5 * This solver is distributed under the Eclipse Public License as part of *
6 * the COIN-OR repository (http://www.coin-or.org). *
7 * *
8 * Authors: Yan Xu, Lehigh University *
9 * Ted Ralphs, Lehigh University *
10 * *
11 * Copyright (C) 2007 Yan Xu and Ted Ralphs. *
12 * All Rights Reserved. *
13 *===========================================================================*/
14
15 #ifndef VrpParams_h
16 #define VrpParams_h
17
18 #include "AlpsKnowledge.h"
19 #include "AlpsParameterBase.h"
20
21 //#############################################################################
22
23 //** Parameters used in Vrp. */
24 class VrpParams : public AlpsParameterSet {
25 public:
28 enum boolParams{
29 doGreedy,
30 doExtraInRoot,
31 tspProb,
32 endOfBoolParams
33 };
34
36 enum intParams{
37 numRoutes,
38 verbosity,
39 greedyNumTrials,
40 whichConnectedRoutine,
41 maxNumCutsInShrink,
42 whichTspCuts,
43 endOfIntParams
44 };
45
47 enum dblParams{
49 endOfDblParams
50 };
51
53 enum strParams{
54 strDummy,
55 //
56 endOfStrParams
57 };
58
60 enum strArrayParams{
61 strArrayDummy,
63 endOfStrArrayParams
64 };
65
66 public:
72 VrpParams() :
73 AlpsParameterSet(
74 static_cast<int>(endOfBoolParams),
75 static_cast<int>(endOfIntParams),
76 static_cast<int>(endOfDblParams),
77 static_cast<int>(endOfStrParams),
78 static_cast<int>(endOfStrArrayParams)
79 )
80 {
81 createKeywordList();
82 setDefaultEntries();
83 }
88 virtual void createKeywordList();
90 virtual void setDefaultEntries();
94 public:
95 //===========================================================================
103 //===========================================================================
104
105
114 inline bool entry(const boolParams key) const { return bpar_[key]; }
117 inline int entry(const intParams key) const { return ipar_[key]; }
119 inline double entry(const dblParams key) const { return dpar_[key]; }
121 inline const std::string&
122 entry(const strParams key) const { return spar_[key]; }
124 inline const std::vector<std::string>&
125 entry(const strArrayParams key) const { return sapar_[key]; }
128 //---------------------------------------------------------------------------
130 void setEntry(const boolParams key, const char * val) {
131 bpar_[key] = atoi(val) ? true : false; }
133 void setEntry(const boolParams key, const char val) {
134 bpar_[key] = val ? true : false; }
136 void setEntry(const boolParams key, const bool val) {
137 bpar_[key] = val; }
139 void setEntry(const intParams key, const char * val) {
140 ipar_[key] = atoi(val); }
142 void setEntry(const intParams key, const int val) {
143 ipar_[key] = val; }
145 void setEntry(const dblParams key, const char * val) {
146 dpar_[key] = atof(val); }
148 void setEntry(const dblParams key, const double val) {
149 dpar_[key] = val; }
151 void setEntry(const strParams key, const char * val) {
152 spar_[key] = val; }
154 void setEntry(const strArrayParams key, const char *val) {
155 sapar_[key].push_back(val); }
156
157 //---------------------------------------------------------------------------
158
163 void pack(AlpsEncoded& buf) {
164 buf.writeRep(bpar_, endOfBoolParams)
165 .writeRep(ipar_, endOfIntParams)
166 .writeRep(dpar_, endOfDblParams);
167 for (int i = 0; i < endOfStrParams; ++i)
168 buf.writeRep(spar_[i]);
169 for (int i = 0; i < endOfStrArrayParams; ++i) {
170 buf.writeRep(sapar_[i].size());
171 for (size_t j = 0; j < sapar_[i].size(); ++j)
172 buf.writeRep(sapar_[i][j]);
173 }
174 }
176 void unpack(AlpsEncoded& buf) {
177 int dummy;
178 // No need to allocate the arrays, they are of fixed length
179 dummy = static_cast<int>(endOfBoolParams);
180 buf.readRep(bpar_, dummy, false);
181 dummy = static_cast<int>(endOfIntParams);
182 buf.readRep(ipar_, dummy, false);
183 dummy = static_cast<int>(endOfDblParams);
184 buf.readRep(dpar_, dummy, false);
185 for (int i = 0; i < endOfStrParams; ++i)
186 buf.readRep(spar_[i]);
187 for (int i = 0; i < endOfStrArrayParams; ++i) {
188 size_t str_size;
189 buf.readRep(str_size);
190 sapar_[i].reserve(str_size);
191 for (size_t j = 0; j < str_size; ++j){
192 // sapar_[i].unchecked_push_back(std::string());
193 sapar_[i].push_back(std::string());
194 buf.readRep(sapar_[i].back());
195 }
196 }
197 }
200 };
201
202 #endif
VrpParams::maxNumCutsInShrink
Definition: VrpParams.h:41
VrpParams::entry
const std::string & entry(const strParams key) const
Definition: VrpParams.h:122
VrpParams::doExtraInRoot
Definition: VrpParams.h:30
VrpParams::setEntry
void setEntry(const boolParams key, const char val)
char is true(1) or false(0), not used
Definition: VrpParams.h:133
VrpParams::setEntry
void setEntry(const boolParams key, const char *val)
char* is true(1) or false(0), not used
Definition: VrpParams.h:130
VrpParams::setDefaultEntries
virtual void setDefaultEntries()
Method for setting the default values for the parameters.
AlpsEncoded::readRep
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:173
VrpParams::greedyNumTrials
Definition: VrpParams.h:39
VrpParams::intParams
intParams
Integer paramters.
Definition: VrpParams.h:36
AlpsEncoded::writeRep
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:163
VrpParams::entry
double entry(const dblParams key) const
Definition: VrpParams.h:119
AlpsParameterBase.h
VrpParams::tspProb
Definition: VrpParams.h:31
VrpParams::whichTspCuts
Definition: VrpParams.h:42
AlpsParameterSet
This is the class serves as a holder for a set of parameters.
Definition: AlpsParameterBase.h:134
VrpParams::setEntry
void setEntry(const dblParams key, const double val)
Definition: VrpParams.h:148
VrpParams::unpack
void unpack(AlpsEncoded &buf)
Unpack the parameter set from the buffer.
Definition: VrpParams.h:176
VrpParams::pack
void pack(AlpsEncoded &buf)
Pack the parameter set into the buffer (AlpsEncoded is used as buffer Here).
Definition: VrpParams.h:163
AlpsParameterSet::ipar_
int * ipar_
The integer parameters.
Definition: AlpsParameterBase.h:150
VrpParams::setEntry
void setEntry(const intParams key, const int val)
Definition: VrpParams.h:142
VrpParams::strArrayParams
strArrayParams
There are no string array parameters.
Definition: VrpParams.h:60
VrpParams::VrpParams
VrpParams()
The default constructor creates a parameter set with from the template argument structure.
Definition: VrpParams.h:72
VrpParams::dblParams
dblParams
Double parameters.
Definition: VrpParams.h:47
VrpParams::endOfStrArrayParams
Definition: VrpParams.h:63
VrpParams::setEntry
void setEntry(const intParams key, const char *val)
Definition: VrpParams.h:139
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
VrpParams::whichConnectedRoutine
Definition: VrpParams.h:40
AlpsParameterSet::spar_
std::string * spar_
The string (actually, std::string) parameters.
Definition: AlpsParameterBase.h:156
VrpParams::boolParams
boolParams
Character parameters.
Definition: VrpParams.h:28
VrpParams::verbosity
Definition: VrpParams.h:38
VrpParams::setEntry
void setEntry(const strArrayParams key, const char *val)
Definition: VrpParams.h:154
VrpParams::setEntry
void setEntry(const strParams key, const char *val)
Definition: VrpParams.h:151
VrpParams::setEntry
void setEntry(const boolParams key, const bool val)
This method is the one that ever been used.
Definition: VrpParams.h:136
AlpsKnowledge.h
AlpsParameterSet::sapar_
std::vector< std::string > * sapar_
The keyword, parameter pairs.
Definition: AlpsParameterBase.h:160
VrpParams::numRoutes
Definition: VrpParams.h:37
VrpParams::entry
const std::vector< std::string > & entry(const strArrayParams key) const
Definition: VrpParams.h:125
AlpsParameterSet::bpar_
bool * bpar_
The bool parameters.
Definition: AlpsParameterBase.h:147
VrpParams::strArrayDummy
Definition: VrpParams.h:61
VrpParams::createKeywordList
virtual void createKeywordList()
Method for creating the list of keyword looked for in the parameter file.
VrpParams::setEntry
void setEntry(const dblParams key, const char *val)
Definition: VrpParams.h:145
VrpParams::entry
bool entry(const boolParams key) const
Definition: VrpParams.h:115
VrpParams::strDummy
Definition: VrpParams.h:54
VrpParams::endOfDblParams
Definition: VrpParams.h:49
AlpsParameterSet::dpar_
double * dpar_
The double parameters.
Definition: AlpsParameterBase.h:153
VrpParams::entry
int entry(const intParams key) const
Definition: VrpParams.h:117
VrpParams::endOfBoolParams
Definition: VrpParams.h:32
VrpParams::doGreedy
Definition: VrpParams.h:29
VrpParams::endOfStrParams
Definition: VrpParams.h:56
VrpParams
Definition: VrpParams.h:24
VrpParams::endOfIntParams
Definition: VrpParams.h:43
VrpParams::strParams
strParams
String parameters.
Definition: VrpParams.h:53