Class CDLPQ
- All Implemented Interfaces:
Runnable,IBS.HasIBS,IBS.HasIBS.DGroups,IBS.HasIBS.DPairs,MilestoneListener,Model.HasDE,Model.HasDE.DGroups,Model.HasDE.EM,Model.HasDE.ODE,Model.HasDE.PDE,Model.HasDE.PDEADV,Model.HasDE.PDERD,Model.HasDE.RK5,Model.HasDE.SDE,Features,Features.Groups,Features.Pairs,Features.Payoffs,HasHistogram,HasHistogram.Degree,HasHistogram.Fitness,HasHistogram.StatisticsStationary,HasMean,HasMean.Fitness,HasMean.Traits,HasPop2D,HasPop2D.Fitness,HasPop2D.Traits,HasPop3D,HasPop3D.Fitness,HasPop3D.Traits,HasS3,CLOProvider
- Direct Known Subclasses:
simCDLPQ
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested classes/interfaces inherited from class CDL
CDL.IBSPopNested classes/interfaces inherited from interface Features
Features.Groups, Features.Multispecies, Features.Pairs, Features.Payoffs, Features.StaticNested classes/interfaces inherited from interface HasHistogram
HasHistogram.Degree, HasHistogram.Fitness, HasHistogram.StatisticsProbability, HasHistogram.StatisticsStationary, HasHistogram.StatisticsTime, HasHistogram.StrategyNested classes/interfaces inherited from interface HasMean
HasMean.Fitness, HasMean.TraitsNested classes/interfaces inherited from interface HasPop2D
HasPop2D.Fitness, HasPop2D.TraitsNested classes/interfaces inherited from interface HasPop3D
HasPop3D.Fitness, HasPop3D.TraitsNested classes/interfaces inherited from interface IBS.HasIBS
IBS.HasIBS.CGroups, IBS.HasIBS.CPairs, IBS.HasIBS.DGroups, IBS.HasIBS.DPairs, IBS.HasIBS.MCGroups, IBS.HasIBS.MCPairsNested classes/interfaces inherited from interface Model.HasDE
Model.HasDE.DGroups, Model.HasDE.DPairs, Model.HasDE.DualDynamics, Model.HasDE.EM, Model.HasDE.ODE, Model.HasDE.PDE, Model.HasDE.PDEADV, Model.HasDE.PDERD, Model.HasDE.RK5, Model.HasDE.SDE -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CLOptionCommand line option to set the cost of pool punishment.final CLOptionCommand line option to set the fine of pool punishment for non-contributors.(package private) doubleThe cost of pool punishment.(package private) doubleThe pool punishment fine for non-contributors.static final intThe trait (and index) value of pool punishers.Fields inherited from class CDLP
cloCostPunish, cloLeniencyCooperators, cloLeniencyLoners, cloPunishment, costPeerPunish, finePeerPunish, leniencyCoop, leniencyLoner, PUNISHFields inherited from class CDL
cloCost, cloInterest, cloLoneCooperator, cloLoneDefector, cloLoner, cloOthers, cloSolo, COOPERATE, costCoop, DEFECT, doSolo, isLinearPGG, LONER, othersOnly, payLoneCoop, payLoneDefect, payLoner, r1, rNFields inherited from class Discrete
cloMonoStop, monoStop, mutation, speciesFields inherited from class Module
active, cloDeathRate, cloGeometry, cloNGroup, cloNPopulation, cloPhase2DAxes, cloTraitColors, cloTraitDisable, cloTraitNames, competition, deathRate, defaultColor, engine, ibs, ID, interaction, logger, map2fitness, markers, model, nActive, name, nGroup, nPopulation, nTraits, opponent, playerUpdate, structure, traitColor, traitName, trajectoryColor, VACANTFields inherited from interface HasS3
CORNER_LEFT, CORNER_RIGHT, CORNER_TOP, EDGE_BOTTOM, EDGE_LEFT, EDGE_RIGHT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidavgScores(double[] density, int n, double[] avgscores) Calculate the average payoff for the frequency of traits specified in the arraystatefor interactions in groups of sizen.voidcollectCLO(CLOParser parser) All providers of command line options must implement this method to collect their options.Returns a string with information about the authors of the module.doubleCalculates and returns the minimum payoff/score of an individual.doublegetMonoPayoff(int type) Calculate and return the payoff/score of individuals in monomorphic populations with traittype.doubleGet the cost of pool punishment.doubleGet the fine for pool punishment.getTitle()Returns title of active module, e.g.voidgroupScores(int[] traitCount, double[] traitScore) Calculate the payoff/score for interactions in groups consisting of traits with respective numbers given in the arraytraitCount.voidload()Load new module and perform basic initializations.voidmixedScores(int[] count, int n, double[] traitScores) Calculate the average payoff/score in a finite population with the number of each trait provided incountfor interaction groups of sizen.doublepairScores(int me, int[] traitCount, double[] traitScore) Calculate and return total (accumulated) payoff/score for pairwise interactions of the focal individual with traitmeagainst opponents with different traits.voidsetPoolPunishCost(double aValue) Set the cost of pool punishment.voidsetPoolPunishFine(double aValue) Set the pool punishment fine.Methods inherited from class CDLP
createIBSPop, getLeniencyCoop, getLeniencyLoner, getPunishCost, getPunishFine, setLeniencyCoop, setLeniencyLoner, setPunishCost, setPunishFineMethods inherited from class CDL
adjustCLO, check, getCostCoop, getDependent, getInterest, getMaxPayoff, getOthersOnly, getPayLoneCoop, getPayLoneDefect, getPayLoner, getSolo, interest, setCostCoop, setInterest, setInterest, setOthersOnly, setPayLoneCoop, setPayLoneDefect, setPayLoner, setSolo, unloadMethods inherited from class Discrete
add, getMaxMonoPayoff, getMinMonoPayoff, getMonoStop, getMutation, setMonoStopMethods inherited from class Module
createGeometry, createModel, getActiveTraits, getCompetitionGeometry, getDeathRate, getGeometry, getIBSPopulation, getID, getInteractionGeometry, getKey, getMap2Fitness, getMarkers, getMeanColors, getModelTypes, getNActive, getName, getNGroup, getNPopulation, getNRoles, getNSpecies, getNTraits, getOpponent, getPlayerUpdate, getSpecies, getSpecies, getTraitColor, getTraitColors, getTraitName, getTraitNames, getTrajectoryColor, getVacant, init, processColorMap, reset, run, setActiveTraits, setDeathRate, setGeometries, setIBSPopulation, setModel, setName, setNGroup, setNPopulation, setNTraits, setOpponent, setTraitColors, setTraitNames, setTrajectoryColorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Features
isMultispecies, isStaticMethods inherited from interface Features.Groups
getNGroup, isPairwiseMethods inherited from interface Features.Payoffs
getMap2Fitness, getMaxMonoPayoff, getMinMonoPayoff, isNeutralMethods inherited from interface HasHistogram
getCustomLevels, getNTraits, getTraitColorsMethods inherited from interface IBS.HasIBS
createIBSMethods inherited from interface IBS.HasIBS.DGroups
mixedScoresMethods inherited from interface MilestoneListener
modelDidInit, modelDidReset, modelLoaded, modelRelaxed, modelRunning, modelSettings, modelStopped, modelUnloaded, moduleLoaded, moduleRestored, moduleUnloaded
-
Field Details
-
SANCTIONING
public static final int SANCTIONINGThe trait (and index) value of pool punishers.- See Also:
-
costPoolPunish
double costPoolPunishThe cost of pool punishment.- See Also:
-
finePoolPunish
double finePoolPunishThe pool punishment fine for non-contributors.- See Also:
-
cloPoolPunish
Command line option to set the fine of pool punishment for non-contributors. -
cloCostPoolPunish
Command line option to set the cost of pool punishment.
-
-
Constructor Details
-
CDLPQ
Create a new instance of the module for voluntary public goods games with peer and pool punishment.- Parameters:
engine- the manager of modules and pacemaker for running the model
-
-
Method Details
-
load
public void load()Description copied from class:ModuleLoad new module and perform basic initializations. -
getAuthors
Description copied from class:ModuleReturns a string with information about the authors of the module.- Overrides:
getAuthorsin classCDLP- Returns:
- the names of the authors
-
getTitle
Description copied from interface:FeaturesReturns title of active module, e.g. 2x2 games inTBTreturns "2x2 Games". -
getMinPayoff
public double getMinPayoff()Description copied from interface:Features.PayoffsCalculates 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.- Specified by:
getMinPayoffin interfaceFeatures.Payoffs- Overrides:
getMinPayoffin classCDLP- Returns:
- the minimum payoff/score
- See Also:
-
getMonoPayoff
public double getMonoPayoff(int type) Calculate and return the payoff/score of individuals in monomorphic populations with traittype.Note: Optional implementation. Returns
Double#NaNif not defined or not implemented.Note, monomorphic populations of peer punishers have the same payoff as monomorphic populations of cooperators. Note, monomorphic populations of pool punishers have the same payoff as monomorphic populations of cooperators.
- Overrides:
getMonoPayoffin classCDLP- Parameters:
type- the index of the trait- Returns:
- payoff/score in monomorphic population with trait
type
-
pairScores
public double pairScores(int me, int[] traitCount, double[] traitScore) Description copied from class:CDLPCalculate and return total (accumulated) payoff/score for pairwise interactions of the focal individual with traitmeagainst opponents with different traits. The respective numbers of each of thenTraitsopponent traits are provided in the arraytCount. The payoffs/scores for each of thenTraitsopponent traits must be stored and returned in the arraytScore.Important: must be overridden and implemented in subclasses that define game interactions between pairs of individuals (
nGroup=2,pairwise=true), otherwise seeIBS.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:
pairScoresin interfaceIBS.HasIBS.DPairs- Overrides:
pairScoresin classCDLP- Parameters:
me- the trait index of the focal individualtraitCount- number of opponents with each traittraitScore- array for returning the scores of each opponent trait- Returns:
- score of focal individual
meaccumulated over all interactions
-
groupScores
public void groupScores(int[] traitCount, double[] traitScore) Description copied from interface:IBS.HasIBS.DGroupsCalculate the payoff/score for interactions in groups consisting of traits with respective numbers given in the arraytraitCount. The interaction group size is given by the sum overtraitCount[i]fori=0,1,...,nTraits. The payoffs/scores for each of thenTraitstraits must be stored and returned in the arraytraitScore.Important: must be overridden and implemented in subclasses that define game interactions among groups of individuals (for groups with sizes
nGroup>2, otherwise seeIBS.HasIBS.DPairs.pairScores(int, int[], double[])).- Specified by:
groupScoresin interfaceIBS.HasIBS.DGroups- Overrides:
groupScoresin classCDLP- Parameters:
traitCount- group composition given by the number of individuals with each traittraitScore- array for returning the payoffs/scores of each trait
-
mixedScores
public void mixedScores(int[] count, int n, double[] traitScores) Description copied from class:CDLPCalculate the average payoff/score in a finite population with the number of each trait provided incountfor interaction groups of sizen. The payoffs/scores for each of thenTraitstraits must be stored and returned in the arraytraitScores.Notes:
For payoff calculations:- each trait 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 trait does not depend on its own type simplifies things
IBS.check()(seeIBSMCPopulationfor 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 withIBS.HasIBS.DPairs.pairScores(int, int[], double[])orIBS.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:
mixedScoresin interfaceIBS.HasIBS.DGroups- Overrides:
mixedScoresin classCDLP- Parameters:
count- number of individuals for each traitn- interaction group sizetraitScores- array for returning the payoffs/scores of each trait
-
avgScores
public void avgScores(double[] density, int n, double[] avgscores) Description copied from class:CDLCalculate the average payoff for the frequency of traits specified in the arraystatefor interactions in groups of sizen. The average payoffs for each of thenTraitstraits must be stored and returned in the arrayscores.- 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:
avgScoresin interfaceModel.HasDE.DGroups- Overrides:
avgScoresin classCDLP- Parameters:
density- the frequency/density of each traitn- the size of interaction groupsavgscores- the array for storing the average payoffs/scores of each trait
-
setPoolPunishCost
public void setPoolPunishCost(double aValue) Set the cost of pool punishment.- Parameters:
aValue- the cost of pool punishment
-
getPoolPunishCost
public double getPoolPunishCost()Get the cost of pool punishment.- Returns:
- the cost of pool punishment
-
setPoolPunishFine
public void setPoolPunishFine(double aValue) Set the pool punishment fine.- Parameters:
aValue- the pool punishment fine.
-
getPoolPunishFine
public double getPoolPunishFine()Get the fine for pool punishment.- Returns:
- the pool punishment fine.
-
collectCLO
Description copied from interface:CLOProviderAll 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, theparserissues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and callsuper.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:
collectCLOin interfaceCLOProvider- Overrides:
collectCLOin classCDLP- Parameters:
parser- the reference to parser that manages command line options- See Also:
-