Skip to content

Commit

Permalink
update homophily value in Schelling example
Browse files Browse the repository at this point in the history
  • Loading branch information
vbv-shm authored and Vaibhav sharma committed Dec 14, 2024
1 parent 393f6a0 commit 4132e43
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .codespellignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ inactivate
ue
fpr
falsy
assertIn
nD
assertIn
4 changes: 2 additions & 2 deletions benchmarks/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"parameters": {
"height": 40,
"width": 40,
"homophily": 3,
"homophily": 0.4,
"radius": 1,
"density": 0.625,
},
Expand All @@ -47,7 +47,7 @@
"parameters": {
"height": 100,
"width": 100,
"homophily": 8,
"homophily": 0.8,
"radius": 2,
"density": 0.8,
},
Expand Down
1 change: 1 addition & 0 deletions mesa/examples/basic/schelling/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def step(self) -> None:
self.pos, moore=True, radius=self.model.radius
)


# Count similar neighbors
similar_neighbors = len([n for n in neighbors if n.type == self.type])

Expand Down
2 changes: 1 addition & 1 deletion mesa/examples/basic/schelling/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def agent_portrayal(agent):
},
"density": Slider("Agent density", 0.8, 0.1, 1.0, 0.1),
"minority_pc": Slider("Fraction minority", 0.2, 0.0, 1.0, 0.05),
"homophily": Slider("Homophily", 0.3, 0.0, 0.8, 0.1),
"homophily": Slider("Homophily", 0.4, 0.0, 1, 0.1),
"width": 20,
"height": 20,
}
Expand Down
6 changes: 3 additions & 3 deletions mesa/examples/basic/schelling/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(
width: int = 40,
density: float = 0.8,
minority_pc: float = 0.5,
homophily: int = 3,
homophily: float = 0.3,
radius: int = 1,
seed=None,
):
Expand All @@ -24,7 +24,7 @@ def __init__(
height: Height of the grid
density: Initial chance for a cell to be populated (0-1)
minority_pc: Chance for an agent to be in minority class (0-1)
homophily: Minimum number of similar neighbors needed for happiness
homophily_ratio: Ratio of similar neighbors to total neighbors needed for happiness
radius: Search radius for checking neighbor similarity
seed: Seed for reproducibility
"""
Expand All @@ -35,7 +35,7 @@ def __init__(
self.width = width
self.density = density
self.minority_pc = minority_pc
self.homophily = homophily
self.homophily_ratio = homophily
self.radius = radius

# Initialize grid
Expand Down

0 comments on commit 4132e43

Please sign in to comment.