Giter VIP home page Giter VIP logo

ga_competition's Introduction

MTSP: Genetic algorithm implementation

Introduction

The Multiple Traveling Salesman Problem is an extension of the classic Traveling Salesman Problem, which seeks to find the shortest possible route that visits each city in a given set and returns to the starting city. In the MTSP, there are multiple salesmen who start from a central depot, visit a subset of cities, and return to the depot. The goal is to minimize the total distance traveled by all salesmen while ensuring that every city is visited exactly once. Genetic Algorithms are a type of optimization technique inspired by natural selection and evolution. They work by creating a population of candidate solutions, evaluating their fitness, selecting the fittest individuals, and applying genetic operators such as crossover and mutation to generate new offspring. This process repeats until a satisfactory solution is found or a predetermined number of generations have been produced. In this implementation we have developed a GA in order to face this problem and see how it performs.

Implementation

Please refer to the pdf in order to read our full implementation.

Usage

git clone https://github.com/pepe-olivert/GA_competition.git

Once you have it downloaded just execute GA.py and check it out!

Add into your GA.py the following code in order to make it run:

if __name__ == '__main__':
    a = GA(time_deadline=180,problem_path='instances/instance1.txt')
    try:print(a.run(),1/a.best_fitness)
    except:print(a.get_best_solution(),1/a.best_fitness)

And then just execute it:

python3 GA.py

Please note: Make sure to have python installed in your machine.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

ga_competition's People

Contributors

pepe-olivert avatar albamrtnz avatar psanchezml avatar hugoalb avatar hugoalbertbonet 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.