-
Notifications
You must be signed in to change notification settings - Fork 182
added a new example: city walking behaviour #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sahil-Chhoker
wants to merge
13
commits into
projectmesa:main
Choose a base branch
from
Sahil-Chhoker:new_example-city-walking-behaviour
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,542
−0
Open
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0142b18
added a new example: city walking behaviour
Sahil-Chhoker c850d5f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 058453d
added pre-commit suggestions
Sahil-Chhoker 91abe57
added model description
Sahil-Chhoker f405721
updated readme
Sahil-Chhoker 7de1a16
improved the model with faster lookups, better placement and better w…
Sahil-Chhoker 32207b2
fixed leisure walks, improved household logic and placement for Humans.
Sahil-Chhoker 9159ee1
fixed imports in model.py
Sahil-Chhoker 7fd5559
fix: model can pass tests
Sahil-Chhoker f32b04e
updated readme
Sahil-Chhoker d6b1e0f
added pictures
Sahil-Chhoker 859c9f0
Update Readme.md
Sahil-Chhoker ba5a4be
applied reviewed changes
Sahil-Chhoker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Walking Behavior Agent-Based Model | ||
|
||
This repository contains an agent-based model (ABM) that simulates walking behavior in a hypothetical city, examining how socioeconomic status (SES), built environment, and social factors influence walking patterns. | ||
|
||
# Walking Behavior Simulation Model Documentation | ||
|
||
## Overview | ||
|
||
## Model Architecture (`model.py`) | ||
|
||
### Initialization Parameters | ||
|
||
- Grid dimensions (width and height) | ||
- Number of workplaces (categorized into Grocery Stores, Social Places, etc.) | ||
- Population composition (number of couples and singles) | ||
|
||
### Simulation Scenarios | ||
|
||
The model implements four distinct scenarios: | ||
|
||
1. **RR (Random-Random)**: Random land use distribution with random safety values | ||
2. **RS (Random-Safety)**: Random land use distribution with lower safety values in core areas | ||
3. **CR (Centralized-Random)**: Centralized land use with random safety values | ||
4. **CS (Centralized-Safety)**: Centralized land use with lower safety values in core areas | ||
|
||
### Environmental Layers | ||
|
||
1. **Safety Layer** (`safety_cell_layer`) | ||
|
||
- Values vary based on selected scenario | ||
- Impacts walking behavior and route choices | ||
|
||
2. **Aesthetic Layer** (`aesthetic_cell_layer`) | ||
- Values decrease with distance from center | ||
- Reflects personal preferences in route selection | ||
|
||
### Agent Placement | ||
|
||
- Workplaces are distributed according to scenario parameters | ||
- Households serve as spawn locations for human agents | ||
- Agent placement correlates with Socioeconomic Status (SES) - lower SES values correspond to more central locations | ||
|
||
### Data Collection | ||
|
||
The model tracks the following metrics across five SES levels (1-5): | ||
|
||
1. Average daily walking trips | ||
2. Work-related trips | ||
3. Basic needs trips (grocery and non-food shopping) | ||
4. Leisure trips (non-purposeful neighborhood walks) | ||
|
||
## Agent Implementation (`agents.py`) | ||
|
||
### Human Class | ||
|
||
Extends the CellAgent class with the following attributes: | ||
|
||
#### Demographic Characteristics | ||
|
||
- Gender: Equal probability of male/female | ||
- Age: Random distribution (18-87 years) | ||
- Family Size: 1 or 2 (based on `SINGLE_HOUSEHOLD_PROBABILITY`) | ||
- Pet Ownership: 20% probability of dog ownership (increases leisure walking frequency) | ||
|
||
#### Personal Attributes | ||
|
||
- Walking Ability: Determined by `get_walking_ability` function | ||
- Walking Attitude: Calculated via `get_walking_attitude` function | ||
- Employment Status: | ||
- Automatic retirement above `RETIREMENT_AGE` | ||
- 95% employment probability for working-age population | ||
- Social Network: Maintains lists of friends and family members | ||
|
||
#### Behavioral Feedback System | ||
|
||
Walking attitude is influenced by: | ||
|
||
- Social network (family and friends' attitudes) | ||
- Environmental factors (safety and aesthetics) | ||
- Local pedestrian density | ||
- Cumulative walking distance | ||
|
||
### WalkingBehaviourModel Class | ||
|
||
Manages walking behavior simulation with: | ||
|
||
- Activity probability distributions | ||
- Maximum distance thresholds | ||
- Daily walk scheduling based on destination distances | ||
- Activity and destination planning algorithms | ||
|
||
### Workplace Classes | ||
|
||
A hierarchy of workplace types: | ||
|
||
1. **Base Workplace**: Abstract class for workplace definition | ||
2. **GroceryStore**: Essential food retail | ||
3. **NonFoodShop**: General retail | ||
4. **SocialPlace**: Community gathering locations | ||
5. **Other**: Miscellaneous workplace types | ||
|
||
All workplace classes inherit from both `Workplace` and `FixedAgent` base classes. | ||
|
||
## How to Run | ||
|
||
To run a basic simulation: | ||
|
||
```python | ||
|
||
solara run app.py | ||
|
||
``` | ||
|
||
# Files | ||
|
||
- [city_walking_behaviour/model.py](city_walking_behaviour/model.py): Core model file. | ||
- [city_walking_behaviour/agents.py](city_walking_behaviour/agents.py): The agent class. | ||
|
||
## Further Reading | ||
|
||
1. A Spatial Agent-Based Model for the Simulation of Adults’ Daily Walking Within a City [article](https://pmc.ncbi.nlm.nih.gov/articles/PMC3306662/) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.