models
Class SimpleCondorcetModel

java.lang.Object
  |
  +--models.SimpleCondorcetModel

public class SimpleCondorcetModel
extends java.lang.Object

The world is set in state 0, each individual is given (noisy) access to the world. With probability (1-e) they are given 0, with probability e they are given 1. After their initial assignments, each individual then polls her neighbors, and updates her belief based on what the majority of her neighbors think. (Each individual stays the same in case of tie.) This is equivalent to myopic best-response in a game of pure coordination. In fact, this is how the model in instantiate here, although the results are translated to conform to the model described above.

Author:
Kevin Zollman

Constructor Summary
SimpleCondorcetModel()
          Does nothing
SimpleCondorcetModel(int n)
          Sets up a group of individuals of size n.
 
Method Summary
 int countTruth()
          Returns the count of individuals who believe the truth (strategy 0).
 void createPlayers(Individual[] is, MutationRule mr, LearningRule lr, ConnectionRule cr)
          Sets up the individuals
 int detectState()
          Detects if the individuals are in one of three states, unanimity on the truth (strategy 0), majority on the truth or none
 Individual[] getIndividuals()
          Returns the set of individuals for the model.
 MersenneTwister getRandom()
          Returns the random number generator for the model.
 int[] incrementSequence(int[] s, int n)
          This is used for enumerations, it takes a sequence of numbers and a maximum for each value and increments to the next in the sequence.
static void main(java.lang.String[] args)
          Main, runs a model.
 void resetPlayers(int s, double e)
          Resets the players beliefs
 int runmodel(double mr, boolean tr, int g, int v)
          Runs the model.
 void setIndividuals(Individual[] i)
          Sets the list of individuals for the model.
 void setRandom(MersenneTwister r)
          Sets the random number generator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleCondorcetModel

public SimpleCondorcetModel()
Does nothing


SimpleCondorcetModel

public SimpleCondorcetModel(int n)
Sets up a group of individuals of size n.

Parameters:
n -
Method Detail

setIndividuals

public void setIndividuals(Individual[] i)
Sets the list of individuals for the model.

Parameters:
i - An array of individuals

getIndividuals

public Individual[] getIndividuals()
Returns the set of individuals for the model.

Returns:
the individuals

setRandom

public void setRandom(MersenneTwister r)
Sets the random number generator.

Parameters:
r - the mersennetwister random number generator

getRandom

public MersenneTwister getRandom()
Returns the random number generator for the model.

Returns:
the mersenne twister random number generator

incrementSequence

public int[] incrementSequence(int[] s,
                               int n)
This is used for enumerations, it takes a sequence of numbers and a maximum for each value and increments to the next in the sequence. The first in the sequence is 0,0,...,0 the last is n,n,...,n

Parameters:
s - The sequence
n - The maximum number

createPlayers

public void createPlayers(Individual[] is,
                          MutationRule mr,
                          LearningRule lr,
                          ConnectionRule cr)
Sets up the individuals

Parameters:
is - The network of individuals (already appropriately connected)
mr - The mutation rule
lr - The learning rule
cr - The connection rule

resetPlayers

public void resetPlayers(int s,
                         double e)
                  throws ModelError
Resets the players beliefs

Parameters:
s - The number of possible belief states
e - The probability of believing belief state 0 (i.e. the truth)
Throws:
ModelError

detectState

public int detectState()
                throws ModelError
Detects if the individuals are in one of three states, unanimity on the truth (strategy 0), majority on the truth or none

Returns:
2 for unanimity, 1 for majority, and 0 for neither
ModelError

countTruth

public int countTruth()
               throws ModelError
Returns the count of individuals who believe the truth (strategy 0).

Returns:
Number that believe the truth
ModelError

runmodel

public int runmodel(double mr,
                    boolean tr,
                    int g,
                    int v)
             throws ModelError
Runs the model. If there is mutation, it runs until the value g is obtained. If there is no mutation, then it checks for convergence and stops if there is convergence (or if g is obtained).

Parameters:
mr - The mutation rate
tr - A boolean saying if "truerate" is set (if true no convergence detection)
g - The maximum number of generations
v - Is the verbosity level (>2 means it prints something out for every gen)
Throws:
ModelError

main

public static void main(java.lang.String[] args)
Main, runs a model.

Parameters:
args - The command line arguments