Jump to content

The process model: Difference between revisions

From SELESwiki
No edit summary
 
No edit summary
 
Line 30: Line 30:
   PrevLSState[3]
   PrevLSState[3]
  Legends:
  Legends:
   LSStateTypes = {0:Uncolonised,   1:Producer, 2:Consumer}
   LSStateTypes = {0:Uncolonised, 1:Producer, 2:Consumer}
  Global Variables:
  Global Variables:
   pInitialProducer = 0.01
   pInitialProducer = 0.01
Line 43: Line 43:


===consumer.lse===
===consumer.lse===
   // Process based definition for consumber behaviour in producer/consumer model
   // Process based definition for consumber behaviour in producer/consumer model
  LSEVENT: Consumder
  LSEVENT: Consumder
  DEFINITIONS
  DEFINITIONS
   LAYER: LSState, PrevLSState
   LAYER: LSState, PrevLSState
   GLOBAL CONSTANT: Uncolonised, Producer, Consumer
   GLOBAL CONSTANT: Uncolonised, Producer, Consumer
   GLOBAL VARIABLE: pInitialConsumer,   pSpreadConsumer, pDeathConsumer //, SpreadRateConsumer
   GLOBAL VARIABLE: pInitialConsumer, pSpreadConsumer, pDeathConsumer //, SpreadRateConsumer
  ENDDEF
  ENDDEF
  // Just start once
  // Just start once
  RETURNTIME = 0
  RETURNTIME = 0
  // Initialize in an empty cell
  // Initialize in an empty cell
  PROBINIT = IF LSState EQ Uncolonised THEN pInitialConsumer ELSE 0
  PROBINIT = IF LSState EQ Uncolonised THEN pInitialConsumer ELSE 0
  TRANSITIONS
  TRANSITIONS
   // Decide if this cell survives
   // Decide if this cell survives
Line 69: Line 69:
  ENDSL
  ENDSL
  SPREADPROB
  SPREADPROB
   // Always spread to the same cell (self), and spread probabilistical to neighbouring producer cells
   // Always spread to the same cell (self), and spread probabilistical to neighbouring producer cells
   SPREADPROB = IF Location EQ (SOURCE Location) THEN 1
   SPREADPROB = IF Location EQ (SOURCE Location) THEN 1
               ELSE IF PrevLSState EQ   Producer  THEN pSpreadConsumer
               ELSE IF PrevLSState EQ Producer  THEN pSpreadConsumer
               ELSE 0
               ELSE 0
  ENDSP
  ENDSP


===producer.lse===
===producer.lse===
  // Process based definiton of producer behaviour in producer/consumer model
  // Process based definiton of producer behaviour in producer/consumer model
  LSEVENT: Producer
  LSEVENT: Producer
  DEFINITIONS
  DEFINITIONS
   LAYER: LSState, PrevLSState
   LAYER: LSState, PrevLSState
   GLOBAL CONSTANT: Uncolonised, Producer, Consumer
   GLOBAL CONSTANT: Uncolonised, Producer, Consumer
   GLOBAL VARIABLE: pInitialProducer, pSpreadProducer, pDeathProducer //, SpreadRateProducer
   GLOBAL VARIABLE: pInitialProducer, pSpreadProducer, pDeathProducer //, SpreadRateProducer
  ENDDEF
  ENDDEF
  // Just start once
  // Just start once
  RETURNTIME = 0
  RETURNTIME = 0
  // Initialize in an empty cell
  // Initialize in an empty cell
  PROBINIT = IF LSState EQ Uncolonised THEN pInitialProducer ELSE 0
  PROBINIT = IF LSState EQ Uncolonised THEN pInitialProducer ELSE 0
  TRANSITIONS
  TRANSITIONS
   // Decide if this cell survives
   // Decide if this cell survives
Line 99: Line 99:
  SPREADTIMESTEP = 1 //SpreadRateProducer  
  SPREADTIMESTEP = 1 //SpreadRateProducer  
  SPREADLOCATION
  SPREADLOCATION
   notEaten = PrevLSState EQ Producer // check that the producer wasn't eaten during the last step
   notEaten = PrevLSState EQ Producer // check that the producer wasn't eaten during the last step
   REGION CENTRED(0, 1, WRAPPED)
   REGION CENTRED(0, 1, WRAPPED)
       DECISION notEaten // don't spread if eaten (i.e. stop process)
       DECISION notEaten // don't spread if eaten (i.e. stop process)
  ENDSL
  ENDSL
  SPREADPROB
  SPREADPROB
   // Always spread to the same cell (self), and spread probabilistically to empty neighbouring cells
   // Always spread to the same cell (self), and spread probabilistically to empty neighbouring cells
   SPREADPROB = IF Location EQ (SOURCE Location) THEN 1 // spread to same cell
   SPREADPROB = IF Location EQ (SOURCE Location) THEN 1 // spread to same cell
               ELSE IF PrevLSState EQ Uncolonised THEN pSpreadProducer
               ELSE IF PrevLSState EQ Uncolonised THEN pSpreadProducer
               ELSE 0
               ELSE 0
  ENDSP
  ENDSP
===update.lse===
// Event to update time step
LSEVENT: Update
DEFINITIONS
  LAYER: LSState, PrevLSState
ENDDEF
RETURNTIME
  RETURNTIME = 1
  PrevLSState = LSState
ENDRT
NUMCLUSTERS = 0


==Suggested Experiments==
==Suggested Experiments==


To explore this cellular automata model further, try the following:
To explore this cellular automata model further, try the following:

Latest revision as of 21:24, 15 November 2006

Summary

Screenshot

Download Model

Download the .scn, .sel and .lse files by clicking on the following link: File:ProducerConsumer.zip

Model Code Exploration

In the following sections we will examine all of the model files for this model. Note that instead of downloading the zip file above, you could just copy the text in the boxes below into a text editor and save it with the appropriate name (Section title). Opening the resulting .scn file in the SELES simulator would run this model.

Consume.scn

Seles Scenario
Model.sel
SimPriority Low Priority

Model.sel

Seles Model
Time Units: Step kiloStep 1000 1000
Landscape Events:
 Producer.lse DEBUG
 Consumer.lse DEBUG
 Update.lse DEBUG
Spatial Variables:
 LSState[3]
 PrevLSState[3]
Legends:
 LSStateTypes = {0:Uncolonised, 1:Producer, 2:Consumer}
Global Variables:
 pInitialProducer = 0.01
 pInitialConsumer = 0.01
 pSpreadProducer = 0.1
 pSpreadConsumer = 0.2
 pDeathProducer = 0.01
 pDeathConsumer = 0.05
//  SpreadRateProducer = 1
//  SpreadRateConsumer = 1
Output Frequency: 1

consumer.lse

 // Process based definition for consumber behaviour in producer/consumer model
LSEVENT: Consumder
DEFINITIONS
  LAYER: LSState, PrevLSState
  GLOBAL CONSTANT: Uncolonised, Producer, Consumer
  GLOBAL VARIABLE: pInitialConsumer, pSpreadConsumer, pDeathConsumer //, SpreadRateConsumer
ENDDEF
// Just start once
RETURNTIME = 0
// Initialize in an empty cell
PROBINIT = IF LSState EQ Uncolonised THEN pInitialConsumer ELSE 0
TRANSITIONS
  // Decide if this cell survives
  Dies = UNIFORM(0,1) < pDeathConsumer
  // If the consumer is dying
  IF Dies
      LSState = Uncolonised
  ENDFN
  TRANSITIONS = !Dies
  LSState = Consumer
ENDTR
SPREADTIMESTEP = 1 //SpreadRateConsumer
SPREADLOCATION
  REGION CENTRED(0,1, WRAPPED)
ENDSL
SPREADPROB
  // Always spread to the same cell (self), and spread probabilistical to neighbouring producer cells
 SPREADPROB = IF Location EQ (SOURCE Location) THEN 1
              ELSE IF PrevLSState EQ Producer  THEN pSpreadConsumer
              ELSE 0
ENDSP

producer.lse

// Process based definiton of producer behaviour in producer/consumer model
LSEVENT: Producer
DEFINITIONS
  LAYER: LSState, PrevLSState
  GLOBAL CONSTANT: Uncolonised, Producer, Consumer
  GLOBAL VARIABLE: pInitialProducer, pSpreadProducer, pDeathProducer //, SpreadRateProducer
ENDDEF
// Just start once
RETURNTIME = 0
// Initialize in an empty cell
PROBINIT = IF LSState EQ Uncolonised THEN pInitialProducer ELSE 0
TRANSITIONS
  // Decide if this cell survives
  Dies = UNIFORM(0,1) < pDeathProducer
  // If the producer is dying
  IF Dies
     LSState = Uncolonised
  ENDFN
  TRANSITIONS = (!Dies)
  LSState = Producer
ENDTR
SPREADTIMESTEP = 1 //SpreadRateProducer 
SPREADLOCATION
  notEaten = PrevLSState EQ Producer // check that the producer wasn't eaten during the last step
  REGION CENTRED(0, 1, WRAPPED)
     DECISION notEaten // don't spread if eaten (i.e. stop process)
ENDSL
SPREADPROB
  // Always spread to the same cell (self), and spread probabilistically to empty neighbouring cells
 SPREADPROB = IF Location EQ (SOURCE Location) THEN 1 // spread to same cell
              ELSE IF PrevLSState EQ Uncolonised THEN pSpreadProducer
              ELSE 0
ENDSP

Suggested Experiments

To explore this cellular automata model further, try the following: