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

- File List
- File Members

# /home/coin/svn-release/Blis-0.93.2/Blis/examples/VRP/VrpHeurTSP.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 Eclipse 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 VrpHeurTSP_h_
    00016 #define VrpHeurTSP_h_
    00017
    00018 //#############################################################################
    00019
    00020 #include <vector>
    00021
    00022 #include "CoinPackedVector.hpp"
    00023
    00024 #include "BlisHeuristic.h"
    00025 #include "VrpModel.h"
    00026
    00027 //#############################################################################
    00028 #if 0
    00029 class VrpAdjList
    00030 {
    00031 private:
    00032     std::vector<CoinPackedVector *> list_;
    00033     VrpModel *model_;
    00034 public:
    00035     VrpAdjList() {}
    00036     VrpAdjList(VrpModel *m) {
    00037         model_ = m;
    00038         createAdjList(m);
    00039     }
    00040
    00041     void createAdjList(VrpModel *model);
    00042 };
    00043
    00044 typedef struct vrp_neighbors
    00045 {
    00046     int n1;
    00047     int n2;
    00048 } VrpNeighbors;
    00049
    00050 #endif
    00051
    00052 //#############################################################################
    00053
    00054 class VrpHeurTSP : public BlisHeuristic {
    00055 private:
    00057     VrpHeurTSP & operator=(const VrpHeurTSP& rhs);
    00058
    00059 protected:
    00060     /* Stored the predetermined next vertex to visit for vertex k if
    00061        the value determined_[k] greater than zero. */
    00062     //int *determined_;
    00063
    00064     /* Adjacent list of all vertices. */
    00065     std::vector<CoinPackedVector *> adjList_;
    00066
    00068     void createAdjList(VrpModel *model);
    00069
    00071     std::vector<int> tour_;
    00072
    00074     bool *visited_;
    00075
    00077     int preNode_;
    00078
    00080     //VrpNeighbor *
    00081     int *neighbors_;
    00082
    00084     int nodeCalls_;
    00085
    00088     std::vector<int> *edgeColMatch_;
    00089
    00090     void freeGuts() {
    00091         if (visited_) {
    00092             delete [] visited_;
    00093             visited_ = NULL;
    00094         }
    00095         int numVertices = adjList_.size();
    00096         for (int k = 0; k < numVertices; ++k) {
    00097             delete adjList_[k];
    00098         }
    00099         adjList_.clear();
    00100         if (neighbors_) {
    00101             delete [] neighbors_;
    00102             neighbors_ = NULL;
    00103         }
    00104         if (edgeColMatch_) {
    00105             delete [] edgeColMatch_;
    00106             edgeColMatch_ = NULL;
    00107         }
    00108     }
    00109
    00110 public:
    00112     VrpHeurTSP()
    00113         :
    00114         visited_(0), preNode_(-1),
    00115         neighbors_(0), nodeCalls_(0), edgeColMatch_(0) {}
    00116
    00118     VrpHeurTSP(VrpModel * model, const char *name,
    00119                BlisHeurStrategy strategy, int freq)
    00120         :
    00121         BlisHeuristic(model, name, strategy, freq)
    00122     {
    00123         visited_ = NULL;
    00124         preNode_ = -1;
    00125         neighbors_ = NULL;
    00126         nodeCalls_ = 0;
    00127         edgeColMatch_ = NULL;
    00128         createAdjList(model);
    00129     }
    00130
    00132     ~VrpHeurTSP()
    00133     {
    00134         freeGuts();
    00135     }
    00136
    00139     virtual bool searchSolution(double & objectiveValue, double * newSolution);
    00140 };
    00141 #endif
    00142
    00143 //#############################################################################