test/tsp_test.cc
changeset 1092 dceba191c00d
parent 1037 d3dcc49e6403
child 1093 fb1c7da561ce
     1.1 --- a/test/tsp_test.cc	Fri Aug 09 14:07:27 2013 +0200
     1.2 +++ b/test/tsp_test.cc	Fri Aug 09 11:28:17 2013 +0200
     1.3 @@ -2,7 +2,7 @@
     1.4   *
     1.5   * This file is a part of LEMON, a generic C++ optimization library.
     1.6   *
     1.7 - * Copyright (C) 2003-2010
     1.8 + * Copyright (C) 2003-2013
     1.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11   *
    1.12 @@ -41,7 +41,7 @@
    1.13  //   check(checkMetricCost(g, constMap<Edge>(0)), "Wrong checkMetricCost()");
    1.14  //   check(checkMetricCost(g, constMap<Edge>(1)), "Wrong checkMetricCost()");
    1.15  //   check(!checkMetricCost(g, constMap<Edge>(-1)), "Wrong checkMetricCost()");
    1.16 -//   
    1.17 +//
    1.18  //   FullGraph::EdgeMap<float> cost(g);
    1.19  //   for (NodeIt u(g); u != INVALID; ++u) {
    1.20  //     for (NodeIt v(g); v != INVALID; ++v) {
    1.21 @@ -64,7 +64,7 @@
    1.22  template <typename Container>
    1.23  bool checkTour(const FullGraph &gr, const Container &p) {
    1.24    FullGraph::NodeMap<bool> used(gr, false);
    1.25 -  
    1.26 +
    1.27    int node_cnt = 0;
    1.28    for (typename Container::const_iterator it = p.begin(); it != p.end(); ++it) {
    1.29      FullGraph::Node node = *it;
    1.30 @@ -72,14 +72,14 @@
    1.31      used[node] = true;
    1.32      ++node_cnt;
    1.33    }
    1.34 -  
    1.35 +
    1.36    return (node_cnt == gr.nodeNum());
    1.37  }
    1.38  
    1.39  // Checks tour validity
    1.40  bool checkTourPath(const FullGraph &gr, const Path<FullGraph> &p) {
    1.41    FullGraph::NodeMap<bool> used(gr, false);
    1.42 -  
    1.43 +
    1.44    if (!checkPath(gr, p)) return false;
    1.45    if (gr.nodeNum() <= 1 && p.length() != 0) return false;
    1.46    if (gr.nodeNum() > 1 && p.length() != gr.nodeNum()) return false;
    1.47 @@ -181,7 +181,7 @@
    1.48          cost[g.edge(u, v)] = (pos[u] - pos[v]).normSquare();
    1.49        }
    1.50      }
    1.51 -    
    1.52 +
    1.53      check(alg.run() > 0, alg_name + ": Wrong total cost");
    1.54  
    1.55      std::vector<Node> vec;
    1.56 @@ -195,14 +195,14 @@
    1.57      check(checkTourPath(g, path), alg_name + ": Wrong tour");
    1.58      check(checkCost(g, path, cost, alg.tourCost()),
    1.59        alg_name + ": Wrong tour cost");
    1.60 -    
    1.61 +
    1.62      check(!Tolerance<double>().less(alg.tourCost(), opt2.run(alg.tourNodes())),
    1.63        "2-opt improvement: Wrong total cost");
    1.64      check(checkTour(g, opt2.tourNodes()),
    1.65        "2-opt improvement: Wrong node sequence");
    1.66      check(checkCost(g, opt2.tourNodes(), cost, opt2.tourCost()),
    1.67        "2-opt improvement: Wrong tour cost");
    1.68 -    
    1.69 +
    1.70      check(!Tolerance<double>().less(alg.tourCost(), opt2.run(path)),
    1.71        "2-opt improvement: Wrong total cost");
    1.72      check(checkTour(g, opt2.tourNodes()),
    1.73 @@ -212,7 +212,7 @@
    1.74    }
    1.75  }
    1.76  
    1.77 -// Algorithm class for Nearest Insertion 
    1.78 +// Algorithm class for Nearest Insertion
    1.79  template <typename CM>
    1.80  class NearestInsertionTsp : public InsertionTsp<CM> {
    1.81  public:
    1.82 @@ -223,7 +223,7 @@
    1.83    }
    1.84  };
    1.85  
    1.86 -// Algorithm class for Farthest Insertion 
    1.87 +// Algorithm class for Farthest Insertion
    1.88  template <typename CM>
    1.89  class FarthestInsertionTsp : public InsertionTsp<CM> {
    1.90  public:
    1.91 @@ -234,7 +234,7 @@
    1.92    }
    1.93  };
    1.94  
    1.95 -// Algorithm class for Cheapest Insertion 
    1.96 +// Algorithm class for Cheapest Insertion
    1.97  template <typename CM>
    1.98  class CheapestInsertionTsp : public InsertionTsp<CM> {
    1.99  public:
   1.100 @@ -245,7 +245,7 @@
   1.101    }
   1.102  };
   1.103  
   1.104 -// Algorithm class for Random Insertion 
   1.105 +// Algorithm class for Random Insertion
   1.106  template <typename CM>
   1.107  class RandomInsertionTsp : public InsertionTsp<CM> {
   1.108  public: