Coder Social home page Coder Social logo

fish_abm's Introduction

fish abm

Agent based model for simulating movement of fish schools.

Image 1: First visualization of the agent based model without environment

Image 2: First visualization of the agent based model with environment

int main():

  • create Mat environment & Mat fish

  • create_environment()

  • individuals fish

  • initialize()

    void sample():

    • counting individuals in_zone(r = 15),in_zone(r = 100) and in_zone(r = 200)

      1. when alone lag is decreased [-1] and individual moves to group
      2. if sample_rate > distrib_sample(rd) (random number) lag is set to [5] and individual feeds. This implements that individuals by chance will sample more frequently in a "good" food patch
      3. else, if lag is 0, sample_rate increases [+1]
      4. else, lag is reduced [-1] and sample_rate increases [+1]

    void feed():

    • sample_rate = 10 * q (q being the quality in the quality box encountered)
    • reduce quality of quality box encountered (feeding)

    void move():

    • the direction angle is corrected back between 0 - 360 degrees and the individual moves in this direction

      1. if lag == 0 new direction is calculated dependent on the social force experienced and an added random error of +-10 degrees; Distance traveled depends on the speed_factor (see: double get_speed)Movement can occur across window boundaries.
      2. else, new direction is previous direction with added random error but without social force dependency

    double social():

    • social response is calculated base on the absence or presence of other individuals in_zone(15),in_zone(100) and in_zone(200) and new direction calculated using averageturn()

      1. if the other individuals are within front field of view (330 degrees / 2) and comfort zone (15) focal individual can express:

      2. avoidance (left/right or directly in front) [weight function (1 / ( 0.1 * pow((dist),2) + 2 ))]

      3. if the other individuals are within front field of view (330 degrees / 2) and alignment distance (100) focal individual can express:

      4. alignment to closest neighbor [weight function ((1 / ( 0.004 * pow((dist-15),2) + 2 ))]

      5. if the other individuals are within front field of view (330 degrees / 2) and distance (200) focal individual can express:

      6. attraction to closest neighbor [weight function (1 / ( 0.004 * pow(( dist-200),2) + 2 ))]

      7. alignment to closest neighbor [weight function ((1 / ( 0.004 * pow((dist-15),2) + 2 ))]

    double get_speed():

    • the speed_factor [default=1] is calculated using the individuals in the front visual field (the number of individuals in front (-90,+90 degrees from head tail axis)) and the response radius of 100: speed_factor = 1 + ind_count divided by N/2 (N: Total Population). The more individuals are perceived ahead, the faster the individual will travel.

    Image 2: Social force heat-map

    All visualization was done using OpenCV2 v. 2.4.13 in C++.

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.