Download presentation
Presentation is loading. Please wait.
Published byAlicia Roberts Modified over 8 years ago
1
An Introduction to TerraME Pedro Ribeiro de Andrade São José dos Campos, 2011 www.terrame.org
2
Cell Spaces Fonte: (Carneiro, 2006) Hipótese: Nenhuma abordagem sozinha é suficiente para representar a complexidade das interações sociedade-natureza TerraME: Ambiente Computacional Multi-paradigma para o Desenvolvimento de Modelos Integrados Natureza-Sociedade
3
CCST-INPE Pedro Andrade, Gilberto Camara, Raian Maretto TerraLab/UFOP Tiago Carneiro DPI/OBT-INPE Miguel Monteiro, Time TerraLib Desenvolvimento do TerraME
4
TerraME
5
Visualization (TerraView) Spatio-temporal Database (TerraLib) Modelling (TerraME) Data Mining(GeoDMA)Statistics (R interface) Software: Open source GIS
6
Spatial structure 1:32:00Mens. 1 1. 1:32:10Mens. 3 2. 1:38:07Mens. 2 3. 1:42:00Mens.4 4.... return value true 1. Get first pair 2. Execute the ACTION 3. Timer =EVENT 4. timeToHappen += period Temporal structure Newly implanted Deforesting Slowing down latency > 6 years Iddle Year of creation Deforestation = 100% Rules of behaviour Spatial relations Source: [Carneiro, 2006] TerraME: Components
7
Lua classes using the constructor mechanism: Cell, CellularSpace, Neighborhood, Timer, Event, Legend A CellularSpace is a multivalued set of Cells. It consists of a geographical area of interest, divided into regular or irregular objects. Each Cell has a set of attributes. CellularSpaces can be stored and retrieved from TerraLib databases if the modeler specify where the data is. TerraME extensions to Lua
8
Example 1: Random cellular space
9
Cellular Space in memory and forEachCell DEAD = 0 ALIVE = 1 cs = CellularSpace { xdim = 30, ydim = 20 } function random (cs) forEachCell (cs, function (cell) v = math.random() -- a value between 0 and 1 if v > 0.5 then cell.state = ALIVE else cell.state = DEAD end end) end random(cs)
10
Legend and Observer lifeLeg = Legend{ type = TYPES.NUMBER, groupingMode = GROUPING.UNIQUEVALUE, slices = 2, maximum = ALIVE, minimum = DEAD, colorBar1 = { {BLACK, DEAD}, {WHITE, ALIVE} }, } cs:createObserver(OBSERVERS.MAP, {"state"}, {lifeLeg}) cs:notifyObservers()
11
Example 2: Game of life
12
Synchronizing a CellularSpace TerraME keeps two copies of a cellular space in memory: one stores the past values of the cells, and another stores the current (present) values of the cells. The model equations must read the past copy and write the values to the present copy of the cellular space. At the correct moment, it will be necessary to synchronize the past copy with the current values of the cellular space.
13
Game of life source code DEAD = 0 ALIVE = 1 TURNS = 400 function random (cs) forEachCell (cs, function (cell) v = math.random() -- a value between 0 and 1 if v > 0.5 then cell.state = ALIVE else cell.state = DEAD end end) end
14
Cellular Space and neighborhood cs = CellularSpace { xdim = 50 } random(cs) createMooreNeighborhood(cs, "1", false) function countAlive(cell) count = 0 forEachNeighbor(cell, function(cell, neigh) if neigh.past.state == ALIVE then count = count + 1 end end) return count end
15
Updating the cellular space function updateSpace(mycs) forEachCell(mycs, function(cell) n = countAlive(cell) -- cells with one or no neighbors die (loneliness). if n < 2 then cell.state = DEAD -- cells with four or more neighbors die (overpopulation). elseif n > 3 then cell.state = DEAD -- cells with two neighbors survive. elseif n == 2 then cell.state = cell.past.state -- cells with three neighbors become populated. elseif n == 3 then cell.state = ALIVE end end) end
16
Running and synchronizing lifeLeg = Legend{ type = TYPES.NUMBER, groupingMode = GROUPING.UNIQUEVALUE, slices = 2, maximum = ALIVE, minimum = DEAD, colorBar1 = { {BLACK, ALIVE}, {WHITE, DEAD} } cs:createObserver(OBSERVERS.MAP, {"state"}, {lifeLeg}) cs:notifyObservers() for i = 1,TURNS do cs:synchronize() updateSpace(cs) cs:notifyObservers() end
17
Example 3: Runoff rain Itacolomi do Itambé Peak Lobo’s Range
18
CellularSpace from database and neighborhood -- input and output data paths TERRAME_PATH = "e:\\Programas\\TerraME\\" INPUT_PATH = TERRAME_PATH.."Database\\" -- retrieve the cell space from the database csQ = CellularSpace{ database = INPUT_PATH.."cabecaDeBoi.mdb", theme = "cells", select = { "height", "soilWater" } } csQ:load() function filter(cell, neigh) if cell.height >= neigh.height then return true end return false end create3x3Neighborhood(csQ, filter)
19
Observers using two attributes heightLeg = Legend{ type = TYPES.NUMBER, groupingMode = GROUPING.EQUALSTEPS, slices = 50, maximum = 255, minimum = 0, colorBar1 = { {BLACK, 0}, {WHITE, 1} } soilWaterLeg = Legend{ type = TYPES.NUMBER, groupingMode = GROUPING.EQUALSTEPS, slices = 100, maximum = 200, minimum = 0, colorBar1 = { {WHITE, 0}, {BLUE, 200} } csQ:createObserver(OBSERVERS.MAP, {"soilWater", "height"}, {soilWaterLeg, heightLeg})
20
Rain and runoff RAIN = 4 -- rain/t MIN_HEIGHT = 200 function rain(cs) forEachCell(cs, function(cell) if ANYWHERE or (cell.height > MIN_HEIGHT) then cell.soilWater = cell.soilWater + RAIN end end) end function runoff(cs) cs:synchronize("soilWater") forEachCell(cs, function(cell) cell.soilWater = 0 end) forEachCell(cs, function(cell) countNeigh = cell:getNeighborhood():size() if countNeigh > 0 then soilWater = cell.past.soilWater / countNeigh forEachNeighbor(cell, function(cell, neigh) neigh.soilWater = neigh.soilWater + soilWater end) else cell.soilWater = cell.soilWater + cell.past.soilWater end end) end
21
Timer RAINING_TIME = 5 FINAL_TIME = 50 t = Timer{ Event{message = function(event) rain(csQ) if event:getTime() > RAINING_TIME then return false end end}, Event{message = function(event) runoff(csQ) end}, Event{priority = 5, message = function(event) csQ:notifyObservers() end} } t:execute(FINAL_TIME)
22
1985 1997 Large farm environments: 2500 m resolution Continuous variable: % deforested Two alternative neighborhood relations: connection through roads farm limits proximity Small farms environments: 500 m resolution Categorical variable: deforested or forest One neighborhood relation: connection through roads Different spatial resolutions
23
Generalized Proximity Matrices (GPM)
24
Models of Computation Agent based models Cellular automata models (Rosenschein and Kaelbling, 1995) (Wooldbridge, 1995) (von Neumann, 1966)(Minsky, 1967) (Aguiar et al, 2004) (Pedrosa et al, 2003) (Straatman et al, 2001)
25
Create pasture/ Deforest Speculator/ large/small bad land management money surplus Subsistence agriculture Diversify use Manage cattle Move towards the frontier Abandon/Sell the property Buy new land Settlement/ invaded land Sustainability path (alternative uses, technology) Sustainability path (technology) State machines
26
To Agent Cell a b a b c c Cell Agent From GPM as a graph
27
CellAgent forEachAgent forEachCell forEachRelativeforEachNeighbor forEachAgent CellularSpace Society GroupTrajectory DBMS Agent-based modelling relations
28
Prodes/INPE 2000-2001 Nested environments
29
up-scaling Escala 1 Escala 2 pai filho down-scaling Nested environments
30
An Introduction to TerraME Pedro Ribeiro de Andrade São José dos Campos, 2011 www.terrame.org
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.