vinmaxx99 / parallel-aco-tsp

Ant colony optimization for TSP problem :ant:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

parallel-aco-tsp 🐜

Parallel Ant Colony Optimization (ACO) algorithm applied to the Traveller Salesman Problem (TSP).

What were parallelized?

  • The processing of ants was splited out into ant's chunks which are processed by the number of given processors.

Structure

.
β”œβ”€β”€ aco_parallel.py        # parallel version
β”œβ”€β”€ aco.py                 # sequential version
β”œβ”€β”€ datasets/              # input datasets
β”œβ”€β”€ main.py
β”œβ”€β”€ output/                # output of utils/scripts_{parallel,sequential}
β”œβ”€β”€ plot.py                # for plotting purpose
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
└── utils/
    β”œβ”€β”€ script_parallel    # get parallel execution time 
    └── script_sequential  # get sequential execution time

Requirements

  • Install openMPI
sudo apt install libopenmpi-dev python3-tk
  • Create a virtualenv
virtualenv aco-tsp
source aco-tsp/bin/activate
pip install -r requirements.txt

How to use?

For execution with 4 processes:

mpiexec -n 4 python main.py --parallel

To use the sequential algorithm instead, just run:

python main.py

About

Ant colony optimization for TSP problem :ant:


Languages

Language:Python 97.9%Language:Shell 2.1%