Class IBSCPopulation


public class IBSCPopulation extends IBSMCPopulation
The core class for individual based simulations with a single continuous trait. As compared to the more generic IBSMCPopulation this subclass takes advantage of simplifications that are possible for a single trait.
Author:
Christoph Hauert
See Also:
  • Field Details

    • pairmodule

      protected IBS.HasIBS.CPairs pairmodule
      For pairwise interaction modules module==pairmodule holds and null otherwise. Convenience field to reduce the number of (unnecessary) casts.
      See Also:
    • groupmodule

      protected IBS.HasIBS.CGroups groupmodule
      For group interaction modules module==groupmodule holds and null otherwise. Convenience field to reduce the number of (unnecessary) casts.
      See Also:
    • opponent

      IBSCPopulation opponent
      The interaction partner/opponent of this population opponent.getModule()==getModule().getOpponent(). In intra-species interactions opponent==this. Convenience field.

      Note: This deliberately hides IBSPopulation.opponent. The two variables point to the same object but this setup avoids unnecessary casts because only Discrete modules generate IBSDPopulation(s).

    • myTrait

      double myTrait
      Temporary storage for the traits of the focal individual. This deliberately hides the array of the same name in IBSMCPopulation.
  • Constructor Details

    • IBSCPopulation

      public IBSCPopulation(EvoLudo engine, Continuous module)
      Creates a population of individuals with a single continuous trait for IBS simulations.
      Parameters:
      engine - the pacemaker for running the model
      module - the module that defines the rules of the game
  • Method Details

    • setOpponentPop

      public void setOpponentPop(IBSPopulation opponent)
      Description copied from class: IBSPopulation
      Set the interaction partner/opponent of this population.
      Overrides:
      setOpponentPop in class IBSMCPopulation
      Parameters:
      opponent - the interaction partner/opponent
    • haveSameTrait

      public boolean haveSameTrait(int a, int b)
      Description copied from class: IBSPopulation
      Check if individuals with index a and index b have the same traits.
      Overrides:
      haveSameTrait in class IBSMCPopulation
      Parameters:
      a - the index of first individual
      b - the index of second individual
      Returns:
      true if the two individuals have the same traits
    • isSameTrait

      public boolean isSameTrait(int a)
      Description copied from class: IBSPopulation
      Check if individual with index a has switched traits.

      Note: this test is only meaningful before trait are committed.

      Overrides:
      isSameTrait in class IBSMCPopulation
      Parameters:
      a - index of individual
      Returns:
      true if trait remained unchanged
      See Also:
    • swapTraits

      public void swapTraits(int a, int b)
      Description copied from class: IBSPopulation
      Swap traits of individuals with index a and index b.

      Note: the traits still need to be committed.

      Overrides:
      swapTraits in class IBSMCPopulation
      Parameters:
      a - the index of first individual
      b - the index of second individual
      See Also:
    • playPairGameAt

      public void playPairGameAt(IBSGroup group)
      Description copied from class: IBSPopulation
      Play a pairwise interaction with the individuals in group.
      Overrides:
      playPairGameAt in class IBSMCPopulation
      Parameters:
      group - the group of individuals interacting in pairs
    • adjustPairGameScoresAt

      public void adjustPairGameScoresAt(int me)
      Description copied from class: IBSPopulation
      Adjusts scores of focal individual with index me and its neighbors after me changed trait. Only works if adjustScores==true.

      Important: new trait must not yet have been committed.

      Overrides:
      adjustPairGameScoresAt in class IBSMCPopulation
      Parameters:
      me - the index of the focal individual
    • playGroupGameAt

      public void playGroupGameAt(IBSGroup group)
      Description copied from class: IBSPopulation
      Play a group interaction with the individuals in group.
      Overrides:
      playGroupGameAt in class IBSMCPopulation
      Parameters:
      group - the group of interacting individuals
    • yalpGroupGameAt

      public void yalpGroupGameAt(IBSGroup group)
      Description copied from class: IBSPopulation
      Counterpart of IBSPopulation.playGroupGameAt(IBSGroup), IBSPopulation.playGameAt(int) and/or IBSPopulation.playGameSyncAt(int). Removes the payoffs of group interactions.
      Overrides:
      yalpGroupGameAt in class IBSMCPopulation
      Parameters:
      group - the interaction group
    • prepareTraits

      public void prepareTraits()
      Description copied from class: IBSPopulation
      Prior to a synchronous update step the current state must be duplicated in preparation for processing the next step.
      Overrides:
      prepareTraits in class IBSMCPopulation
      See Also:
    • commitTraitAt

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

      public void getTraitHistogramData(double[] bins)
      Creates a histogram for trait and returns the result in the array bins.
      Parameters:
      bins - the array to store the histogram(s)