Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef VrpSolution_h_
00016 #define VrpSolution_h_
00017
00018 #include "BlisSolution.h"
00019
00020 #include "VrpModel.h"
00021
00022
00024
00025
00026 class VrpSolution : public BlisSolution {
00027
00028 protected:
00029
00030 _node *opt_;
00031
00032 public:
00033
00035 VrpSolution() : BlisSolution(), opt_(0)
00036 {}
00037
00039 VrpSolution(int s, const double *values, double objValue, VrpModel *vrp=0);
00040
00042 virtual ~VrpSolution(){
00043 delete [] opt_;
00044 }
00045
00047 void setOpt(_node *opt) {
00048 if (opt_) delete opt_;
00049 opt_ = opt;
00050 }
00051
00053 virtual void print(std::ostream& os) const;
00054
00056 virtual AlpsEncoded* encode() const {
00057 AlpsEncoded* encoded = new AlpsEncoded(AlpsKnowledgeTypeSolution);
00058 encodeBcps(encoded);
00059
00060
00061 int cur_vert = opt_[0].next, count = 1;
00062 while (cur_vert != 0){
00063 cur_vert = opt_[cur_vert].next;
00064 ++count;
00065 }
00066 encoded->writeRep(count);
00067 for (int j = 0; j < count; ++j) {
00068 encoded->writeRep(opt_[j].next);
00069 encoded->writeRep(opt_[j].route);
00070 }
00071
00072 return encoded;
00073 }
00074
00076 virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const {
00077 VrpSolution * sol = new VrpSolution();
00078 sol->decodeBcps(encoded);
00079
00080
00081 int count;
00082 encoded.readRep(count);
00083 _node *opt = new _node [count];
00084 for (int j = 0; j < count; ++j) {
00085 encoded.readRep(opt[j].next);
00086 encoded.readRep(opt[j].route);
00087 }
00088 sol->setOpt(opt);
00089
00090 return sol;
00091 }
00092
00093 };
00094
00095
00096
00097
00098 #endif