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

    • cpairmodule

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

      final Model.HasIBS.CGroups cgroupmodule
      For group interaction modules module==groupmodule holds and null otherwise. Convenience field to reduce the number of (unnecessary) casts.
      See Also:
  • 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)
      Play a pairwise interaction with the individuals in group.

      Continuous modules with a single trait never get here.

      Continuous modules with multiple traits never get here.

      Overrides:
      playPairGameAt in class IBSMCPopulation
      Parameters:
      group - the group of individuals interacting in pairs
      See Also:
    • adjustPairGameScoresAt

      public void adjustPairGameScoresAt(int me)
      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.

      Continuous modules with a single trait never get here.

      Continuous modules with multiple traits never get here.

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

      public void playGroupGameAt(IBSGroup group)
      Play a group interaction with the individuals in group.

      Continuous modules with a single trait never get here.

      Continuous modules with multiple traits never get here.

      Overrides:
      playGroupGameAt in class IBSMCPopulation
      Parameters:
      group - the group of interacting individuals
      See Also:
    • playGroupSequentiallyAt

      void playGroupSequentiallyAt(int me, IBSGroup group, int nGroup)
      Description copied from class: IBSMCPopulation
      Evaluate sequential group interactions when not enough opponents are available simultaneously.
      Overrides:
      playGroupSequentiallyAt in class IBSMCPopulation
      Parameters:
      me - focal player index
      group - sampled opponent group
      nGroup - number of players participating in each interaction
    • playGroupOnceAt

      void playGroupOnceAt(int me, IBSGroup group)
      Description copied from class: IBSMCPopulation
      Evaluate a single group interaction with the sampled opponents.
      Overrides:
      playGroupOnceAt in class IBSMCPopulation
      Parameters:
      me - focal player index
      group - sampled opponent group
    • yalpGroupGameAt

      public void yalpGroupGameAt(IBSGroup group)
      Counterpart of IBSPopulation.playGroupGameAt(IBSGroup), IBSPopulation.playGameAt(int) and/or IBSPopulation.playGameSyncAt(int). Removes the payoffs of group interactions.

      Continuous modules with a single trait never get here.

      Continuous modules with multiple traits never get here.

      Overrides:
      yalpGroupGameAt in class IBSMCPopulation
      Parameters:
      group - the interaction group
      See Also:
    • 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)