Class SegregationModel

java.lang.Object
org.episteme.social.sociology.SegregationModel

public final class SegregationModel extends Object
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.
  • 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

      public static Real calculateSegregationIndex(SegregationModel.AgentType[][] grid)
      Calculates the Segregation (Dissimilarity) Index. Uses a simplified block-level dissimilarity measure.
      Parameters:
      grid - the simulation grid
      Returns:
      the segregation index score
    • calculateHappiness

      public static Real calculateHappiness(SegregationModel.AgentType[][] grid, Real threshold)
      Calculates the percentage of agents who are currently "happy".
      Parameters:
      grid - the simulation grid
      threshold - the happiness threshold used
      Returns:
      happiness rate (0.0 to 1.0)
    • visualize

      public static String visualize(SegregationModel.AgentType[][] grid)
      Generates a string visualization of the grid.
      Parameters:
      grid - the grid to visualize
      Returns:
      string representation