Class IBSGroup

Object
IBSGroup

public class IBSGroup extends Object
Interaction and reference groups in IBS models.
Author:
Christoph Hauert
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Types of sampling of groups for interactions or references: none no interactions all interact with all neighbours random interact with n random neighbours
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) int
    The index of the focal individual.
    (package private) int[]
    Reference to the indices of the members of the group.
    private static int[]
    The empty neighbourhood of a lone individual.
    private int[]
    Storage for selected interaction or reference groups.
    (package private) int
    The effective sample size.
    (package private) int
    The sample size requested.
    protected RNGDistribution
    The shared random number generator to ensure reproducibility of results.
    (package private) IBSGroup.SamplingType
    The current sampling type for the formation of interaction or reference groups.
    (package private) boolean
    The flag indicating whether to include the focal individual when sampling.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new interaction or competition group.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the index of the focal individual.
    int[]
    Gets the array of indices of the interaction/reference group members.
    int
    Get the number of interactions with random neighbours.
    int
    Get the number of interactions with random neighbours.
    Gets the type of sampling of interaction/reference groups.
    boolean
    Gets whether random sampling includes the focal individual or not.
    boolean
    Checks whether the type of sampling of interaction/reference groups is type.
    int[]
    pickAt(int me, Geometry geom, boolean out)
    Picks an interaction/reference group for the focal individual focal and the population structure geom.
    private void
    pickRandom(int size)
    Pick group of nSamples random individual with indices 0 - (size-1).
    void
    setGroupAt(int focal, int[] group, int size)
    Sets the interaction/reference group to group with a size size and the focal indiviual focal.
    void
    setNSamples(int nSamples)
    Set the number of interactions with random neighbours.
    void
    Sets the type of sampling of interaction/reference groups to type.
    void
    setSelf(boolean self)
    Sets whether random sampling should include the focal individual or not.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • loner

      private static int[] loner
      The empty neighbourhood of a lone individual.
    • mem

      private int[] mem
      Storage for selected interaction or reference groups.
    • group

      int[] group
      Reference to the indices of the members of the group.
    • focal

      int focal
      The index of the focal individual.
    • rng

      protected RNGDistribution rng
      The shared random number generator to ensure reproducibility of results.
      See Also:
    • samplingType

      IBSGroup.SamplingType samplingType
      The current sampling type for the formation of interaction or reference groups.
    • nSamples

      int nSamples
      The sample size requested. Default is a single sample for RANDOM sampling.
    • nSampled

      int nSampled
      The effective sample size. nSampled < nSamples may hold depending on the population structure.
    • self

      boolean self
      The flag indicating whether to include the focal individual when sampling.

      Notes

      In the original Moran process the offspring can replace the parent. Hence, for reference groups in well-mixed populations it makes sense to include the focal individual. In contrast, self-interactions may simplify some analytical considerations but in IBS never make sense.
  • Constructor Details

    • IBSGroup

      public IBSGroup(RNGDistribution rng)
      Create a new interaction or competition group. The global, shared random number generator rng must be passed here to ensure reproducibility of the simulation results.

      Note: The default (empty) constructor does not need to be declared private in order to prevent instantiation. The compiler does not generate a default constructor if another one exists.

      Parameters:
      rng - the random number generator for picking interaction or reference groups
  • Method Details

    • setSampling

      public void setSampling(IBSGroup.SamplingType type)
      Sets the type of sampling of interaction/reference groups to type.
      Parameters:
      type - the type of sampling
    • getSampling

      public IBSGroup.SamplingType getSampling()
      Gets the type of sampling of interaction/reference groups.
      Returns:
      the type of sampling
    • getNSamples

      public int getNSamples()
      Get the number of interactions with random neighbours.
      Returns:
      the number of interactions
    • setNSamples

      public void setNSamples(int nSamples)
      Set the number of interactions with random neighbours.
      Parameters:
      nSamples - the number of interactions
    • isSampling

      public boolean isSampling(IBSGroup.SamplingType type)
      Checks whether the type of sampling of interaction/reference groups is type.
      Parameters:
      type - the sampling type to check
      Returns:
      true if the type of sampling is type
    • getNSampled

      public int getNSampled()
      Get the number of interactions with random neighbours.
      Returns:
      the number of interactions
    • setSelf

      public void setSelf(boolean self)
      Sets whether random sampling should include the focal individual or not.
      Parameters:
      self - true if sampling includes focal
    • getSelf

      public boolean getSelf()
      Gets whether random sampling includes the focal individual or not.
      Returns:
      true if sampling includes focal
    • setGroupAt

      public void setGroupAt(int focal, int[] group, int size)
      Sets the interaction/reference group to group with a size size and the focal indiviual focal.
      Parameters:
      focal - the index of the focal individual
      group - the array with the indices of the members of the group
      size - the size of the group
    • getGroup

      public int[] getGroup()
      Gets the array of indices of the interaction/reference group members.
      Returns:
      the interaction/reference group
    • getFocal

      public int getFocal()
      Gets the index of the focal individual.
      Returns:
      the index of the focal individual
    • pickAt

      public int[] pickAt(int me, Geometry geom, boolean out)
      Picks an interaction/reference group for the focal individual focal and the population structure geom. If the flag out == true then the group is sampled from the outgoing neighbours (downstream) of the focal and from the incoming neighbours (upstream) otherwise.

      Important: For efficiency the sampled group may be a direct reference to the population structure. For example, group = out[focal] to reference all neighbours of the focal individual. As a consequence the array group is untouchable and must never be manipulated because this would result in permanent changes of the population structure.

      Parameters:
      me - the index of the focal individual
      geom - the geometry of the population
      out - the flag indicating whether to sample the group from the outgoing or incoming neighbours
      Returns:
      the interaction/reference group (same as group)
      See Also:
    • pickRandom

      private void pickRandom(int size)
      Pick group of nSamples random individual with indices 0 - (size-1). The focal individual is included if self==true.
      Parameters:
      size - the maximum index to pick