1 / 30

An Introduction to TerraME

An Introduction to TerraME. Pedro Ribeiro de Andrade São José dos Campos, 2011 www.terrame.org. Cell Spaces. TerraME: Ambiente Computacional Multi-paradigma para o Desenvolvimento de Modelos Integrados Natureza-Sociedade.

egholson
Télécharger la présentation

An Introduction to TerraME

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Introduction to TerraME Pedro Ribeiro de Andrade São José dos Campos, 2011 www.terrame.org

  2. Cell Spaces TerraME: Ambiente ComputacionalMulti-paradigma para o Desenvolvimento de Modelos Integrados Natureza-Sociedade Hipótese: Nenhuma abordagem sozinha é suficiente para representar a complexidade das interações sociedade-natureza Fonte: (Carneiro, 2006)

  3. Desenvolvimento do TerraME • CCST-INPE • Pedro Andrade, Gilberto Camara, Raian Maretto • TerraLab/UFOP • Tiago Carneiro • DPI/OBT-INPE • Miguel Monteiro, Time TerraLib

  4. TerraME

  5. Software: Open source GIS Visualization (TerraView) Modelling (TerraME) Spatio-temporal Database (TerraLib) Statistics (R interface) Data Mining(GeoDMA)

  6. 1. Get first pair 2. Execute the ACTION 1. 2. 3. Timer =EVENT 3. 1:32:00 1:32:10 1:42:00 1:38:07 Mens.4 Mens. 2 Mens. 1 Mens. 3 4. return value . . . true 4. timeToHappen += period TerraME: Components Temporal structure Spatial structure latency > 6 years Deforesting Newly implanted Year of creation Slowing down Iddle Deforestation = 100% Spatial relations Rules of behaviour Source: [Carneiro, 2006]

  7. TerraME extensions to Lua • Lua classes usingthe 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.

  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) functioncountAlive(cell) count = 0 forEachNeighbor(cell, function(cell, neigh) ifneigh.past.state == ALIVE then count = count + 1 end end) return count end

  15. Updating the cellular space functionupdateSpace(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). elseifn > 3 then cell.state = DEAD -- cells with two neighbors survive. elseifn == 2 then cell.state = cell.past.state -- cells with three neighbors become populated. elseifn == 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() fori = 1,TURNS do cs:synchronize() updateSpace(cs) cs:notifyObservers() end

  17. Example 3: Runoff rain rain 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) ifcell.height >= neigh.heightthen 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() ifcountNeigh > 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. Different spatial resolutions 1985 • Small farms environments: • 500 m resolution • Categorical variable: deforested or forest • One neighborhood relation: • connection through roads • Large farm environments: • 2500 m resolution • Continuous variable: • % deforested • Two alternative neighborhood • relations: • connection through roads • farm limits proximity 1997 1997

  23. GeneralizedProximityMatrices (GPM)

  24. Models of Computation (von Neumann, 1966) (Minsky, 1967) (Pedrosa et al, 2003) (Aguiar et al, 2004) (Wooldbridge, 1995) (Straatman et al, 2001) (Rosenschein and Kaelbling, 1995) Cellular automata models Agent based models

  25. State machines Settlement/invaded land Diversify use Sustainability path (alternative uses, technology) money surplus Sustainability path (technology) Manage cattle Buy newland Subsistenceagriculture Create pasture/ Deforest bad land management Abandon/Selltheproperty Speculator/large/small Move towardsthe frontier

  26. From a Cell Agent c a b b c Agent Cell To GPM as a graph

  27. Agent-based modelling relations forEachRelative forEachNeighbor forEachCell Agent Cell forEachAgent forEachCell forEachAgent Society CellularSpace Group Trajectory DBMS

  28. Nested environments Prodes/INPE 2000-2001

  29. Escala 1 pai up-scaling down-scaling filho Escala 2 Nested environments

  30. An Introduction to TerraME Pedro Ribeiro de Andrade São José dos Campos, 2011 www.terrame.org

More Related