Class HierarchicalGeometry


public class HierarchicalGeometry extends AbstractLattice
Hierarchical meta-population structure implementation. Embeds well-mixed or square-lattice demes into recursive layers.
  • Field Details

    • subType

      private GeometryType subType
      The geometry of each hierarchical level.
    • hierarchy

      private int[] hierarchy
      The number of units at each hierarchical level.
    • hierarchyWeight

      private double hierarchyWeight
      Coupling strength between hierarchical levels.
  • Constructor Details

    • HierarchicalGeometry

      public HierarchicalGeometry(EvoLudo engine)
      Create a hierarchical geometry tied to the given engine.
      Parameters:
      engine - EvoLudo pacemaker
  • Method Details

    • parse

      boolean parse(String spec)
      Description copied from class: AbstractGeometry
      Parse geometry-specific CLI options.
      Overrides:
      parse in class AbstractGeometry
      Parameters:
      spec - the argument string without the geometry key
      Returns:
      true if parsing succeeded, false if invalid
    • isSubtype

      public boolean isSubtype(GeometryType type)
      Check if the sub-geometry matches the given type.
      Parameters:
      type - the geometry type to check against
      Returns:
      true if the sub-geometry matches the given type
    • getSubType

      public GeometryType getSubType()
      Retrieve the geometry used within each hierarchy level (e.g. square or well-mixed).
      Returns:
      the geometry used within each hierarchy level (e.g. square or well-mixed)
    • getHierarchyWeight

      public double getHierarchyWeight()
      Report the weight applied to inter-level interactions.
      Returns:
      the weight applied to inter-level interactions
    • getHierarchyLevels

      public int[] getHierarchyLevels()
      Retrieve a copy of the processed hierarchy definition (levels plus individuals per deme).
      Returns:
      a copy of the processed hierarchy definition (levels plus individuals per deme)
    • checkSettings

      protected boolean checkSettings()
      Description copied from class: AbstractGeometry
      Hook for subclasses to implement geometry specific checks.
      Overrides:
      checkSettings in class AbstractGeometry
      Returns:
      true if adjustments require a reset
    • calcUnitSize

      private boolean calcUnitSize()
      Process the hierarchy specifications to calculate the number of units and the size of each unit. On each level there must be at least 2 units for well-mixed hierarchies and each unit must contain at least 2 individuals. For hierarchies with square lattices each level must ahev at least 2x2 units with at least 3x3 individuals each.
      Returns:
      true if the size was adjusted and resetting is required
    • calcSquareUnit

      private int calcSquareUnit(int nHierarchy)
      Calculate the unit size for square-lattice hierarchies, adjusting each level to a perfect square with at least 2x2 units with at least 3x3 individuals each.
      Parameters:
      nHierarchy - the number of hierarchy levels
      Returns:
      the total size of the graph
    • init

      public void init()
      Initialise the geometry.

      Requirements/notes:

      Only well-mixed (complete) or square lattice graphs are currently supported.
      Specified by:
      init in class AbstractGeometry
    • initHierarchy

      private void initHierarchy(int level, int start)
      Utility method to generate hierarchical graphs.
      Parameters:
      level - the hierarchical level
      start - the index of the first node to process
    • isUnique

      public boolean isUnique()
      Description copied from class: AbstractGeometry
      Check if current geometry unique. Only unique geomteries need to be encoded.

      Requirements/notes:

      1. Lattices etc. are not unique because they can be identically recreated.
      2. Complete graphs, stars, wheels, etc. are not unique.
      3. All geometries involving random elements are unique.
      4. All rewired geometries are unique.
      5. Hierarchical geometries require recursive checks of uniqueness.
      Overrides:
      isUnique in class AbstractGeometry
      Returns:
      true if geometry is unique
    • clone

      public HierarchicalGeometry clone()
      Description copied from class: AbstractGeometry
      Clone geometry.

      Requirements/notes:

      1. Overrides clone() in Object but conflicts with GWT's aversion to clone()ing...
      2. Remove @SuppressWarnings("all") to ensure that no other issues crept in when modifying method.
      Overrides:
      clone in class AbstractLattice
      Returns:
      clone of geometry
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractLattice
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class AbstractLattice
    • parseHierarchy

      private void parseHierarchy()
      Parse the hierarchy-related CLI spec, updating subtype, boundary flag and weight, and storing the raw hierarchy levels (without the computed leaf size).