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

- File List
- File Members

VrpHeurTSP.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 VrpHeurTSP_h_
16 #define VrpHeurTSP_h_
17
18 //#############################################################################
19
20 #include <vector>
21
22 #include "CoinPackedVector.hpp"
23
24 #include "BlisHeuristic.h"
25 #include "VrpModel.h"
26
27 //#############################################################################
28 #if 0
29 class VrpAdjList
30 {
31 private:
32 std::vector<CoinPackedVector *> list_;
33 VrpModel *model_;
34 public:
35 VrpAdjList() {}
36 VrpAdjList(VrpModel *m) {
37 model_ = m;
38 createAdjList(m);
39 }
40
41 void createAdjList(VrpModel *model);
42 };
43
44 typedef struct vrp_neighbors
45 {
46 int n1;
47 int n2;
48 } VrpNeighbors;
49
50 #endif
51
52 //#############################################################################
53
54 class VrpHeurTSP : public BlisHeuristic {
55 private:
57 VrpHeurTSP & operator=(const VrpHeurTSP& rhs);
58
59 protected:
60 /* Stored the predetermined next vertex to visit for vertex k if
61 the value determined_[k] greater than zero. */
62 //int *determined_;
63
64 /* Adjacent list of all vertices. */
65 std::vector<CoinPackedVector *> adjList_;
66
68 void createAdjList(VrpModel *model);
69
71 std::vector<int> tour_;
72
74 bool *visited_;
75
77 int preNode_;
78
80 //VrpNeighbor *
81 int *neighbors_;
82
84 int nodeCalls_;
85
88 std::vector<int> *edgeColMatch_;
89
90 void freeGuts() {
91 if (visited_) {
92 delete [] visited_;
93 visited_ = NULL;
94 }
95 int numVertices = adjList_.size();
96 for (int k = 0; k < numVertices; ++k) {
97 delete adjList_[k];
98 }
99 adjList_.clear();
100 if (neighbors_) {
101 delete [] neighbors_;
102 neighbors_ = NULL;
103 }
104 if (edgeColMatch_) {
105 delete [] edgeColMatch_;
106 edgeColMatch_ = NULL;
107 }
108 }
109
110 public:
112 VrpHeurTSP()
113 :
114 visited_(0), preNode_(-1),
115 neighbors_(0), nodeCalls_(0), edgeColMatch_(0) {}
116
118 VrpHeurTSP(VrpModel * model, const char *name,
119 BlisHeurStrategy strategy, int freq)
120 :
121 BlisHeuristic(model, name, strategy, freq)
122 {
123 visited_ = NULL;
124 preNode_ = -1;
125 neighbors_ = NULL;
126 nodeCalls_ = 0;
127 edgeColMatch_ = NULL;
128 createAdjList(model);
129 }
130
132 ~VrpHeurTSP()
133 {
134 freeGuts();
135 }
136
139 virtual bool searchSolution(double & objectiveValue, double * newSolution);
140 };
141 #endif
142
143 //#############################################################################
BlisHeurStrategy
BlisHeurStrategy
Definition: Blis.h:77
VrpHeurTSP::~VrpHeurTSP
~VrpHeurTSP()
Destructor.
Definition: VrpHeurTSP.h:132
VrpHeurTSP::VrpHeurTSP
VrpHeurTSP()
Default Constructor.
Definition: VrpHeurTSP.h:112
VrpModel
Model class for VRP.
Definition: VrpModel.h:32
BlisHeuristic
Heuristic base class.
Definition: BlisHeuristic.h:46
VrpHeurTSP::createAdjList
void createAdjList(VrpModel *model)
Create adjacent list for each vertex.
CoinPackedVector.hpp
VrpModel.h
VrpHeurTSP::searchSolution
virtual bool searchSolution(double &objectiveValue, double *newSolution)
Returns 0 if no solution, 1 if valid solution.
VrpHeurTSP::edgeColMatch_
std::vector< int > * edgeColMatch_
Edge and column relationship.
Definition: VrpHeurTSP.h:88
VrpHeurTSP::preNode_
int preNode_
The node at which this heuristic was call.
Definition: VrpHeurTSP.h:77
VrpHeurTSP::adjList_
std::vector< CoinPackedVector * > adjList_
Definition: VrpHeurTSP.h:65
VrpHeurTSP::freeGuts
void freeGuts()
Definition: VrpHeurTSP.h:90
BlisHeuristic::name
const char * name() const
return name of generator.
Definition: BlisHeuristic.h:177
VrpHeurTSP::visited_
bool * visited_
Mark if vertices have been visited.
Definition: VrpHeurTSP.h:74
VrpHeurTSP::neighbors_
int * neighbors_
Neighbors determined from LP solution.
Definition: VrpHeurTSP.h:81
VrpHeurTSP::operator=
VrpHeurTSP & operator=(const VrpHeurTSP &rhs)
Illegal Assignment operator.
VrpHeurTSP::tour_
std::vector< int > tour_
TSP Tour.
Definition: VrpHeurTSP.h:71
VrpHeurTSP::nodeCalls_
int nodeCalls_
Call how many time at a node.
Definition: VrpHeurTSP.h:84
VrpHeurTSP
Definition: VrpHeurTSP.h:54
VrpHeurTSP::VrpHeurTSP
VrpHeurTSP(VrpModel *model, const char *name, BlisHeurStrategy strategy, int freq)
Constructor with model.
Definition: VrpHeurTSP.h:118
BlisHeuristic::strategy
virtual int strategy()
Get/set strategy.
Definition: BlisHeuristic.h:124