Coder Social home page Coder Social logo

ga-tsp's Introduction

GA-TSP

GA(遗传算法)求解TSP(旅行商)问题,可随机坐标,可读取文件,可求解**省会城市坐标(1081.png明显还可以优化辽宁-吉林-黑龙江-北京这样应该就是最优了)

实际上代码运行时给出的可以修改的参数中,只有每多少代显示一次和显示时间这两个参数可以修改 其他修改了都没用(后续有待我继续完善好吧 如果想要读取city_info文件, 务必务必记得: 1.严格按照格式要求储存坐标信息,比如

{"朝鲜": [125.30,39.09],
"加拿大": [-75.42,45.27], 巴拉巴拉... "**": [116.20,39.55] } 最后千万注意没有','

2.记住自己存了多少个坐标进去,在运行前先去config文件里面修改城市数量city_num,不然就会报错 我也不知道为啥不能改 好像是涉及到循环调用函数还是什么的? 说实话我感觉不如把函数和主程序写一个文件里面,这样应该就不会报错了吧? 可惜我没耐心了不想继续改了

代码实现了四个主要功能:

  1. 随机生成一定数量的城市坐标,并采用遗传算法求解TSP问题。这验证了遗传算法求解TSP问题的可行性。
  2. 求解**省会城市坐标的TSP问题。这是一个较为实际的应用实例,验证了遗传算法在真实问题上的求解能力。
  3. 提供TSP问题接口,通过读取City坐标文件,采用遗传算法求解相应的TSP问题。这使得该遗传算法具有较强的通用性,可扩展到更大规模和不同格式的TSP问题。
  4. 设置路径长度阈值并重复运行遗传算法以找到满意解。通过设定路径长度标准并重复运行减小随机影响提高结果可靠性。

有问题有建议都欢迎向我提出来,谢谢

ga-tsp's People

Contributors

jboubb avatar

Stargazers

Jason Xiao avatar Minavaer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.