Strumenti Utente

Strumenti Sito


lcs:lcs08:esercitazioni:esercitazione1

Questa è una vecchia versione del documento!


Life and death in the ocean: fish and sharks (WATOR)

In questo esercizio realizziamo un semplice modello di andamento della popolazione acquatica studiato in ecologia.

The problem involves a simple model of population dynamics studied in ecology. This model became famous after it was presented in the Computer Recreations column of Scientific American [A. K. Dewdney, Sharks and fish wage an ecological war on the toroidal planet Wator, Scientific American, December 1984]. Wator is a toroidal (donut-shaped) planet, entirely covered by a warm ocean. The ocean is inhabited by predators (sharks) and prey (fish), and it is represented by a rectangular matrix: each element of the matrix corresponds to a location in the ocean, which can be empty, contain exactly one fish, or contain exactly one shark. Time is also subdivided in standard units, known as chronons.

This is how we model the behavior of predator and prey:

  • Sharks eat and move. At each step, a shark will look around in all the adjacent (nearest neighbor ) cells, and eat a fish if it finds one there; then the shark will move to the space previously occupied by the fish. If the shark cannot find any fish, it will move into one of the empty adjacent cells, if there any. [In a rectangular matrix, the nearest-neighbor elements are those whose first or second index (but not both) differ by exactly one.
  • Sharks breed and die. If a shark survives for Sb or more chronons, it will breed: if an empty adjacent cell is available, a new shark will appear there. The parent will breed again after Sb chronons. However, if a shark has not eaten after Sd chronons, it will die (disappear from the grid).
  • Fish move. At each step, each fish will move at random into one of the free adjacent cells, if there are any. Since Wator is toroidal, fish (and sharks) can swim out of one edge of the matrix, and come back from the opposite edge
  • Fish breed. If a fish survives for Fb chronons or more, it will breed: if an empty adjacent cell is available, a new fish will appear there. The parent will breed again after Fb chronons
  • Initial population. At the beginning of the simulation, the grid should be filled up randomly with NS sharks and NF fish. Their breeding and starving ages can all be set to zero
  • Random movement. Whenever a shark or fish can choose to operate (move, eat, spawn) in more than one direction, it should do so randomly

These rules are sufficient to create a simple model of predator-prey interaction that displays a behavior similar to that observed in some populations in nature. . When there are enough fish to go around, the sharks can prosper and breed: but if the number of sharks grows too large, they will eat most of the fish and a famine will ensue.

In this assignment, you are going to write a parallel program that implements the Wator model by subdividing (dynamically, for load-balancing purposes) the rectangular matrix that represents the ocean between the parallel processors.

lcs/lcs08/esercitazioni/esercitazione1.1201532557.txt.gz · Ultima modifica: 28/01/2008 alle 15:02 (18 anni fa) da Susanna Pelagatti

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki