Class DemesTBT.IBSPop

All Implemented Interfaces:
ChangeListener, MilestoneListener
Enclosing class:
DemesTBT

public class DemesTBT.IBSPop extends TBT.IBSPop implements MilestoneListener, ChangeListener
Custom implemenation for individual based simulations in deme structured populations.
  • Field Details

    • distrMigration

      protected RNGDistribution.Geometric distrMigration
      The distribution for migration events.
    • distrMutationMigration

      protected RNGDistribution.Geometric distrMutationMigration
      The distribution for migration events.
    • pure

      private double[] pure
      The time spent in homogenous states.
    • demeTypeCount

      int[][] demeTypeCount
      The number of traits in each deme.
    • optimizeMigration

      boolean optimizeMigration
      The flag to indicate whether to optimize migration.
    • prevsample

      protected double prevsample
      Time of previous sample.
  • Constructor Details

    • IBSPop

      protected IBSPop(EvoLudo engine, DemesTBT module)
      Create a new instance of the IBSPop class.
      Parameters:
      engine - the pace maker of the simulation
      module - the module that defines the interactions
  • Method Details

    • check

      public boolean check()
      Description copied from class: IBSPopulation
      Check all model parameters for consistency and adjust if necessary (and feasible). Returns true if adjustments require a reset. Free memory if possible and request a reset if new memory needs to be allocated.
      Overrides:
      check in class TBT.IBSPop
      Returns:
      true if reset is required
      See Also:
    • init

      public void init()
      Description copied from class: IBSPopulation
      Initialize the model. All parameters must be consistent. Subclasses must override this method to generate the initial strategy configuration and call super.

      Note: Initialization leaves the interaction and competition structures untouched

      Overrides:
      init in class IBSDPopulation
      See Also:
    • getStatus

      public String getStatus()
      Description copied from class: IBSPopulation
      Gets the status of the as a formatted string. This is typically used in the GUI to summarize the progress of the model.
      Overrides:
      getStatus in class TBT.IBSPop
      Returns:
      the status of the population
    • checkConvergence

      public boolean checkConvergence()
      Description copied from class: IBSPopulation
      Check if population has converged. By default true if population is monomorphic and no (zero) mutations. However, different implementations may have different criteria for convergence.

      Note: This tends to be less restrictive than reaching an absorbing state. Typically convergence is used as a criterion to abort simulations.

      Overrides:
      checkConvergence in class IBSDPopulation
      Returns:
      true if converged.
    • homoDemes

      protected int homoDemes()
      Determine the number of homogeneous demes in trait A, provided that all demes are homogeneous. Returns -1 if any deme is heterogeneous.
      Returns:
      the number of homogeneous A demes or -1 if any deme is heterogeneous
    • doDiffusionMigration

      public void doDiffusionMigration()
      Perform diffusion migration, which is implemented as two players swap their locations while leaving their respective neighbourhood structure untouched.

      Override IBSPopulation.doDiffusionMigration() to take demes into account.

      Overrides:
      doDiffusionMigration in class IBSPopulation
    • doDeathBirthMigration

      public void doDeathBirthMigration()
      Perform a death-birth migration, where a member of the population (selected uniformly at random) dies and the remaining individuals compete to repopulate the vacant site. One competitor succeeds with a probability proportional proportional to fitness.

      Note: This is almost identical to Moran (birth-death) updating in well-mixed populations

      1. Override IBSPopulation.doDeathBirthMigration() to take demes into account.
      2. Almost identical (victim and migrant always different) to Moran (death-birth) updating in well-mixed population.
      Overrides:
      doDeathBirthMigration in class IBSPopulation
    • updatePlayerMoranBirthDeathAt

      protected void updatePlayerMoranBirthDeathAt(int parent)
      Description copied from class: IBSPopulation
      Perform a Moran (Birth-death) update for the focal individual with index parent to produce a clonal offspring and replace one of the parent's neighbours selected uniformly at random. This is the original Moran process where the offspring can replace the parent in well-mixed populations.
      Overrides:
      updatePlayerMoranBirthDeathAt in class IBSPopulation
      Parameters:
      parent - the index of the parent
    • modelChanged

      public void modelChanged(ChangeListener.PendingAction pending)
      Description copied from interface: ChangeListener
      Called whenever the state of the EvoLudo model changed. Process potentially pending requests.

      Note: the model may process some pending actions directly and without notifying the listeners through modelChanged(PendingAction) first. In particular, this applies to pending actions that fire their own notifications, such as RESET and INIT that in turn trigger modelReset() and modelInit(), respectively.

      Specified by:
      modelChanged in interface ChangeListener
      Parameters:
      pending - pending action that needs to be processed.
      See Also:
    • modelStopped

      public void modelStopped()
      Description copied from interface: MilestoneListener
      Called after a running EvoLudo model stopped because the model converged (or reached an absorbing state).
      Specified by:
      modelStopped in interface MilestoneListener
    • startStatistics

      protected void startStatistics()
      Start collecting statistics.
    • resetStatistics

      protected void resetStatistics()
      Reset statistics.
    • updateStatistics

      protected void updateStatistics(double time)
      Update statistics.
      Parameters:
      time - the time of the sample
    • commitStrategyAt

      public void commitStrategyAt(int me)
      Description copied from class: IBSPopulation
      The change of a strategy of the player at index is stored in a temporary variable and must be committed before proceeding.
      Overrides:
      commitStrategyAt in class IBSDPopulation
      Parameters:
      me - the index of the player that needs to have its new strategy committed
    • commitStrategies

      public void commitStrategies()
      Description copied from class: IBSDPopulation
      After a synchronous update step the new state must be copied back to become the current state.

      For discrete modules, update the strategy count of each type and check if population reached a homogeneous state.

      Overrides:
      commitStrategies in class IBSDPopulation
      See Also:
    • updateScores

      public void updateScores()
      Update the scores of all individuals in the population.

      Note: Overridden to set scores in well-mixed populations more efficiently.

      Overridden to set scores in demes more efficiently

      Overrides:
      updateScores in class IBSDPopulation
    • adjustGameScoresAt

      public void adjustGameScoresAt(int me)
      Adjust scores of focal player me and its neighbours (interaction partners).

      Requirements/notes:

      1. This optimized method is only applicable if IBSGroup.SamplingType.ALL is true and not Geometry.Type.MEANFIELD, i.e. if the interaction group includes all neighbors but not all other members of the population.
      2. For pairwise interactions more efficient approaches are possible but those require direct access to the stratgies and are hence delegated to subclasses.

      Overridden to allow for adjusting scores in well-mixed populations.

      Overridden to set scores in demes more efficiently

      Overrides:
      adjustGameScoresAt in class IBSDPopulation
      Parameters:
      me - the index of the focal individual
      See Also: