Skip to content

Commit

Permalink
Saving output
Browse files Browse the repository at this point in the history
  • Loading branch information
BAFurtado committed May 15, 2020
1 parent efddb9c commit f444750
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 2 additions & 3 deletions violence/input/generator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Later replace by self.model.random
from collections import defaultdict

import numpy as np
import pandas as pd
from collections import defaultdict

import violence.input.geography as geo
import violence.input.population as pop



"""
Objective is to have data on population, age, gender and qualification.
Geography class provides the list of IBGE's AREAS DE PONDERAÇÃO (APs) for a given metropolis input.
Expand Down
15 changes: 11 additions & 4 deletions violence/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
os.chdir('/home/furtadobb/MyModels/home_violence/')

import numpy as np
import pandas as pd
from mesa import Model
from mesa.space import MultiGrid
from mesa.datacollection import DataCollector
Expand Down Expand Up @@ -184,7 +185,13 @@ def run_model(self, step_count=200):

if __name__ == '__main__':
# Bernardo's debugging
my_model = Home()
for i in range(10):
my_model.step()
# my_model.run_model()
# Running all metropolis
from violence.input.generator import metropolis
output = pd.DataFrame(columns=['metropolis', 'stress'])
for metro in metropolis:
home = Home(metro=metro)
for i in range(10):
home.step()
model_df = home.datacollector.get_model_vars_dataframe()
output.loc[output.shape[0]] = [metro, model_df.loc[9, 'Stress']]
output.to_csv('output.csv', sep=';', index=False)
5 changes: 2 additions & 3 deletions violence/server.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import numpy as np

from mesa.visualization.ModularVisualization import ModularServer
from mesa.visualization.modules import CanvasGrid, ChartModule
from mesa.visualization.UserParam import UserSettableParameter
from mesa.visualization.modules import CanvasGrid, ChartModule

from violence.agents import Person, Family
from violence.model import Home
from violence.input.generator import metropolis
from violence.model import Home

# dark grey
ADULT = "#757575"
Expand Down

0 comments on commit f444750

Please sign in to comment.