Git Product home page Git Product logo

population_models's Introduction

Population Models

This repo contains the scripts to simulate a population model of 3 species with 3 different methods:

  1. Using a deterministic ODE solver
  2. Using an stochastic method (Gillespie Algorithm)
  3. Using a agent based approach

System model

The ODE system is:

equation_system

The system models a food chain as follows:

The food chain begins with the plant. The plant is eaten by the rabbit. The rabbit is then eaten by a larger animal, the fox.

Being G the amount of grass, R the number of rabbits, and F the number of foxes. The deltas are the death rates of each specie according to their subindex....

Cellular Automata

The algorith for the Cellular Automata (C.A.) is as follows:

FOR T steps

FOR j individuals in the population list P

choose a random neighbor i

IF j=prey and i=empty

j reproduce with probability r

ELSEIF j=predator 1 and i=empty

j move with probability m_r

ELSEIF j=predator 1 and i=prey

j eats i with probability e_r and i becomes of the type j

ELSEIF j=predator 1 and i=predator 2

j dies with probability d_r

ELSEIF j=predator 2 and i=empty

j move with probability m_f

ELSEIF j=predator 2 and i=predator 1

j eats $i$ with probability e_f and i becomes of the type j

ELSEIF j=predator 2 and i=predator 2

j dies with probability d_f

ENDFOR

ENDFOR

The scripts are organized in the next way: prey_pred_2.m contains the ODE system stated above. Model_Lotka_analytic.m solves the model using a ode45 solver. lotca_stochastic_3species.m solves the Lotka-Volterra model using Gillespie Algorithm, The simulation depends on the parameters size, alpha, beta_gr, beta_r, gamma_r, gamma_f, delta_r, delta_f, k_g, k_r, s_f and s_r as stated in the equation system, and the initial populations: g0, r0 and f0 which can be changed in the files Model_Lotka_analytic.m and lotca_stochastic_3species.m.

2species_CA.pywill simulate the system as a Cellular Automata as stated above. It will create a file with 4 columns indicating

Simulation Step Population G Population F Population R

The initial populations can be changed in the lines

spec1_i=XXX #grass
spec2_i=XXX #rabbit
spec3_i=XXX #foxes

If there are several simulations which were run under the same conditions you can plot all of them in a single graph by using plot_data.m you just need to change the line

name='results/XXXXXX_';

being XXXXX the base name of the simulatons you want to plot

If you want to change the ODE system to your own you can do it by modifying the fifle prey_pred_2.m

1. Determinisit Results

result_1 result_2

result_3 result_4

2. Stochastic Results

results_5 results_6

results_7 results_8

results_9 results_10

3. C.A. Results

ca_results_1 ca_results_2 ca_results_3 ca_results_4 ca_results_5

population_models's People

Contributors

j-lazo 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.