Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 7, 2024
1 parent 431e503 commit 1b48a8d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 47 deletions.
50 changes: 27 additions & 23 deletions gis/geo_schelling_experimental/Mesa-Geo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
" else:\n",
" agent.atype = 0\n",
" self.schedule.add(agent)\n",
" \n",
"\n",
" def export_agents_to_file(self) -> None:\n",
" self.space.get_agents_as_GeoDataFrame(agent_cls=SchellingAgent).to_crs(\n",
" \"epsg:4326\"\n",
Expand All @@ -116,7 +116,7 @@
"\n",
" If All agents are happy, halt the model.\n",
" \"\"\"\n",
" \n",
"\n",
" self.happy = 0 # Reset counter of happy agents\n",
" self.schedule.step()\n",
" self.datacollector.collect(self)\n",
Expand Down Expand Up @@ -148,26 +148,30 @@
" portrayal[\"color\"] = \"Blue\"\n",
" return portrayal\n",
"\n",
"\n",
"model_params = {\n",
" \"density\":{ \n",
" \"type\": \"SliderFloat\",\n",
" \"value\": 0.6,\n",
" \"label\": \"Population Density\",\n",
" \"min\": 0.0,\n",
" \"max\": 1.0,\n",
" \"step\": 0.1,},\n",
" \"minority_pc\":{\n",
" \"type\": \"SliderFloat\",\n",
" \"value\": 0.2,\n",
" \"label\": \"Fraction Minority\",\n",
" \"min\": 0.0,\n",
" \"max\": 1.0,\n",
" \"step\": 0.05},\n",
" \"export_data\": { \n",
" \"type\": \"Checkbox\",\n",
" \"value\": False,\n",
" \"description\" :'Export Data',\n",
" \"disabled\": False}\n",
" \"density\": {\n",
" \"type\": \"SliderFloat\",\n",
" \"value\": 0.6,\n",
" \"label\": \"Population Density\",\n",
" \"min\": 0.0,\n",
" \"max\": 1.0,\n",
" \"step\": 0.1,\n",
" },\n",
" \"minority_pc\": {\n",
" \"type\": \"SliderFloat\",\n",
" \"value\": 0.2,\n",
" \"label\": \"Fraction Minority\",\n",
" \"min\": 0.0,\n",
" \"max\": 1.0,\n",
" \"step\": 0.05,\n",
" },\n",
" \"export_data\": {\n",
" \"type\": \"Checkbox\",\n",
" \"value\": False,\n",
" \"description\": \"Export Data\",\n",
" \"disabled\": False,\n",
" },\n",
"}"
]
},
Expand Down Expand Up @@ -199,11 +203,11 @@
"page = mge.JupyterViz(\n",
" GeoSchelling,\n",
" model_params,\n",
" measures = [\"happy\"],\n",
" measures=[\"happy\"],\n",
" name=\"Geo-Schelling Model\",\n",
" agent_portrayal=schelling_draw,\n",
" zoom=3,\n",
" center_point= [52,12],\n",
" center_point=[52, 12],\n",
")\n",
"# This is required to render the visualization in the Jupyter notebook\n",
"page"
Expand Down
54 changes: 30 additions & 24 deletions gis/geo_schelling_experimental/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ def __init__(self):
def render(self, model):
return "Happy agents: " + str(model.happy)

'''

"""
model_params = {
"density": mesa.visualization.Slider("Agent density", 0.6, 0.1, 1.0, 0.1),
"minority_pc": mesa.visualization.Slider("Fraction minority", 0.2, 0.00, 1.0, 0.05),
"export_data": mesa.visualization.Checkbox("Export data after simulation", False),
}
'''
"""


def schelling_draw(agent):
"""
Expand All @@ -37,36 +39,40 @@ def schelling_draw(agent):
portrayal["color"] = "Blue"
return portrayal


model_params = {
"density":{
"type": "SliderFloat",
"value": 0.6,
"label": "Population Density",
"min": 0.0,
"max": 1.0,
"step": 0.1,},
"minority_pc":{
"type": "SliderFloat",
"value": 0.2,
"label": "Fraction Minority",
"min": 0.0,
"max": 1.0,
"step": 0.05},
"export_data": {
"type": "Checkbox",
"value": False,
"description" :'Export Data',
"disabled": False}
"density": {
"type": "SliderFloat",
"value": 0.6,
"label": "Population Density",
"min": 0.0,
"max": 1.0,
"step": 0.1,
},
"minority_pc": {
"type": "SliderFloat",
"value": 0.2,
"label": "Fraction Minority",
"min": 0.0,
"max": 1.0,
"step": 0.05,
},
"export_data": {
"type": "Checkbox",
"value": False,
"description": "Export Data",
"disabled": False,
},
}

page = mge.JupyterViz(
GeoSchelling,
GeoSchelling,
model_params,
measures = ["happy"],
measures=["happy"],
name="Geo-Schelling Model",
agent_portrayal=schelling_draw,
zoom=3,
center_point= [52,12]
center_point=[52, 12],
)

page

0 comments on commit 1b48a8d

Please sign in to comment.