Class CDLP

All Implemented Interfaces:
Runnable, IBS.HasIBS, IBS.HasIBS.DGroups, IBS.HasIBS.DPairs, MilestoneListener, ODE.HasDE, ODE.HasODE, PDE.HasPDE, SDE.HasSDE, Features, Features.Groups, Features.Pairs, HasHistogram, HasHistogram.Degree, HasHistogram.Fitness, HasHistogram.StatisticsStationary, HasMean, HasMean.Fitness, HasMean.Strategy, HasPop2D, HasPop2D.Fitness, HasPop2D.Strategy, HasPop3D, HasPop3D.Fitness, HasPop3D.Strategy, HasS3, CLOProvider
Direct Known Subclasses:
CDLPQ, simCDLP

public class CDLP extends CDL
Cooperation in voluntary (non-linear) public goods interactions with peer punishment.
Author:
Christoph Hauert
  • Field Details

    • PUNISH

      public static final int PUNISH
      The trait (and index) value of peer punishers.
      See Also:
    • costPeerPunish

      double costPeerPunish
      The cost of peer punishment of non-contributors.
      See Also:
    • finePeerPunish

      double finePeerPunish
      The fine for peer punishment of non-contributors.
      See Also:
    • leniencyCoop

      double leniencyCoop
      The leniency of peer punishers towards cooperators (0: full leninecy, 1: no leninecy). Punishment of cooperators applies only if they happen to find themselves in an interaction group that reveals them as second-order free riders. For example, a group including a cooperator, a peer punisher and a defector such that the peer punisher notices the failure of the cooperator to punish the defector(s). The default is full leniency.
    • leniencyLoner

      double leniencyLoner
      The leniency of peer punishers towards loners (0: full leninecy, 1: no leninecy). The default is full leniency.
    • cloLeniencyCooperators

      public final CLOption cloLeniencyCooperators
      Command line option to set the leniency of peer punishers towards cooperators, provided the composition of the interaction group reveals them as second-order free riders.
    • cloLeniencyLoners

      public final CLOption cloLeniencyLoners
      Command line option to set the leniency of peer punishers towards loners.
    • cloPunishment

      public final CLOption cloPunishment
      Command line option to set the fine of peer punishment for non-contributors.
    • cloCostPunish

      public final CLOption cloCostPunish
      Command line option to set the cost of peer punishment.
  • Constructor Details

    • CDLP

      public CDLP(EvoLudo engine)
      Create a new instance of the module for voluntary public goods games with peer punishment.
      Parameters:
      engine - the manager of modules and pacemaker for running the model
  • Method Details

    • load

      public void load()
      Description copied from class: Module
      Load new module and perform basic initializations.
      Overrides:
      load in class CDL
      See Also:
    • getAuthors

      public String getAuthors()
      Description copied from class: Module
      Returns a string with information about the authors of the module.
      Overrides:
      getAuthors in class CDL
      Returns:
      the names of the authors
    • getTitle

      public String getTitle()
      Description copied from class: Module
      Returns title of active module, e.g. 2x2 games in TBT returns "2x2 Games".
      Overrides:
      getTitle in class CDL
      Returns:
      the title of active module
    • getMinGameScore

      public double getMinGameScore()
      Description copied from class: Module
      Calculates and returns the minimum payoff/score of an individual. This value is important for converting payoffs/scores into probabilities, for scaling graphical output and some optimizations.
      Overrides:
      getMinGameScore in class CDL
      Returns:
      the minimum payoff/score
      See Also:
    • getMonoGameScore

      public double getMonoGameScore(int type)
      Calculate and return the payoff/score of individuals in monomorphic populations with trait/strategy type.

      Note: Optional implementation. Returns Double#NaN if not defined or not implemented.

      Note, monomorphic populations of peer punishers have the same payoff as monomorphic populations of cooperators.

      Overrides:
      getMonoGameScore in class CDL
      Parameters:
      type - trait/strategy
      Returns:
      payoff/score in monomorphic population with trait/strategy type
    • pairScores

      public double pairScores(int me, int[] traitCount, double[] traitScore)
      Calculate and return total (accumulated) payoff/score for pairwise interactions of the focal individual with trait/strategy me against opponents with different traits/strategies. The respective numbers of each of the nTraits opponent traits/strategies are provided in the array tCount. The payoffs/scores for each of the nTraits opponent traits/strategies must be stored and returned in the array tScore.

      Important: must be overridden and implemented in subclasses that define game interactions between pairs of individuals (nGroup=2, pairwise=true), otherwise see IBS.HasIBS.DGroups.groupScores(int[], double[]).

      Note: Leniency with cooperators (and punishing cooperators that failed to punish defectors) does not matter in pairwise interactions because this requires at least groups of three or more players. For example a cooperator, a defector and a punisher interact. In such a group composition the cooperator reveals the fact that it does not punish the defector (second-order free riding) and in turn may get punished by the punisher.

      Specified by:
      pairScores in interface IBS.HasIBS.DPairs
      Overrides:
      pairScores in class CDL
      Parameters:
      me - the trait index of the focal individual
      traitCount - number of opponents with each trait/strategy
      traitScore - array for returning the scores of each opponent trait/strategy
      Returns:
      score of focal individual me accumulated over all interactions
    • groupScores

      public void groupScores(int[] traitCount, double[] traitScore)
      Description copied from interface: IBS.HasIBS.DGroups
      Calculate the payoff/score for interactions in groups consisting of traits/strategies with respective numbers given in the array tCount. The interaction group size is given by the sum over tCount[i] for i=0,1,...,nTraits. The payoffs/scores for each of the nTraits traits/strategies must be stored and returned in the array tScore.

      Important: must be overridden and implemented in subclasses that define game interactions among groups of individuals (for groups with sizes nGroup>2, otherwise see IBS.HasIBS.DPairs.pairScores(int, int[], double[])).

      Specified by:
      groupScores in interface IBS.HasIBS.DGroups
      Overrides:
      groupScores in class CDL
      Parameters:
      traitCount - group composition given by the number of individuals with each trait/strategy
      traitScore - array for returning the payoffs/scores of each trait/strategy
    • mixedScores

      public void mixedScores(int[] count, int n, double[] traitScores)
      Calculate the average payoff/score in a finite population with the number of each trait/strategy provided in count for interaction groups of size n. The payoffs/scores for each of the nTraits traits/strategies must be stored and returned in the array traitScores.

      Notes:

      For payoff calculations:
      • each strategy sees one less of its own type in its environment
      • the size of the environment is nPopulation-1
      • the fact that the payoff of each strategy does not depend on its own type simplifies things
      If explicit calculations of the well-mixed scores are not available, interactions with everyone in well-mixed populations should be checked for and excluded with a warning in IBS.check() (see IBSMCPopulation for an example).

      Important:

      Must be overridden and implemented in subclasses that define game interactions in well-mixed populations where individuals interact with everyone else. Computationally it is not feasible to cover this scenario with IBS.HasIBS.DPairs.pairScores(int, int[], double[]) or IBS.HasIBS.DGroups.groupScores(int[], double[]), respectively.
      standard non-linear PGG:
      \[ \begin{align} f_L =& c \sigma \\ f_D =& \frac{X}{M-1}\frac{N}{M-N} (B + S) + H_2(X+Y-1, 0, M-X-Y, N-1) \sigma c \\ f_C =& \frac{(r_1-1)N}{M-N} \left(1-H_2(X+Y-1, 0, M-X-Y, N-1)\right) c +\\ & \frac{N}{M-N}\left(\frac{X-2}{M-1} S - \frac{Y}{M-1} B\right) + H_2(X+Y-1, 0, M-X-Y, N-1) \sigma c \end{align} \] with \[ \begin{align} B =& \frac{M-1}{X+Y} \frac{M-N}{M}\left(r_1 - \frac{2 S}{N-1}\right) \times \left(\frac{N}{M-N} - \frac{\big(1-H_2(X+Y-1, 0, M-X-Y, N)\big)M}{N(X+Y-1)}\right) c \\ S =& \frac{(r_\text{all}-r_1)(X-1)}{(X+Y-2)} c \end{align} \] using \[ H_2(X, x, Y, y) = \frac{\binom{X}{x}\binom{Y}{y}}{\binom{X+Y}{x+y}} \]
      other's only non-linear PGG:
      \[ \begin{align} f_L =& c \sigma \\ f_D =& \frac{X}{M-1} \frac{N}{M-N} (B + S) + H_2(X+Y-1, 0, M-X-Y, N-1) \sigma c \\ f_C =& \frac{X-2}{M-1} \frac{N}{M-N} (B + S) +\frac{r_1 (N-1)}{(M-N)(X+Y)}c- \frac{N}{M-N}\left(\frac{r_1 (M-X-Y-N+1)}{N(X+Y)(X+Y-1)}+1\right)\times \\ & \left(1-H_2(X+Y-1, 0, M-X-Y, N-1)\right)c+ H_2(X+Y-1, 0, M-X-Y, N-1) \sigma c \end{align} \] with \[ \begin{align} B =& \frac{M-1}{X+Y} \frac{M-N}{M} \left(r_1 - \frac{2 S}{N-1}\right) \times \left(\frac{N}{M-N} - \frac{\big(1-H_2(X+Y-1, 0, M-X-Y, N)\big)M}{N(X+Y-1)}\right)c \\ S =& \frac{(r_\text{all}-r_1)(X-1)}{X+Y-2}\frac{N-1}{N-2}c. \end{align} \]

      Proper sampling in finite populations - formulas for standard public goods interactions with private punishment: \[ \begin{align} f_C =& \sigma-\frac w{M-1}(N-1)\delta\beta\\ f_D =& B-\frac w{M-1}(N-1)\beta\\ f_C =& B-F(z)c-w(N-1)G(y)\alpha\beta\\ f_P =& B-F(z)c-\frac y{M-1}(N-1)\gamma-x(N-1)G(y)\alpha\gamma-\frac z{M-1}(N-1)\delta\gamma \end{align} \] with \[ \begin{align} B =& \frac{\binom z{N-1}}{\binom{M-1}{N-1}}\sigma+r\frac {x+w}{M-z-1}\times\\ \left(1-\frac 1{N(M-z)}\left( M-(z-N+1)\frac{\binom z{N-1}}{\binom{M-1}{N-1}}\right)\right) c\\ F(z) =& 1-\frac rN\frac{M-N}{M-z-1}+\frac{\binom z{N-1}}{\binom{M-1}{N-1}} \left(\frac rN \frac{z+1}{M-z-1}+r\frac{M-z-2}{M-z-1}-1\right)\\ G(y) =& \frac 1{M-1}-\frac 1{M-y-1}\frac{\binom{M-y-1}{N-1}}{\binom{M-1}{N-1}} \end{align} \]

      Specified by:
      mixedScores in interface IBS.HasIBS.DGroups
      Overrides:
      mixedScores in class CDL
      Parameters:
      count - number of individuals for each trait/strategy
      n - interaction group size
      traitScores - array for returning the payoffs/scores of each trait/strategy
    • avgScores

      public void avgScores(double[] density, int n, double[] avgscores)
      Description copied from class: CDL
      Calculate the average payoff/score for the frequency of traits/strategies specified in the array density for interactions in groups of size n. The average payoffs/scores for each of the nTraits traits/strategies must be stored and returned in the array avgscores.

      Note: needs to be thread safe for parallel processing of PDE's.

      IMPORTANT: one of

      should be implemented in modules that advertise the model types ODE, SDE or PDE.

      Alternatively, the method ODE.getDerivatives(double, double[], double[], double[]) may be overridden in a subclass of ODE, which may prevent calls to avgScores(...) altogether.

      standard non-linear PGG:
      \[ \begin{align} f_L =& c \sigma \\ f_D =& x (B + S) c + \sigma c z^{N-1} \\ f_C =& (r_1-1)\left(1-z^{N-1}\right)c-y B c + x S c + \sigma c z^{N-1} \end{align} \] with \[ \begin{align} B =& \frac1{1-z} \left(r_1 - \frac{2 S}{N-1}\right) \left(1-\frac{1-z^N}{N (1-z)}\right) \\ S =& x \frac{r_\text{all}-r_1}{1-z} \end{align} \]
      other's only non-linear PGG:
      \[ \begin{align} f_L =& c \sigma \\ f_D =& x (B + S) c + \sigma c z^{N-1} \\ f_C =& x (B + S) c - \left(1-z^{N-1}\right)c + \sigma c z^{N-1} \end{align} \] with \[ \begin{align} B =& \frac1{1-z} \left(r_1 - \frac{2 S}{N-1}\right) \left(1 - \frac{1-z^N}{N (1-z)}\right) \\ S =& x \frac{r_\text{all}-r_1}{1-z}\frac{N-1}{N-2} \end{align} \]
      Specified by:
      avgScores in interface ODE.HasDE
      Overrides:
      avgScores in class CDL
      Parameters:
      density - the frequency/density of each trait/strategy
      n - the size of interaction groups
      avgscores - the array for storing the average payoffs/scores for each strategic type
    • setPunishCost

      public void setPunishCost(double aValue)
      Set the cost of peer punishment of non-contributors.
      Parameters:
      aValue - the cost of cooperation.
    • getPunishCost

      public double getPunishCost()
      Get the cost of peer punishment of non-contributors.
      Returns:
      the cost of peer punishment.
    • setPunishFine

      public void setPunishFine(double aValue)
      Set the fine peer punishment for non-contributors.
      Parameters:
      aValue - the peer punishment fine.
    • getPunishFine

      public double getPunishFine()
      Get the peer punishment fine to non-contributors.
      Returns:
      the peer punishment fine.
    • setLeniencyCoop

      public void setLeniencyCoop(double aValue)
      Set the leniency towards cooperators, provided the composition of the interaction group reveals them as second-order free riders.
      Parameters:
      aValue - the leniency towards cooperators.
      See Also:
    • getLeniencyCoop

      public double getLeniencyCoop()
      Get the leniency towards cooperators, provided the composition of the interaction group reveals them as second-order free riders.
      Returns:
      the leniency towards cooperators.
      See Also:
    • setLeniencyLoner

      public void setLeniencyLoner(double aValue)
      Set the leniency of punishment towards loners.
      Parameters:
      aValue - the leniency towards loners.
      See Also:
    • getLeniencyLoner

      public double getLeniencyLoner()
      Get the leniency towards loners.
      Returns:
      the leniency towards loners.
      See Also:
    • collectCLO

      public void collectCLO(CLOParser parser)
      Description copied from interface: CLOProvider
      All providers of command line options must implement this method to collect their options.

      Each command line option is (uniquely) identified by it's name (see CLOption.getName()), which corresponds to the long version of the option. If an attempt is made to add an option with a name that already exists, the parser issues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and call super.collectCLO(CLOParser) at the end such that subclasses are able to override command line options specified in a parental class.

      Override this method in subclasses to add further command line options. Subclasses must make sure that they include a call to super.

      Specified by:
      collectCLO in interface CLOProvider
      Overrides:
      collectCLO in class CDL
      Parameters:
      parser - the reference to parser that manages command line options
      See Also:
    • createIBSPop

      public CDL.IBSPop createIBSPop()
      Opportunity to supply custom individual based simulations.

      The parent class CDL admits kaleidoscopes. None have been identified for CDLP - use default IBS model.

      Overrides:
      createIBSPop in class CDL
      Returns:
      the custom IBSPopulation or null to use default.