Class simCDLP

All Implemented Interfaces:
Runnable, ChangeListener, 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

public class simCDLP extends CDLP implements ChangeListener
Simulations to investigate peer punishment in the voluntary public goods game. This module extends the CDLP module to determine, for example, the probability of fixation in each of the four homogeneous, absorbing states.
Author:
Christoph Hauert
See Also:
  • "Hauert C., Traulsen A., Brandt H., Nowak M. A., Sigmund K. (2007) <em>Via Freedom to Coercion: The Emergence of Costly Punishment.</em> Science 316:1905-1907. doi: <a href= 'https://doi.org/10.1126/science.1141588'>10.1126/science.1141588</a>"
  • "Hauert C., De Monte S., Hofbauer J., Sigmund K. (2002) <em>Volunteering as Red Queen Mechanism for Cooperation in Public Goods Games.</em> Science 296:1129-1132. doi: <a href= 'https://doi.org/10.1126/science.1070582'>10.1126/science.1070582</a>"
  • Field Details

    • threshold

      int threshold
      The threshold for qualifying as a corner state.
    • timesamples

      long timesamples
      The time to reach the punisher corner.
    • doLocation

      boolean doLocation
      Generate a histogram of states visited.
    • doBasin

      private boolean doBasin
      Generate the basins of attraction.
    • initInQ

      private boolean initInQ
      The flag to indicate whether the initial configuration is given by the interior fixed point Q (for CDL only).
    • out

      The output stream. Defaults to System.out.
    • mean

      double[] mean
      Temporary variables for fixation probabilities and absorption times.
    • var

      double[] var
      Temporary variables for fixation probabilities and absorption times.
    • state

      double[] state
      Temporary variables for fixation probabilities and absorption times.
    • prevsample

      double prevsample
      Time of previous sample.
    • cloThreshold

      public final CLOption cloThreshold
      Command line option to set the threshold for corner states.
    • cloBasin

      public final CLOption cloBasin
      Command line option to determine the basin of attraction of punishers and cooperators.
    • cloTime2Punish

      public final CLOption cloTime2Punish
      Command line option to determine the time to reach the threshold of punishers.
    • cloHistogram

      public final CLOption cloHistogram
      Command line option to generate a histogram of states visited.
  • Constructor Details

    • simCDLP

      public simCDLP(EvoLudo engine)
      Create a new simulation to investigate the role of punishment in voluntary public goods games.
      Parameters:
      engine - the pacemaker for running the model
  • Method Details

    • run

      public void run()
      Description copied from class: Module

      Default run-loop for modules. Opportunity to override in subclasses for running customized simulations. Currently only called from EvoLudoJRE.simulation() if custom simulation class is specified in jar file.

      Specified by:
      run in interface Runnable
      Overrides:
      run in class Module
    • modelChanged

      public void modelChanged(ChangeListener.PendingAction action)
      Description copied from interface: ChangeListener
      Called whenever the state of the EvoLudo model changed. Process potentially pending requests.

      Note: the model may process some pending actions directly and without notifying the listeners through modelChanged(PendingAction) first. In particular, this applies to pending actions that fire their own notifications, such as RESET and INIT that in turn trigger modelReset() and modelInit(), respectively.

      Specified by:
      modelChanged in interface ChangeListener
      Parameters:
      action - pending action that needs to be processed.
      See Also:
    • modelStopped

      public void modelStopped()
      Description copied from interface: MilestoneListener
      Called after a running EvoLudo model stopped because the model converged (or reached an absorbing state).
      Specified by:
      modelStopped in interface MilestoneListener
    • startStatistics

      protected void startStatistics()
      Start collecting statistics.
    • resetStatistics

      protected void resetStatistics()
      Reset statistics.
    • updateStatistics

      protected void updateStatistics(double time)
      Update statistics.
      Parameters:
      time - the current time
    • findQ

      private double[] findQ(int n, double r, double sigma)
      Find the interior fixed point Q for the CDL model.
      Parameters:
      n - the maximum size of the interaction group
      r - the multiplication factor of the public good
      sigma - the payoff for loners
      Returns:
      the interior fixed point Q
    • func

      private double func(double z, int n, double r)
      The function \(F(z)\) for the interior fixed point \(Q\).
      Parameters:
      z - the fraction of loners
      n - the maximum size of the interaction group
      r - the multiplication factor of the public good
      Returns:
      the value of \(F(z)\)
    • sign

      private double sign(double x)
      The sign function. Returns 1.0 for positive values, 0.0 for negative values, and 0.5 for zero.
      Parameters:
      x - the value
      Returns:
      the sign of the value
    • 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 CDLP
      Parameters:
      parser - the reference to parser that manages command line options
      See Also:
    • main

      public static void main(String[] args)
      Main method to run the simulation.
      Parameters:
      args - the array of command line arguments