示例#1
0
def main():
    record = SimulationRecord(1, False)
    record.loadHDF5('../data/results.h5', True, True)

    agentResults = GlobalAgentStats(';')

    agentResults.addAnalysis(AgentNum())
    agentResults.addAnalysis(AgentMean('strength x100'))
    agentResults.addAnalysis(AgentMean('aggressiveness x100'))
    agentResults.addAnalysis(AgentStdDev('strength x100'))
    agentResults.addAnalysis(AgentStdDev('aggressiveness x100'))
    agentResults.addAnalysis(AgentSum('strength x100'))
    agentResults.addAnalysis(AgentSum('aggressiveness x100'))

    agentResults.applyTo(record, 'farmers.csv', 'Farmer')
    agentResults.applyTo(record, 'herders.csv', 'Herder')

    rasterResults = GlobalRasterStats(';')
    rasterResults.addAnalysis(RasterMean())
    rasterResults.addAnalysis(RasterSum())

    rasterResults.applyTo(record, 'conflicts.csv', 'conflicts')
示例#2
0
def main():
    """ this file provides a template that can be used to analyze any Pandora model """
    record = SimulationRecord(1, False)
    record.loadHDF5('data/results.h5', True, True)

    agentResults = GlobalAgentStats(';')
    agentResults.addAnalysis(AgentNum())
    agentResults.addAnalysis(AgentMean('x'))
    agentResults.addAnalysis(AgentMean('y'))
    agentResults.addAnalysis(AgentMean('value'))
    agentResults.addAnalysis(AgentSum('value'))
    agentResults.applyTo(record, 'agents.csv', 'HelloAgent')

    rasterResults = GlobalRasterStats(';')
    rasterResults.addAnalysis(RasterMean())
    rasterResults.addAnalysis(RasterSum())
    rasterResults.applyTo(record, 'values.csv', 'values')
示例#3
0
            self.addAgent(newAgent)
            newAgent.setRandomPosition()
            newAgent._value = random.randint(0, 10)


mySimulation = Simulation(32, 10)
myWorld = MyWorld(mySimulation)
myWorld.initialize()
myWorld.run()

# analysis

record = SimulationRecord()
record.loadHDF5('data/results.h5', 1, 1)

agentResults = AgentResults(record, 'agents.csv', 'id', ';')
agentResults.addAnalysis(AgentNum())
agentResults.addAnalysis(AgentMean('x'))
agentResults.addAnalysis(AgentMean('y'))
agentResults.addAnalysis(AgentMean('value'))
agentResults.addAnalysis(AgentSum('value'))
agentResults.addAnalysis(AgentHDFtoSHP('shp/agents.shp', -1))

agentResults.apply()

rasterResults = RasterResults(record, 'resources.csv', 'test', ';')
rasterResults.addAnalysis(RasterMean())
rasterResults.addAnalysis(RasterSum())

rasterResults.apply()
示例#4
0
#!/usr/bin/python

import sys
sys.path.append('..')
sys.path.append('../../')
from pyPandora import SimulationRecord, AgentResults, AgentMean, AgentSum, AgentNum, AgentHDFtoSHP, RasterMean, RasterSum, RasterResults

record = SimulationRecord()
record.loadHDF5('data_test/gujarat.h5', 1, 1)

agentResults = AgentResults(record, 'agents.csv', 'HunterGatherer', ';')
agentResults.addAnalysis(AgentNum())
agentResults.addAnalysis(AgentMean('children'))
agentResults.addAnalysis(AgentSum('children'))
agentResults.addAnalysis(AgentMean('collected resources'))
agentResults.addAnalysis(AgentHDFtoSHP('shp/agents.shp', -1))

agentResults.compute()

rasterResults = RasterResults(record, 'resources.csv', 'resources', ';')
rasterResults.addAnalysis(RasterMean())
rasterResults.addAnalysis(RasterSum())

rasterResults.compute()

示例#5
0
#!/usr/bin/python

import sys
sys.path.append('../../../pandora/pyPandora/')
sys.path.append('../../../pandora/')
from pyPandora import SimulationRecord, AgentResults, AgentMean, AgentSum, AgentNum, AgentHDFtoSHP, RasterMean, RasterSum, RasterResults

record = SimulationRecord()
record.loadHDF5('data/results.h5', 1, 1)

agentResults = AgentResults(record, 'agents.csv', 'MyAgent', ';')
agentResults.addAnalysis(AgentNum())
agentResults.addAnalysis(AgentMean('x'))
agentResults.addAnalysis(AgentMean('y'))
agentResults.addAnalysis(AgentMean('resources'))
agentResults.addAnalysis(AgentSum('resources'))
agentResults.addAnalysis(AgentHDFtoSHP('shp/agents.shp', -1))

agentResults.apply()

rasterResults = RasterResults(record, 'rasters.csv', 'resources', ';')
rasterResults.addAnalysis(RasterMean())
rasterResults.addAnalysis(RasterSum())

rasterResults.apply()

示例#6
0
#!/usr/bin/python3

import sys, random

pandoraDir = '/home/xrubio/workspace/pandoraMaster/'

sys.path.append(pandoraDir + '/pandora/')
sys.path.append(pandoraDir + '/pandora/pyPandora/')

from pyPandora import Simulation, Point2DInt, SimulationRecord, GlobalAgentStats, AgentNum, AgentMean, AgentSum, AgentStdDev, GlobalRasterStats, RasterMean, RasterSum, SizeInt

record = SimulationRecord(1, False)
record.loadHDF5('data/ap.h5', True, True)

agentResults = GlobalAgentStats(';')
agentResults.addAnalysis(AgentNum())
agentResults.addAnalysis(AgentMean('population'))
agentResults.addAnalysis(AgentSum('population'))
"""
agentResults.addAnalysis(AgentMean('starvation rate %'))
agentResults.addAnalysis(AgentMean('number of plots'))
agentResults.addAnalysis(AgentSum('number of animals'))
"""
agentResults.applyTo(record, 'agents.csv', 'ap')