-
Notifications
You must be signed in to change notification settings - Fork 892
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
Fix: Schelling Model Neighbor Similarity Calculation #2518
base: main
Are you sure you want to change the base?
Fix: Schelling Model Neighbor Similarity Calculation #2518
Conversation
Performance benchmarks:
|
else: | ||
self.model.happy += 1 | ||
# If unhappy, move to a random empty cell | ||
if similarity_fraction < self.model.homophily / 8.0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not change homopily at the model level to be a fraction? That makes the model independent of the neighborhood size.
if hasattr(neighbor, "type") and neighbor.type == self.type | ||
] | ||
total_neighbors = [ | ||
neighbor for neighbor in neighbors if hasattr(neighbor, "type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you iterate twice, with one check being done in both. You can make this more efficient by looping only once.
Summary
Fixed #2515 Schelling segregation model to calculate agent happiness using neighbor similarity fraction, aligning with Wikipedia and NetLogo standards.
Bug / Issue
Current model incorrectly counts empty spaces as neighbors, leading to inaccurate agent happiness determination.
Implementation
Modified
SchellingAgent.step()
to: