Echo

Echo preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

biology 

Tagged by Reuven M. Lerner over 11 years ago

evolution 

Tagged by Reuven M. Lerner over 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 699 times • Downloaded 85 times • Run 4 times
Download the 'Echo' modelDownload this modelEmbed this model

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


WHAT IS IT?

Echo is a model about the evolution of fitness, adapted from John Holland's book Hidden Order (1995). It can be used to facilitate experiments in a variety of domains where an agent's fitness varies with its context. This particular adaptation of Echo has a biological flavor and refers to the agents as "creatures", and groups of agents with identical mating preferences as "species."

With Echo, Holland attempted to codify intuitions about complex adaptive systems into a more rigorous and abstract model. Holland was inspired by notions from ecological systems research, especially with regards to the dynamics of niches. How does a change in the population dynamics of an ecosystem create new niches and destroy old ones? Echo was an attempt to create an abstract model that could facilitate understanding of the interplay of evolutionary and ecological processes. In Echo, different niches are created where creatures can consume, transform, and exchange resources, but this model is not necessarily just a biological model --- it can also be viewed as a model of other phenomena like the emergence of new markets.

It should be noted that Echo as laid out in Hidden Order is not meant to be a specific model, but rather a framework for building models. There are a number of mechanisms that are not fully specified in Hidden Order and the description includes multiple different mechanisms that can be implemented. As a result, there is no model which is "the Echo model" there can only be "an Echo model." This NetLogo Echo model is one particular instantiation of this framework.

HOW IT WORKS

Each agent, or creature, has two components -- a reservoir to keep resources it collects, and a chromosome that contains its genetic material and defines its capabilities.

A creature expends resources moving around the world looking for resources. A creature can gain resources either directly from its environment, or from another creature at its current location.

The amount of resources gained from its environment depends on the amount of available resources and the number of other creatures at its current location.

The amount of resources gained from another creature depends on the match between the creatures' chromosomes. More precisely, a creature's chromosome is compromised of three "tags" --- an offense tag, a defense tag, and a mating condition tag -- which are represented by strings of "a's", "b's" and "c's". The amount transferred from one creature to another depends on how closely the first creature's offense tag matches the second creature's defense tag. However, all interactions, or "fights", between creatures are two-way exchanges --- i.e., both agents match their offense tags to the other's defense tag. Consequently, resources can be either gained or lost on any given interaction with another agent. For example, offense tag "aaa" of creature 1 to defense tag "aaa" of creature 2 would be a perfect match. It would entitle creature 1 to all of creature 2 resources, but the second creature could possibly get some, or even all of the resources back based on the match of his offense tag to the other agent's defense tag.

If an agent's resource level drops below a minimum threshold, it dies.

An agent can reproduce only if it has acquired a minimum level of resources. Reproduction occurs in two ways: 1) simple replication, as determined by the REPLICATE-CHANCE slider, in which case the replicated agent is identical to the parent, and 2) mating with other agents. By default, an agent can mate with any other agent, resulting in an offspring that contains a mixed set of elements, or a "cross", of both parent's chromosomes. If the SELECTIVE-MATING? switch is enabled, an agent will not mate with just anyone, but instead only mate with agents whose offense tags match its own mating condition tag. The similarity between the mating tag and offense tag necessary for a match to occur is determined by the MATING-SELECTIVITY slider. With either process, it is possible that the characteristics of offspring are not an exact copy or cross of the parent's chromosomes. Mutations can occur at a rate determined by the MUTATION-RATE slider.

HOW TO USE IT

Click the SETUP button to setup the world, then click the GO button. The agents will begin to move, exchange resources, and reproduce. The sliders allow you to change each of the parameters of the model as described below. The plots provide an update on the composition of the populations of agents.

The agents are colored by mating tags. Identical mating tags share the same color; mating tags that are close are similar in color; and so on. Each creature has its offense and defense tags as its label in the format "offense-tag.defense-tag". For example, a label of "aab.bcc" represents a creature with an offense tag of "aab" and defense tag of "bcc."

The model includes the following parameters:

NUM-CREATURES --- The number of agents with which to start the simulation.

REPLENISH-SPEED --- The speed at which the resources in the environment replenish.

REPLICATE-CHANCE --- The chance that a creature with sufficient energy will replicate.

SELECTIVE-MATING? --- If 'Off' it is possible for agents to mate with any other agent that has enough energy to reproduce. If 'On' agents will only mate with other agents whose offense tag matches their own mating tag.

MATING-SELECTIVITY? --- Determines how similar a mating tag and offense tag must be in order for two agents to mate. Higher, positive numbers are more selective. '0' is the midpoint.

MUTATION-RATE --- The rate at which a letter in the offense or defense tags of offspring may change during replication.

Here are descriptions of all the plots in the model:

"Offense Tags" --- A histogram of the number of each offense tag currently in existence.

"Defense Tags" --- A histogram of the number of each defense tag currently in existence.

"Species Counts" --- A histogram of the number of each species currently alive. A species is defined as a group of agents that share an identical mating tag.

"Populations" --- This shows the number of creatures in the two largest species currently in the world.

"Speciation" --- This shows the current total number of different species, the total number of different offense tags, and the total number of different defense tags in the world.

Some other options are described below in THINGS TO TRY.

THINGS TO NOTICE

Populations often become dynamically stable with several species at oscillating population levels.

Increasing the initial NUM-CREATURES slider does not necessarily result in a larger stable population, indeed the opposite may occur as creatures compete for limited resources.

THINGS TO TRY

Change REPLENISH-SPEED to examine the impact of making resources more scarce.

See what impact increasing or lowering the MUTATION-RATE and/or switching SELECTIVE-MATING? 'On' has on the number of species that ultimately survive in situation with dynamically stable populations.

EXTENDING THE MODEL

Add a mechanism that allows selective interaction for the exchange of resources, in addition to selective mating.

Resources could be more nuanced than the simple "energy" variable. Certain locations in the environment could give off certain resources. For example, every creature might need at least one "c" resource to live, but only certain wells might give resources of type "c". Furthermore, resources could be transformed. For example, one "a" and two "b's" could be turned into a "c" for some cost.

Currently the exchange of resources between two agents is a fight --- a zero-sum exchange. However, this interaction could be changed to an interaction where both parties can become better off --- a situation that resembles a trade more than a fight.

Holland describes several additional extensions in some detail in Chapter 3 of Hidden Order.

EXTENDING THE MODEL (CATERPILLAR-FLY-ANT)

Holland discusses an interesting example from nature that can be imitated in Echo -- the Caterpillar-Fly-Ant triangle. The triangle refers to the stable, triangular relation between the three different species: Species 1 -- Flies lay eggs on caterpillars and become prey through their larva. Species 2 -- Ants are aggressive predators on the flies, but not of caterpillars. Species 3 -- Caterpillars produce nectar on their skin which ants find very attractive. The more ants around a caterpillar the less likely it is to be attacked by a predatory fly. This can be represented in Echo with the following tags:

 ant - offense: aaa, defense: cb
 fly - offense: aab, defense: aaa
 caterpillar - offense: c, defense: aab

Notice that the ants' offense tag matches perfectly with the fly's defense tag, making it a perfect predatory on the fly. Likewise, the fly's offense tag matches perfectly on the caterpillar making it a perfect predator on the caterpillar. The ant consumes the nectar of the caterpillar but does not prey on the caterpillar; thus, the ant and caterpillar have tags that result in an exchange of resources.

Try replicating this scenario. You'll probably want to set SELECTIVE-MATING? to on and MATING-SELECTIVITY to a high value such as 5. Is it possible to achieve a stable relationship between the three species? (Are changes to the parameters and/or the rules of the model necessary...?)

To get you started, here's some code for creating a roughly equal number of the three species. (You may want to experiment with different initial proportions.) The mating tags are completely different, to discourage interspecies mating.

 create-turtles init-num-creatures
 [
   let choice random 3
   if choice = 0  ; ant
   [
     set offense ["a" "a" "a"]
     set defense ["c" "b"]
     set mating  ["a" "a" "a"]
   ]
   if choice = 1  ; fly
   [
     set offense ["a" "a" "b"]
     set defense ["a" "a" "a"]
     set mating  ["b" "b" "b"]
   ]
   if choice = 2  ; caterpillar
   [
     set offense ["c"]
     set defense ["a" "a" "b"]
     set mating  ["c" "c" "c"]
   ]
 ]

NETLOGO FEATURES

Tags are represented by lists of strings, so the code is heavily dependent on lists. map, reduce, and foreach are used to do list processing.

RELATED MODELS

Sample Models > Biology > Evolution > (entire section)
Sample Models > Biology > Rabbits Grass Weeds
Sample Models > Biology > Wolf Sheep Predation

CREDITS AND REFERENCES

Holland, J. (1995). Hidden Order: How Adaptation Builds Complexity. Addison-Wesley, Reading, Massachusetts.

HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

  • Wilensky, U. (2005). NetLogo Echo model. http://ccl.northwestern.edu/netlogo/models/Echo. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
  • Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

COPYRIGHT AND LICENSE

Copyright 2005 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 http://creativecommons.org/licenses/by-nc-sa/3.0/ 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 uri@northwestern.edu.

Comments and Questions

Click to Run Model

globals [
  energy-threshold    ;; minimum amount of energy needed by creatures to reproduce
  all-tags            ;; sorted list of all possible tags
]

patches-own [
  well      ;; the amount of resources a patch has
  max-well  ;; the max amount of resources for that patch
]

turtles-own [
  energy    ;; current resource level
  offense   ;; offense tag
  defense   ;; defense tag
  mating    ;; mating tag (can be thought of as identifying a species)
]

to setup
  clear-all
  set energy-threshold 100
  setup-all-tags-list
  setup-patches
  setup-creatures
  reset-ticks
end 

;; Creates a list of all possible tags (of length 1, 2, or 3)

to setup-all-tags-list
  set all-tags []
  let tag-elements ["a" "b" "c"]
  foreach tag-elements
  [
    let i ?
    set all-tags lput (list ?) all-tags
    foreach tag-elements [
      let j ?
      set all-tags fput (list i ?) all-tags
      foreach tag-elements
        [ set all-tags fput (list i j ?) all-tags ]
    ]
  ]
end 

to setup-patches
  ask patches [
    set max-well random 50
    set well max-well
    recolor-patch
  ]
end 

to setup-creatures
  create-turtles init-num-creatures
  [
    setxy random-xcor random-ycor
    set offense one-of all-tags
    set defense one-of all-tags
    set mating one-of all-tags
    set size 0.5   ;; since the patch size is so big make the turtles smaller
    set energy random energy-threshold
    recolor-turtle
  ]
end 

to recolor-turtle  ;; turtle procedure
  set color tag-color mating
  set label reduce [word ?1 ?2] (sentence offense "." defense)
end 

to-report tag-color [tag]
  report 5 + 10 * position tag all-tags
end 

to recolor-patch  ;; patch procedure
   set pcolor scale-color green well 0 100
end 

to go
  if not any? turtles [ stop ]
  ask patches [ replenish ]
  ask turtles [ grab-resources ]
  ask turtles [ fight ]
  ask turtles [ reproduce ]
  ask turtles [ move ]
  ask turtles [ replicate ]
  ask patches [ recolor-patch ]
  tick
end 

to replenish  ;; patch procedure
  if well < max-well [
    set well well + ((max-well - well) * (replenish-speed / 100))
  ]
end 

;; Get resources from the environment, if you need them.  You don't fight for these,
;; but instead they are shared with other agents in the same location.

to grab-resources    ;; turtle procedure
  if (energy < energy-threshold) and (well > 0) [
    set energy energy + ( well / count turtles-here )
    set well well - ( well / count turtles-here )
  ]
end 

;; Try to get resources from another agent at your location.
;; This is done by comparing tags.
;; We compare id numbers to prevent the same pair from fighting
;; twice during the same tick.

to fight  ;; turtle procedure
  let candidates turtles-here with [self > myself]
  if any? candidates [ match-off-def self one-of candidates ]
end 

;; if there are any other agents at your location, reproduce with them
;; We compare id numbers to prevent the same pair from fighting
;; twice during the same tick.

to reproduce   ;; turtle procedure
  let candidates turtles-here with [self > myself]
  if any? candidates [ reproduce-match self one-of candidates ]
end 

to move  ;; turtle procedure
  set energy energy - 1
  ifelse energy < 20
    [ die ]
    [ rt random-normal 0 20
      fd random-float 1 ]
end 

to replicate   ;; creature procedure
  if energy > energy-threshold and random-float 100 < replicate-chance
  [
    set energy energy / 2  ;; give half of your energy to your offspring
    hatch 1
  ]
end 

;; Creates offspring from mating, including selective mating

to reproduce-match [agent1 agent2]
  if ( [energy] of agent1 > energy-threshold ) and
     ( [energy] of agent2 > energy-threshold )
  [
    if (not selective-mating?) or
        ( ( match-score [mating] of agent1 [offense] of agent2 > mating-selectivity ) and
          ( match-score [mating] of agent2 [offense] of agent1 > mating-selectivity ) )
    [
      hatch 1
      [
        set mating mutate cross [mating] of agent1 [mating] of agent2
        set offense mutate cross [offense] of agent1 [offense] of agent2
        set defense mutate cross [defense] of agent1 [defense] of agent2
        setxy random-xcor random-ycor
        set energy random-normal 50 20
        recolor-turtle
      ]
      ask agent1 [ set energy energy / 2 ]
      ask agent2 [ set energy energy / 2 ]
    ]
  ]
end 

;; This crosses tags during reproduction by walking through
;; each position of the string.  When the letters from each tag differ at a position
;; there is an equal chance of it being either one.  When the tags are different lengths,
;; the additional letters are just appended on to the tage of the offspring.

to-report cross [tag1 tag2]
  if length tag1 > length tag2
    [ report sentence cross sublist tag1 0 length tag2 tag2 sublist tag1 length tag2 length tag1 ]
  if length tag2 > length tag1
    [ report sentence cross tag1 sublist tag2 0 length tag1 sublist tag2 length tag1 length tag2 ]
  report (map [one-of (list ?1 ?2)] tag1 tag2)
end 

;; Mutates a given string

to-report mutate [tag]
  report map [ifelse-value (random-float 100 >= mutation-rate)
                [?] [one-of remove ? ["a" "b" "c"]]]
             tag
end 

;; This procedure determines how resources are transferred between
;; agents.  The offense tag of an agent1 is matched with the defense
;; tag of agent 2, and the offense tag of agent2 is matched with the
;; defense tag of agent1.

to match-off-def [agent1 agent2]

  ;; match respective offense and defense tags
  let a1a2 match-score [offense] of agent1  [defense] of agent2
  let a2a1 match-score [offense] of agent2  [defense] of agent1

  ;; scale resulting scores so that all values are positive
  set a1a2 a1a2 + 6
  set a2a1 a2a1 + 6

  ;; Determine how much resource is transferred between the agents.
  ;; Each agent takes from the other based on the relative magnitude
  ;; of its match score
  set a1a2 (a1a2 / 12) * ([energy] of agent2)
  set a2a1 (a2a1 / 12) * ([energy] of agent1)

  ;; You win some, you lose some.
  ask agent1 [ set energy energy + a1a2 - a2a1 ]
  ask agent2 [ set energy energy + a2a1 - a1a2 ]
end 

;; This reports a score that represents how well tag 1 matches tag 2.
;; The match takes places letter by letter -- the first
;; letters of each tag are compared, then the second letters, and so on.
;; An adjustment is made for unequal length tags.The resulting "match-score"
;; is ultimately used to help determine how resources are transferred between agents
;; or the extent to which a potential mate matches an agent's mating conditions

to-report match-score [tag1 tag2]
  if length tag1 > length tag2
    [ report (length tag2 - length tag1) + match-score sublist tag1 0 length tag2 tag2 ]
  if length tag2 > length tag1
    [ report (length tag1 - length tag2) + match-score tag1 sublist tag2 0 length tag1 ]
  report sum (map [ifelse-value (?1 = ?2) [2] [-2]] tag1 tag2)
end 


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

There are 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 12 years ago Updated version tag Download this version
Uri Wilensky about 12 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky almost 13 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 14 years ago Echo Download this version

Attached files

File Type Description Last updated
Echo.png preview Preview for 'Echo' over 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.