Giter Club home page Giter Club logo

ant_system's Introduction

ANT_SYSTEM

Overview

This program is an implementation of ant_system model, a cellular automaton that simulates the behavior of an ant colony in search of food with use of MPI, is a communication protocol for computers..

In the initial state there is a number of ants located at a point of origin, called a nest. Ants start to move in a random way until one of them find the food.

Once the food is found the ant returns towards the nest releasing a substance called pheromone during the journey. The remains ants

The remaining ants will be attracted to this pheromone and move towards it. In this way they will be able to find food easily and return to the nest. The greater the number of neighboring ants that propagate pheromone the greater the distance it will expand.

Implementation technologies

There are provided both sequential and parallel implementation of the Cellular Automata, and both of them was developed by using the C++

GUI was implemented with ALLEGRO library.

Parallel implementation

The parallel implementation consists in a separation of problem in n sub_problem each of which is assigned to a different process.

The division was carried out in rows, dividing the matrix by mirroring the world equally between the processes.

Each process will manage the updating of the elements present in the competence line, or the cells (with the value of the pheromone) and the ants.

Every Process receive informations about cells and ants from the process next to him, both right and left. This is due to the fact that every process to manage the ants that are near the edges needs to know the data of the edges on its left and on its right. Since we are not facing a problem with the toroidal world, the first process will send exclusively to the one on its right, while the process to the left only.

Details of implementation

At beginning the process 0 initiliazate GUI, with source and food location.

Every Process must manage:

  1. A vector of ants in its portion
    • move them randomly if they haven't food
    • move them in direction of source if they have food
    • expand pheromone in a neighborhood starting from its position
  2. A vector of cells in its portion
  3. The expansion of pheromone in its portion
  4. Send to its neighbours the ants that leave its portions of matrix
  5. Receive from its neighbours
  6. Send to Process 0 all data for gui display

Le comunicazioni avvengono tramite l'ausilio di 3 datatype:

  1. MPI_Datatype (MPI_STRUCT) ant_mpi: to send and receive the ants that leave or enter in a process
  2. MPI_Datatype (MPI_Type_contiguous) single_row_to_send_mpi: to send a single row of matrix to the limiting process)
  3. MPI_Datatype (MPI_Type_contiguous) all_data_row: to send all sub_matrix to process 0 for gui.

GUI implementation

The gui was implemented with Allegro, a a cross-platform library. The implementation is very simple, each cell is colored based on the amount of pheromone in it:

  1. The higher the pheromone, the higher the shade of red
  2. The lower it is the less it's red.
  3. The food cell is colored green
  4. The source cell is colored blue
  5. Every cell with an ant without food is colored black
  6. Every cell with an ant with food is colored yellow

Results (ONE PROCESS VS MORE)

How we know a mpi process behavior change in relation of machine, the machine used for the test was a 8 GB RAM with Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz.

Technologies

ant_system's People

Contributors

gb1609 avatar

Watchers

James Cloos 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.