models
Class BgModel

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

public class BgModel
extends java.lang.Object

This is a class that runs the BalaGoyal Model of Bayesian Learning in Networks.

Author:
Kevin Zollman

Constructor Summary
BgModel()
          Does nothing
BgModel(int n)
          Creates a new BgModel with a specified number of individuals.
 
Method Summary
 void createPlayersHigh(Individual[] inds, int s)
          Forms a new network of specified size; expects random to be set.
 void createPlayersHigh(Individual[] inds, int s, ConnectionRule c, LearningRule l, double m, double z)
          Forms a new network of specified size; expects random to be set.
 void createPlayersHigh(Individual[] inds, int s, ConnectionRule c, LearningRule l, Game g, double m, double z)
          Forms a new network of specified size; expects random to be set.
 void createPlayersLow(Individual[] inds)
          Forms a new network of specified size; doesn't expect much to be set.
 int detectConvergence(int sow)
          Checks to see if the population has converged either to the correct state or the bad state.
 Game[] getGames()
          Returns the games for the BgModel
 Individual[] getIndividuals()
          Returns the set of individuals for the model.
 MersenneTwister getRandom()
          Returns the random number generator for the model.
static void main(java.lang.String[] args)
          Main, runs a model.
 void playGen()
          Resets then plays a generation.
 void setGames(Game[] g)
          Sets an array of games, one for each state of the world.
 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

BgModel

public BgModel()
Does nothing


BgModel

public BgModel(int n)
Creates a new BgModel with a specified number of individuals. This creates a new list of individuals, sets their id number, and tells each about the network.

Parameters:
n - The size of the network
Method Detail

setGames

public void setGames(Game[] g)
Sets an array of games, one for each state of the world.

Parameters:
g - The array of Game objects

getGames

public Game[] getGames()
Returns the games for the BgModel

Returns:
the games

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

createPlayersLow

public void createPlayersLow(Individual[] inds)
Forms a new network of specified size; doesn't expect much to be set. This method only tells each individual of the network, does not set anything else.

Parameters:
inds - A list of individuals

createPlayersHigh

public void createPlayersHigh(Individual[] inds,
                              int s)
                       throws ModelError
Forms a new network of specified size; expects random to be set. This method tells each individual of the network, sets the random number generator, and calle each individuals initStart function.

Parameters:
inds - A list of individuals
s - The number of states of the world
Throws:
ModelError - If an initialization error

createPlayersHigh

public void createPlayersHigh(Individual[] inds,
                              int s,
                              ConnectionRule c,
                              LearningRule l,
                              double m,
                              double z)
                       throws ModelError
Forms a new network of specified size; expects random to be set. This method tells each individual of the network, sets the random number generator, gives the individuals a connection and learning rule, sets the mutation rate, sets belief constraint, and calls each individuals initStart function

Parameters:
inds - A list of individuals
s - The number of states of the world
c - The connection rule used for forming network connections by each individual
l - The learning rule used for determining strategies by each individual
m - The mutation rate for each individual to reset their beliefs
z - The zero-state constraint for beliefs (initial beliefs cannot be lower than z)
Throws:
ModelError - If something fails during initialization

createPlayersHigh

public void createPlayersHigh(Individual[] inds,
                              int s,
                              ConnectionRule c,
                              LearningRule l,
                              Game g,
                              double m,
                              double z)
                       throws ModelError
Forms a new network of specified size; expects random to be set. This method tells each individual of the network, sets the random number generator, gives the individuals a connection and learning rule, sets the list of games sets the mutation rate, sets belief constraint, and calls each individuals initStart function

Parameters:
inds - A list of individuals
s - The number of states of the world
c - The connection rule used for forming network connections by each individual
l - The learning rule used for determining strategies by each individual
g - The games used in the model
m - The mutation rate for each individual to reset their beliefs
z - The zero-state constraint for beliefs (initial beliefs cannot be lower than z)
Throws:
ModelError - If something fails during initialization

playGen

public void playGen()
             throws ModelError
Resets then plays a generation. This first calls each individuals reset function, then calls each individuals playGame function, then calles each individuals update function

Throws:
ModelError - If something bad happens

detectConvergence

public int detectConvergence(int sow)
                      throws ModelError
Checks to see if the population has converged either to the correct state or the bad state. This function presumes that state 0 is the uninformative state.

Parameters:
sow - What is the actual state of the world?
Returns:
This function returns 0 if unconverged, 1 if converged to the true state, 2 if converged to the wrong state (only possible in good states; i.e. not state 0).
ModelError

main

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

Parameters:
args - The command line arguments