Skip to content

A Python implementation of a Genetic Algorithm (GA) to solve the Quadratic Assignment Problem (QAP), demonstrating the use of metaheuristic optimization for facility–location assignments. Includes live convergence plotting and an optional Turtle/Tkinter visualization of final solutions.

Notifications You must be signed in to change notification settings

plainsight16/GA-QAP

Repository files navigation

Genetic Algorithm for the Quadratic Assignment Problem (QAP)

This project implements a Genetic Algorithm (GA) to solve the Quadratic Assignment Problem (QAP).
It includes both a matplotlib convergence plot and a turtle-based visualizer for the best solution.


Setup Instructions

  1. Clone this repository:
    git clone https://github.com/plainsight16/GA-QAP.git
    cd GA-QAP
    
  2. Create and activate a virtual environment:
    python3 -m venv venv
    source venv/bin/activate    # On macOS/Linux
    venv\Scripts\activate       # On Windows
  3. Install dependencies:
    pip install -r requirements.txt
  4. Run main.py
    python Main.py
    

Sample View

Results

Graph of Best fitness score vs Avg fitness score

This plot shows how the best and average fitness scores evolve across generations.

Simulation of the Best Solution

The turtle visualizer simulates the best assignment solution by drawing facilities and connections.

Legend(how to read)

Red color of line means long distance, green one - short Thick line means big value of flow (aka cost), thin one - small Both values are in context of particular distance and flow matrices

In short: thin green is better than thick red

About

A Python implementation of a Genetic Algorithm (GA) to solve the Quadratic Assignment Problem (QAP), demonstrating the use of metaheuristic optimization for facility–location assignments. Includes live convergence plotting and an optional Turtle/Tkinter visualization of final solutions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages