Class IBSCPopulation


public class IBSCPopulation extends IBSMCPopulation
The core class for individual based simulations with a single continuous trait/strategy. As compared to the more generic IBSMCPopulation this subclass takes advantage of simplifications that are possible for a single trait/strategy.
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).

  • 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
    • haveSameStrategy

      public boolean haveSameStrategy(int a, int b)
      Description copied from class: IBSPopulation
      Check if individuals with index a and index b have the same strategies.
      Overrides:
      haveSameStrategy 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 strategies
    • isSameStrategy

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

      Note: this test is only meaningful before strategy gets committed.

      Overrides:
      isSameStrategy in class IBSMCPopulation
      Parameters:
      a - index of individual
      Returns:
      true if strategy remained the same
      See Also:
    • swapStrategies

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

      Note: the strategies still need to be committed.

      Overrides:
      swapStrategies 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 strategy. Only works if adjustScores==true.

      Important: new strategy 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
    • prepareStrategies

      public void prepareStrategies()
      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:
      prepareStrategies in class IBSMCPopulation
      See Also:
    • 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 IBSMCPopulation
      Parameters:
      me - the index of the player that needs to have its new strategy 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)