Skip to content

Commit

Permalink
Phase 1, done
Browse files Browse the repository at this point in the history
  • Loading branch information
BAFurtado committed May 15, 2020
1 parent f444750 commit 23bb72a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ simulate the main processes and drivers within this system**." (Malleson, Heppen
We developed the model on top of [https://github.com/projectmesa/mesa] mesa wolf_sheep example
We thank David Massa e all the contributors of the mesa project.

**Alan Rafael Dill**

**Lígia Mori Madeira**

**Bernardo Alves Furtado**

**Alan Rafael Dill**

We are considering two models (see the other one at github.com/bafurtado/armas:

### 1. Home violence model
Expand Down
48 changes: 48 additions & 0 deletions output.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
metropolis;stress
MANAUS;0.015413056522166494
BELEM;0.01512778215826908
MACAPA;0.015607207428302933
SAO LUIS;0.015062071229671074
TERESINA;0.01544716915866165
FORTALEZA;0.015075663587447868
CRAJUBAR;0.01570076100482962
NATAL;0.015241406571013211
JOAO PESSOA;0.01497565012527498
CAMPINA GRANDE;0.015654850859894858
RECIFE;0.015032789843866133
PETROLINA - JUAZEIRO;0.01607362134415093
MACEIO;0.01528808566628607
ARACAJU;0.015479135597806221
SALVADOR;0.014744720963030065
FEIRA DE SANTANA;0.014944898840595439
ILHEUS - ITABUNA;0.01596026156975715
PETROLINA - JUAZEIRO;0.01629604953265254
BELO HORIZONTE;0.014808226812753164
JUIZ DE FORA;0.014188831874965972
IPATINGA;0.014848129735741197
UBERLANDIA;0.014507885582531754
VITORIA;0.014436284883361126
VOLTA REDONDA - BARRA MANSA;0.01434090352000408
RIO DE JANEIRO;0.014132121977181649
CAMPOS DOS GOYTACAZES;0.015525989683022205
SAO PAULO;0.01402184252526661
CAMPINAS;0.014295169188475414
SOROCABA;0.014288853104210839
SAO JOSE DO RIO PRETO;0.014154699166614054
SANTOS;0.014477763794973767
JUNDIAI;0.014447826390115088
SAO JOSE DOS CAMPOS;0.014813393194991245
RIBEIRAO PRETO;0.014282103250052828
CURITIBA;0.013963751892614224
LONDRINA;0.014337898961405684
MARINGA;0.014184831524900588
JOINVILLE;0.01514952607844631
FLORIANOPOLIS;0.01395010849509571
PORTO ALEGRE;0.014251968616385667
NOVO HAMBURGO - SAO LEOPOLDO;0.014985636318288337
CAXIAS DO SUL;0.014572435814835017
PELOTAS - RIO GRANDE;0.014365054765180133
CAMPO GRANDE;0.014262793357552735
CUIABA;0.01445571862551349
GOIANIA;0.014960733344703651
BRASILIA;0.014677902107105205
2 changes: 1 addition & 1 deletion violence/input/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ILHEUS - ITABUNA", "PETROLINA - JUAZEIRO", "BELO HORIZONTE", "JUIZ DE FORA", "IPATINGA", "UBERLANDIA",
"VITORIA", "VOLTA REDONDA - BARRA MANSA", "RIO DE JANEIRO", "CAMPOS DOS GOYTACAZES", "SAO PAULO",
"CAMPINAS", "SOROCABA", "SAO JOSE DO RIO PRETO", "SANTOS", "JUNDIAI", "SAO JOSE DOS CAMPOS",
"RIBEIRAO PRETO", "CURITIBA" "LONDRINA", "MARINGA", "JOINVILLE", "FLORIANOPOLIS", "PORTO ALEGRE",
"RIBEIRAO PRETO", "CURITIBA", "LONDRINA", "MARINGA", "JOINVILLE", "FLORIANOPOLIS", "PORTO ALEGRE",
"NOVO HAMBURGO - SAO LEOPOLDO", "CAXIAS DO SUL", "PELOTAS - RIO GRANDE", "CAMPO GRANDE", "CUIABA",
"GOIANIA", "BRASILIA"]

Expand Down
17 changes: 13 additions & 4 deletions violence/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from violence.agents import Person, Family
from violence.schedule import RandomActivationByBreed
from violence.input import generator
from violence.input.generator import metropolis


class Home(Model):
Expand Down Expand Up @@ -183,10 +184,8 @@ def run_model(self, step_count=200):
print('Final number People: ', self.schedule.get_breed_count(Person))


if __name__ == '__main__':
# Bernardo's debugging
# Running all metropolis
from violence.input.generator import metropolis
def generate_output():
# Running for all metropolis
output = pd.DataFrame(columns=['metropolis', 'stress'])
for metro in metropolis:
home = Home(metro=metro)
Expand All @@ -195,3 +194,13 @@ def run_model(self, step_count=200):
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)


if __name__ == '__main__':
# Bernardo's debugging
generate_output()
# metro = 'CURITIBA'
# home = Home(metro=metro)
# for i in range(5):
# home.step()
pass

0 comments on commit 23bb72a

Please sign in to comment.