×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

C++ source code for TSP 最短路径算法

Recently, the best way for solving such kind of NP-complete problem as
Traveling Salesman Problem (TSP), is to use Meta-heuristics such as Simulated Annealing (SA), Genetic Algorithms (GA), and other heuristic algorithms, or a combination of them. In my opinion, the main difference of the algorithms is efficiency (speed), not effectiveness (quality) of the solutions. So if speed is not your major concern (e.g not many cities), anyone of them will do the job very well. Some special cases of the TSP are not NP-hard problem, and therefore can be solved by an simple exact method.

The most effective and simple algorithm was done by LK back in 1973:

Lin, S. and Kernighan, B.W. An effective heuristic for the traveling-salesman problem. Oper. Res. 21 (1973)

Some C/C++ source code are listed in the following links:

http://www.lalena.com/ai/tsp/
http://www.netlib.org/c/numcomp-free-c
Report

Replies, comments and Discussions:

  • 枫下家园 / 电脑用户 / 请教会C++的大侠:在哪可以找到有名的关于推销员推销产品,走最短路线的问题的code?非常感谢
    • 好像router的最短路径算法比较类似
    • 你是不是指TSP(traveling salesman problem)? If yes, then forget it because it is NP-hard.
    • C++ source code for TSP 最短路径算法
      Recently, the best way for solving such kind of NP-complete problem as
      Traveling Salesman Problem (TSP), is to use Meta-heuristics such as Simulated Annealing (SA), Genetic Algorithms (GA), and other heuristic algorithms, or a combination of them. In my opinion, the main difference of the algorithms is efficiency (speed), not effectiveness (quality) of the solutions. So if speed is not your major concern (e.g not many cities), anyone of them will do the job very well. Some special cases of the TSP are not NP-hard problem, and therefore can be solved by an simple exact method.

      The most effective and simple algorithm was done by LK back in 1973:

      Lin, S. and Kernighan, B.W. An effective heuristic for the traveling-salesman problem. Oper. Res. 21 (1973)

      Some C/C++ source code are listed in the following links:

      http://www.lalena.com/ai/tsp/
      http://www.netlib.org/c/numcomp-free-c