Changeset 1270:dceba191c00d in lemon for test/tsp_test.cc
- Timestamp:
- 08/09/13 11:28:17 (11 years ago)
- Branch:
- default
- Children:
- 1271:fb1c7da561ce, 1381:e0ccc1f0268f
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/tsp_test.cc
r1205 r1270 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-201 05 * Copyright (C) 2003-2013 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 42 42 // check(checkMetricCost(g, constMap<Edge>(1)), "Wrong checkMetricCost()"); 43 43 // check(!checkMetricCost(g, constMap<Edge>(-1)), "Wrong checkMetricCost()"); 44 // 44 // 45 45 // FullGraph::EdgeMap<float> cost(g); 46 46 // for (NodeIt u(g); u != INVALID; ++u) { … … 65 65 bool checkTour(const FullGraph &gr, const Container &p) { 66 66 FullGraph::NodeMap<bool> used(gr, false); 67 67 68 68 int node_cnt = 0; 69 69 for (typename Container::const_iterator it = p.begin(); it != p.end(); ++it) { … … 73 73 ++node_cnt; 74 74 } 75 75 76 76 return (node_cnt == gr.nodeNum()); 77 77 } … … 80 80 bool checkTourPath(const FullGraph &gr, const Path<FullGraph> &p) { 81 81 FullGraph::NodeMap<bool> used(gr, false); 82 82 83 83 if (!checkPath(gr, p)) return false; 84 84 if (gr.nodeNum() <= 1 && p.length() != 0) return false; … … 182 182 } 183 183 } 184 184 185 185 check(alg.run() > 0, alg_name + ": Wrong total cost"); 186 186 … … 196 196 check(checkCost(g, path, cost, alg.tourCost()), 197 197 alg_name + ": Wrong tour cost"); 198 198 199 199 check(!Tolerance<double>().less(alg.tourCost(), opt2.run(alg.tourNodes())), 200 200 "2-opt improvement: Wrong total cost"); … … 203 203 check(checkCost(g, opt2.tourNodes(), cost, opt2.tourCost()), 204 204 "2-opt improvement: Wrong tour cost"); 205 205 206 206 check(!Tolerance<double>().less(alg.tourCost(), opt2.run(path)), 207 207 "2-opt improvement: Wrong total cost"); … … 213 213 } 214 214 215 // Algorithm class for Nearest Insertion 215 // Algorithm class for Nearest Insertion 216 216 template <typename CM> 217 217 class NearestInsertionTsp : public InsertionTsp<CM> { … … 224 224 }; 225 225 226 // Algorithm class for Farthest Insertion 226 // Algorithm class for Farthest Insertion 227 227 template <typename CM> 228 228 class FarthestInsertionTsp : public InsertionTsp<CM> { … … 235 235 }; 236 236 237 // Algorithm class for Cheapest Insertion 237 // Algorithm class for Cheapest Insertion 238 238 template <typename CM> 239 239 class CheapestInsertionTsp : public InsertionTsp<CM> { … … 246 246 }; 247 247 248 // Algorithm class for Random Insertion 248 // Algorithm class for Random Insertion 249 249 template <typename CM> 250 250 class RandomInsertionTsp : public InsertionTsp<CM> {
Note: See TracChangeset
for help on using the changeset viewer.