Class SegregationModel
java.lang.Object
org.episteme.social.sociology.SegregationModel
An implementation of Thomas Schelling's model of spatial segregation.
demonstrating how individual preferences for similar neighbors (homophily) can lead
to macro-level segregation, even with mild preferences.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTypes of agents or occupancy status in the grid.static final recordRepresents a snapshot of the grid at a specific simulation step. -
Method Summary
Modifier and TypeMethodDescriptionstatic RealcalculateHappiness(SegregationModel.AgentType[][] grid, Real threshold) Calculates the percentage of agents who are currently "happy".static RealCalculates the Segregation (Dissimilarity) Index.static List<SegregationModel.GridState> Runs the Schelling segregation simulation.static Stringvisualize(SegregationModel.AgentType[][] grid) Generates a string visualization of the grid.
-
Method Details
-
simulate
public static List<SegregationModel.GridState> simulate(int size, Real density, Real threshold, int steps) Runs the Schelling segregation simulation.- Parameters:
size- Dimensions of the grid (size x size)density- Fraction of cells initially occupied (0.0 to 1.0)threshold- Minimum fraction of similar neighbors required for an agent to be "happy"steps- Maximum number of simulation steps- Returns:
- List of GridState objects representing the simulation history
-
calculateSegregationIndex
Calculates the Segregation (Dissimilarity) Index. Uses a simplified block-level dissimilarity measure.- Parameters:
grid- the simulation grid- Returns:
- the segregation index score
-
calculateHappiness
Calculates the percentage of agents who are currently "happy".- Parameters:
grid- the simulation gridthreshold- the happiness threshold used- Returns:
- happiness rate (0.0 to 1.0)
-
visualize
Generates a string visualization of the grid.- Parameters:
grid- the grid to visualize- Returns:
- string representation
-