Code Monkey home page Code Monkey logo

angel3245 / ga-and-pso-analysis Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 115.51 MB

This project involves the analysis and comparison of Genetic Algorithm (GA) and Particle Swarm Optimization (PSO) for minimizing mathematical functions and solving the Traveling Salesman Problem (TSP) using the scikit-opt library. Both GA and PSO are popular metaheuristic algorithms used for optimization problems.

License: GNU General Public License v3.0

Jupyter Notebook 100.00%
educational-project evolutionary-algorithms genetic-algorithm particle-swarm-optimization

ga-and-pso-analysis's Introduction

Genetic Algorithm and Particle Swarm Optimization using scikit-opt

This project involves the analysis and comparison of Genetic Algorithm (GA) and Particle Swarm Optimization (PSO) for minimizing mathematical functions and solving the Traveling Salesman Problem (TSP) using the scikit-opt library. Both GA and PSO are popular metaheuristic algorithms used for optimization problems.

Dataset Description

For function minimization, we use a set of standard benchmark functions, such as:

  • Schaffer Function
  • Rosenbrock Function

For the TSP, we use a set of predefined cities with coordinates to define the distances between them.

Methodologies

Genetic Algorithm (GA)

GA is an evolutionary algorithm that simulates the process of natural selection. It operates through:

  • Initialization: Randomly generating an initial population of solutions.
  • Selection: Selecting the fittest individuals for reproduction.
  • Crossover: Combining pairs of individuals to produce offspring.
  • Mutation: Introducing random changes to individuals to maintain genetic diversity.
  • Iteration: Repeating the selection, crossover, and mutation processes over several generations to evolve better solutions.

Particle Swarm Optimization (PSO)

PSO is a population-based optimization technique inspired by the social behavior of birds. It involves:

  • Initialization: Generating a swarm of particles with random positions and velocities.
  • Update: Updating the velocities and positions of particles based on their own best-known positions and the best-known positions of their neighbors.
  • Iteration: Iteratively adjusting particle positions to explore the search space and converge towards optimal solutions.

Function Minimization

The function minimization involves:

  • Defining benchmark functions: Implementing standard functions to be minimized.
  • Applying GA and PSO: Using scikit-opt to optimize the benchmark functions.
  • Evaluating performance: Comparing the algorithms based on solution accuracy and convergence speed.

Traveling Salesman Problem (TSP)

The TSP solution involves:

  • Defining the TSP instance: Using a predefined set of cities with known distances.
  • Applying GA and PSO: Using scikit-opt to find the shortest possible route that visits each city exactly once and returns to the starting point.
  • Evaluating performance: Comparing the algorithms based on the quality of the routes and computational efficiency.

Evaluation

The evaluation process includes:

  • Performance metrics: Evaluating the algorithms using metrics such as best solution found, average solution quality, and computational time.
  • Visualizations: Plotting convergence curves and solution paths for TSP to visualize the performance of the algorithms.

Dependencies

The main libraries used in this project include:

  • Scikit-opt
  • PyTorch
  • Scipy
  • NumPy
  • Matplotlib
  • Optuna

ga-and-pso-analysis's People

Contributors

angel3245 avatar

Stargazers

 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.