GenEvo 4 Competition

GenEvo 4 Competition preview image

1 collaborator

My_photo_2 Sugat Dabholkar (Author)


(This model has yet to be categorized with any tags)
Part of project 'GenEvo Curriculum'
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0-BETA1 • Viewed 196 times • Downloaded 9 times • Run 0 times
Download the 'GenEvo 4 Competition' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


This is a population model of competition between cells in a population of asexually reproducing bacteria E. coli for resources in an environment. Users can experiment with various parameters to learn more about two different mechanisms of evolution: natural selection and genetic drift.


Using the LevelSpace extension of NetLogo, each cell in this population model is actually controlled by a genetic switch model (just like _GenEvo 1_). In LevelSpace terminology, this population model is called a _parent model_ and each cell is a _child model_. However, in this info section, we will call this model the _population model_ and each background genetic switch model a _cell model_.

Depending on the selected options, each cell model begins with a different set of initial parameters. Then, each cell model simulates the DNA-Protein interactions in the lac-operon of E. coli (check out the _GenEvo 1_ model for a refresher). In the population model, we see the competition for resources between these cells.

When a cell's energy level doubles from its initial level, the cell produces two daughter cells that inherit the cell's genetic and epigenetic information. The cells with a 'fitter' genetic circuit turn their switch on and off faster, resulting in a faster increase in the energy levels, and a faster growth rate.

Because the molecular interactions in each cell model are stochastic, the population model displays the effects of both natural and statistical selection (genetic drift).


### To Setup

You can use this model in two ways.

1. The simplest way to use this model is to set CHOOSE-MODELS? to OFF. In this mode, the default Genetic Switch model is created for each cell. This method simulates genetic drift as a mechanism of evolution since each cell starts off identical.

2. If CHOOSE-MODELS? is ON, a user can manually select the NetLogo models (`.nlogo` files) to be used for each cell, allowing each cell to have a different genetic switch. This allows for variability in the population. This method simulates natural selection as well as genetic drift.

In both ways, the SETUP button sets up the population of E. coli cells (each type represented by a unique color) and randomly distributes them across the world.

### To run

After you setup the model, set the environmental conditions by setting LACTOSE? and GLUCOSE? to ON or OFF.

Click GO to run the population model (and consequently, the cell models) for around 300 ticks. Click GO again to pause the model. Click INSPECT CELLS and click on any cell to see the cell model behind it. Close the individual cell models (Always select 'run in the background' option when closing individual models). Click GO to run the model again.

Change the environmental conditions using the LACTOSE? and GLUCOSE? switches and observe the different behaviors of population. (Note: You have to run the model for a few hundred ticks in order to observe cellular behavior.)

### Buttons

SETUP - Sets up the population model and cell models

GO - Makes the simulation in the population model (and consequently the cell models) begin to tick

INSPECT-CELLS - This button allows you to inspect the cell model of any cell in the population model. Click the button first and then click on a cell to see its cell model. When you close an individual cell model, always select the 'run in the background' option.

### Switches

LACTOSE? - If ON, lactose is added to the external environment and equally distributed among the cell models. This means that the more the cells, the less lactose each cell gets. In other words, this is how we model carrying capacity.

GLUCOSE? - If ON, glucose is added to the external environment. Transport and digestion of glucose is not explicitly modeled, however since glucose is a _preferred sugar_, when glucose is present the _lac promoter_ in the Genetic Switch model is inactive. In addition, when glucose is present, the energy of each cell increases with a constant rate (10 units per tick).

### Sliders

INITIAL-NUMBER-OF-CELLS – This is the initial number of cells in the population model. If CHOOSE-MODELS? is ON, this also corresponds to the number of Genetic Switch models the user has to select.


Notice the reproduction of cells as the time progresses. Notice how each cell model behaves with different sugar conditions.

Run the model for a few thousand ticks to see which cell type wins. Notice the cellular behavior of the Genetic Switch in the different types of cells by using the INSPECT CELLS button. Run the simulation several times with the same set of cell models to distinguish between the roles of natural selection and genetic drift. If natural selection is a stronger mechanism for evolution in a given set of cell models, then the same trait will win more frequently.


See if you can make the background color of the view scale with how much lactose and glucose are in the medium.


See if you can modify the model to model the effect of glucose explicitly by introducing the requisite proteins.


This model uses the LevelSpace extension to allow each cell to have its own genetic switch model controlling the protein interactions within.


* GenDrift Sample Models

* GenEvo Curricular Models


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

* Dabholkar, S. and Wilensky, U. (2016). NetLogo GenEvo 4 Competition model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Please cite the NetLogo software as:

* Wilensky, U. (1999). NetLogo. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

To cite the GenEvo Systems Biology curriculum as a whole, please use:

* Dabholkar, S. & Wilensky, U. (2016). GenEvo Systems Biology curriculum. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.


Copyright 2016 Uri Wilensky.

![CC BY-NC-SA 3.0](

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

extensions [ ls cf ]

globals [
  ; These are constant variables used to specify simulation restrictions
  global-lactose-limit         ; variable to specify lactose quantity
  initial-energy               ; variable to specify initial energy of bacterial cells
  old-models-list                  ; list of ls:models to identify newly created model

breed [ ecolis ecoli ]

ecolis-own [
  my-model              ; cell model (LevelSpace child model) associated with an E. coli cell
  my-model-path         ; path to locate the file to be used for creating a cell model (LevelSpace child model)

  ; these variables are used to store the corresponding statistics from the cell models
  energy                ; energy of the cell
  lactose-inside        ; lactose quantity inside a cell
  lactose-outside       ; lactose quantity in the outside environment
  lacZ-inside           ; lacZ proteins inside a cell
  lacY-inside           ; lacY proteins inside a cell
  lacY-inserted         ; lacY proteins inserted into the cell-wall
  lacI-lactose-complex  ; lacI-lactose-complex molecules inside a cell

;;;;;;;;;;;;; SETUP PROCEDURES ;;;;;;;;;;;;;

to setup
  ; set the constant values
  set initial-energy 1000
  set global-lactose-limit (initial-number-of-cells * 5000)
  generate-cells ; create the cells
  if lactose? [ distribute-lactose ] ; distribute lactose if the option is selected

; procedure to generate E. coli cells. If choose-models is OFF, default cell model is created for all the cells.

to generate-cells
  let color-list [ gray red brown yellow green cyan violet magenta ]

  let i 0
  create-ecolis initial-number-of-cells [
    set color (item i color-list)
    setxy random-xcor random-ycor
    set shape "ecoli"

    ifelse choose-models? [
      user-message "Select a Genetic Switch model to use..."
      set my-model-path user-file
      set my-model-path "GenEvo 1 Genetic Switch.nlogo"

    while [ test-if-switch my-model ] [
      user-message "The model must be a Genetic Switch model! Please select a Genetic Switch model again."
      ls:close my-model
      set my-model-path user-file
    set i i + 1

to create-my-model ; turtle procedure
  ; If my-model-path is False, it means the user didn't select a file.
  ; In that case, we kill the E. coli so we this doesn't mess anything up.
  ifelse my-model-path != False [
    ls:create-interactive-models 1 my-model-path
    set my-model max ls:models
    ls:hide my-model

    ls:let initial-variables-list generate-initial-variables-list
    ls:ask my-model [
      set-initial-variables initial-variables-list
  [ die ]

;;;;;;;;;;;;; RUNTIME PROCEDURES ;;;;;;;;;;;;;;

to go
  ask ecolis [
    rt random-float 360
    fd 1
    if energy < 0 [
      ls:close my-model
  if not any? ecolis [ stop ]

; Updates the enviornmental conditions and then runs each cell model

to run-your-model ; turtle procedure
   ls:let lactose-outside-per-cell ifelse-value lactose? [ floor ( global-lactose-limit / length ls:models ) ] [ 0 ]
   ls:let parent-glucose? glucose?
   ls:let parent-lactose? lactose?

   ls:ask my-model [
     set glucose? parent-glucose?
     set lactose? parent-lactose?

; when lactose? is OFF, this procedure is used to update the lactose quantity in the environment in the population model

to distribute-lactose
  ifelse lactose? [
    ls:let lactose-per-model (global-lactose-limit / length ls:models)
    ask patches [ set pcolor 2 ]
    ask ecolis [ ls:ask my-model [ update-lactose lactose-per-model ] ]
    ; see how much lactose is outside all of the cells
    let total-lactose-outside sum [ count lactoses with [ not inside? ] ] ls:of ls:models

    cf:when ; color the patches based on the global lactose amount
    cf:case [ total-lactose-outside < (global-lactose-limit / 2) ] [ ask patches [ set pcolor 1 ]]
    cf:case [ total-lactose-outside = 0 ] [ ask patches [ set pcolor 0 ] ]
    cf:else [ ask patches [ set pcolor 2 ] ]

    ls:let lactose-per-model (total-lactose-outside / length ls:models)
    ask ecolis [ ls:ask my-model [ update-lactose lactose-per-model ] ]

; procedure for E. coli cells to reproduce. A new cell is added in the population model and a new individual cell model is created.

to maybe-reproduce
  ; if there's enough energy, reproduce
  if ( [ energy ] ls:of my-model > 2 * initial-energy ) [
    ls:ask my-model [ divide-cell ]
    hatch 1 [
      rt random-float 360 fd 1 ; move it forward so they don't overlap
      create-my-model  ; Now create and setup the cell model that will simulate this new daughter cell

; procedure to concatenate all the necessary initial variables for a daughter cell model into a single list

to-report generate-initial-variables-list ; turtle procedure
  report (list color initial-energy lacY-inside lacY-inserted lacZ-inside lacI-lactose-complex lactose-inside lactose-outside lactose? glucose?)

; Extract all the necessary variables from the cell model

to extract-cell-model-variables ; turtle procedure

  let list-of-variables ([ send-variables-list ] ls:of my-model) ; grab the list

  ; now save the elements in our 'ecolis-own' variables
  set energy item 0 list-of-variables
  set lacY-inside item 1 list-of-variables
  set lacY-inserted item 2 list-of-variables
  set lacZ-inside item 3 list-of-variables
  set lacI-lactose-complex item 4 list-of-variables
  set lactose-inside item 5 list-of-variables
  set lactose-outside item 6 list-of-variables

; procedure to view the cell model (LevelSpace child model) associated with each cell

to inspect-cells
  if mouse-inside? and mouse-down? [
    ask ecolis with-min [ distancexy mouse-xcor mouse-ycor ] [
      ls:show my-model

; procedure to test whether or not a model is a Genetic Switch model

to-report test-if-switch [ a-model-number ]
  let return-value False
  carefully [
    ls:ask a-model-number [ set LevelSpace? True ]
     set return-value True
  report return-value

; Copyright 2016 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created over 2 years ago by Sugat Dabholkar.

Attached files

File Type Description Last updated
GenEvo 4 Competition.png preview Preview for 'GenEvo 4 Competition' over 2 years ago, by Sugat Dabholkar Download

This model does not have any ancestors.

This model does not have any descendants.