Jump to content

LSStats: Difference between revisions

From SELESwiki
No edit summary
 
No edit summary
Line 4: Line 4:
==Screenshot==
==Screenshot==


[[Image:ConvexHull.gif]]
[[Image:LSStats.gif]]


==Download Model==
==Download Model==


Download the .scn, .sel and .lse files by clicking on the following link: [[Image:ConvexHull.zip]]
Download the .scn, .sel and .lse files by clicking on the following link: [[Image:LSStats.zip]]


==Model Code Exploration==
==Model Code Exploration==
Line 14: Line 14:
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.
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.


===MLM.scn===
===BatchStats.scn===


  SELES Scenario
  SELES Scenario
  $gisData$ = ..\..\CaseStudy_Morice\gisData\cell
  $baseGisDir$ = ..\..\CaseStudy\gisData\cell
  StudyArea = $gisData$\BEC
$gisDir$ = ..\..\CaseStudy\v6_roads\output\cell
  Model Dimensions: StudyArea
  $first$ = TRUE
  Model.sel
// load first layers
  SimPriority Low Priority
StudyArea = $baseGisDir$\StudyArea
  //SimStart 100000 1
cwd oStats
// Loop over all files in the directory that start with "ACPatchType1."
for($x$ = "..\$gisDir$\OldForest_1_*")
// Open a patch layer (ensure previous one, if any, is closed)
PatchLayer = ..\$gisDir$\OldForest_1_$x$
// Load model
  Model Dimensions: PatchLayer
  ..\stats.sel
  // Set up parameters
  CellWidth = 100
HaPerCell = 1
NNType = 2        // For MPG
LandscapeId = $x$  // This sets the variable LandscapeId to the integer represented by $x$
  NumPTypes = 1
  Reset Output $first$    // Tell SELES to not reset output files (i.e. to append to them) except on first  iteration
  $first$ = FALSE


===Model.sel===
  // Turn off centroid stats (time consuming if there are lots of patches (np^2))
//  centroid.lse OFF
//  nn.lse OFF
  // Run simulation
  SimStart 100*365.25 1
  Close PatchLayer
end
 
===centroid.lse==
 
===identifyPatches.lse===
===nn.lse===
===stats.lse===
===stats.scn===
===stats.sel===


  Seles Model
  Seles Model

Revision as of 22:11, 8 November 2006

Summary

Screenshot

Download Model

Download the .scn, .sel and .lse files by clicking on the following link: File:LSStats.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.

BatchStats.scn

SELES Scenario
$baseGisDir$ = ..\..\CaseStudy\gisData\cell
$gisDir$ = ..\..\CaseStudy\v6_roads\output\cell
$first$ = TRUE
// load first layers
StudyArea = $baseGisDir$\StudyArea
cwd oStats
// Loop over all files in the directory that start with "ACPatchType1."
for($x$ = "..\$gisDir$\OldForest_1_*")
// Open a patch layer (ensure previous one, if any, is closed)
PatchLayer = ..\$gisDir$\OldForest_1_$x$
// Load model
Model Dimensions: PatchLayer
..\stats.sel
// Set up parameters
CellWidth = 100
HaPerCell = 1
NNType = 2         // For MPG
LandscapeId = $x$  // This sets the variable LandscapeId to the integer represented by $x$
  NumPTypes = 1
  Reset Output $first$     // Tell SELES to not reset output files (i.e. to append to them) except on first  iteration
  $first$ = FALSE
  // Turn off centroid stats (time consuming if there are lots of patches (np^2))
//   centroid.lse OFF
//   nn.lse OFF
  // Run simulation
  SimStart 100*365.25 1
  Close PatchLayer
end

=centroid.lse

identifyPatches.lse

nn.lse

stats.lse

stats.scn

stats.sel

Seles Model
Time Units: Step kiloStep 1000 100000
Landscape Events:
ConvexHull.lse
Spatial Constants:
StudyArea
Spatial Variables:
ConvexHullPoints[1] <= 0
ConvexHull[1] <= 0
Global Variables:
TRLoc = 0
Output Frequency: 1

ConvexHull.lse

// Sweep-line approach to identifying convex hull using a worker agent
LSAGENT: ConvexHull
DEFINITIONS
 LAYER: StudyArea, ConvexHull, ConvexHullPoints
 GLOBAL VARIABLE: TRLoc
 LOCAL VARIABLE: EndingPivotLoc
 AGENT VARIABLE: PivotLocation, EdgeLocation, EdgeRow, EdgeCol
ENDDEF
INITIALSTATE
  INITIALSTATE = 1
// Find the top-right-most point
  TRLoc = 0
  OVER REGION WHOLE MAP
     DECISION StudyArea > 0
     TRLoc = MAX(TRLoc, Location)
  ENDFN
ConvexHull = 1 // Initialize convex hull layer to all ones (will erase areas outside hull)
ENDIS
NUMAGENTS = 1 // Only need a single worker
// Start on the first pivot vertex on convex hull
AGENTLOCATION
  REGION LOCATION(TRLoc)
ENDAL
PROBINIT
 PROBINIT = 1
// Set up first pivot vertex, and first raster boundary location
 PivotLocation = Location
 EdgeRow = NUMROWS-1
 EdgeCol = COL(Location)
 EdgeLocation = LOCATION(EdgeRow, EdgeCol)
 EndingPivotLoc = -1
ENDPI
TRANSITIONS
 // Continue until we reach the ending pivot location (which is actually second time we hit the second pivot           vertex,
 // since the first pivot vertex gets only partially processed on first pass)
 TRANSITIONS = (PivotLocation NEQ EndingPivotLoc)
ConvexHullPoints = 1
// Walk line from boundary to vertex and erase until a new pivot vertex is hit (then move there)
 oldPivot = PivotLocation
 hitPivot = FALSE
 OVER REGION VECTOR(EdgeLocation, PivotLocation)
    DECISION !hitPivot
 IF (StudyArea > 0) // hit new vertex
       hitPivot = TRUE
       IF (EndingPivotLoc EQ -1) AND (Location NEQ PivotLocation)
          EndingPivotLoc = PivotLocation
       ENDFN
       PivotLocation = Location
    ELSE
       ConvexHull = 0 // erase
    ENDFN
 ENDFN
// Move boundary location clockwise around outside edge of raster
 IF (EdgeRow EQ NUMROWS-1) AND (EdgeCol < NUMCOLS-1)
    EdgeCol = EdgeCol + 1
 ELSE IF (EdgeCol EQ NUMCOLS-1) AND (EdgeRow > 0)
    EdgeRow = EdgeRow - 1
 ELSE IF (EdgeRow EQ 0) AND (EdgeCol > 0)
    EdgeCol = EdgeCol - 1
 ELSE
    EdgeRow = EdgeRow + 1
 ENDFN
 EdgeLocation = LOCATION(EdgeRow, EdgeCol)
ENDTR
POPULATIONTIME = 1
// Move to current/new pivot location
MOVELOCATION
 REGION LOCATION(PivotLocation)
ENDML

Suggested Experiments

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