ModelSwarm documentation

Authors

Generated by pauljohn

Contents -

  1. Software documentation for the AgentSwarm class
  2. Software documentation for the ModelSwarm class

Software documentation for the AgentSwarm class

AgentSwarm : Swarm

Declared in:
ModelSwarm.h

This class "AgentSwarm" is an intermediate level swarm. It is used to keep agent actions separated from Model actions that happen at time X.


Instance Variables

Method summary

activateIn: 

- (id) activateIn: (id)swarmContext;

Put the schedules to work by hanging them on the system clock.


buildActions 

- (id) buildActions;

Create schedules for agent actions. Please note that there are CPP flags that can be used to compare different approaches to the problem of randomizing the order in which agents step at a given time. The default method is to randomize the list of agents at the beginning of each day, and then tell the agents to choose times to move to work and times to initiate discussions. These actions are thrown onto the system schedule in a first come, first serve way at each hour of the day. If the CPP flag "CONCURRENT_GROUP_SCHEDULE is set, then an additional level of randomization is invoked. When agent actions are thrown onto the schedule at a given hour, then those actions are randomized. This is a very complete (and really slow) sort of randomization. If the CPP flag is "NO_MASTER_SCHEDULE", then the actions in the model are completely decentralized. Each Citizen agent keeps its own schedule and, and the schedules are activated within the larger overall Swarm time frame. Each time the model takes a step, it scans from the "top down" to make sure that all actions in all lower schedules have been executed.


setCitizenList: 

- (id) setCitizenList: (id)list;

Set the list of citizens




Instance Variables for AgentSwarm Class

agentSchedule

@protected id agentSchedule;

Description forthcoming.


citizenList

@protected id citizenList;

Description forthcoming.


periodicSchedule

@protected id periodicSchedule;

Description forthcoming.





Software documentation for the ModelSwarm class

ModelSwarm : Swarm

Declared in:
ModelSwarm.h

The ModelSwarm object directly manages the execution of the simulation. It creates individual level agents, sets their interactions in motion, and records information at each time step about what is happening


Instance Variables

Method summary

createBegin: 

+ (id) createBegin: (id)aZone;
This is a designated initialiser for the class.

Initiates the creation of the model


activateIn: 

- (id) activateIn: (id)swarmContext;

Each schedule that is going to be integrated into the overall time scale must be activated within some time framework, called "swarmContext" in this case.


buildActions 

- (id) buildActions;

Create schedules that orchestrate the actions that occur in the model.


buildObjects 

- (id) buildObjects;

This is the central method that triggers all actions needed to create agents, the environment, record keepers, etc.


calculateStability: Value: 

- (id) calculateStability: (int)issue Value: (int)value;

Calculate a stability index for a given issue and opinion. For each citizen, this calculates how close the agent's network is to "tipping". This is an experimental implementation.


calculateUniqueNetworks 

- (int) calculateUniqueNetworks;

Figure out how many unique networks there are. This can be used to diagnose the density of the network connections in the society and the importance of weak ties


clearTabulator 

- (void) clearTabulator;

The tabulator has counts for all opinions on all issues set equal to zero


createCitizens 

- (id) createCitizens;

This method does the heavy lifting of creating the agents that are put into the citizenList. The ModelType variable (see the Parameters object) determines which sort of agents are created. These are the types:

  • ModelType 0: Axelrod (for both select and adjust)
  • ModelType 1: HJ type citizens (for both select and adjust)
  • ModelType 2: Axelrod select, HJ adjust, persuasionModel=0
  • ModelType 3: Coleman type agents (Coleman select, Axelrod adjust)
  • ModelType 4: Coleman type agents (Coleman select, Axelrod adjust). Same asModelType 3 in current implementation.
  • ModelType 5: MikePM2 type agents
  • ModelType 6: Axelrod Select, MikePM2 adjust
  • ModelType 7: HJ Select, Axelrod adjust
  • ModelType 8: Axelrod select, HJ adjust, persuasionModel=1


createEnd 

- (id) createEnd;
This is a designated initialiser for the class.

Finalizes the creation of the model


drop 

- (void) drop;

Close up the data output objects when this object is dropped


getAcquaintanceAvg 

- (double) getAcquaintanceAvg;

Return the value of the acquaintanceAverager. An agent considers another to be an acquantance if they have a randomly chosen opinion in common. Agent experiences are averaged.


getAcquaintanceVariance 

- (double) getAcquaintanceVariance;

Description forthcoming.


getAverageFeature: 

- (double) getAverageFeature: (int)f;

For the indicated opinion, return the average of agent opinions


getBetaVariateAlpha1: Alpha2: 

- (double) getBetaVariateAlpha1: (double)alpha1 Alpha2: (double)alpha2;

Return a random draw from a Beta distribution


getBinomialVariateN: P: 

- (int) getBinomialVariateN: (int)n P: (double)p;

This method is adapted from the C code of the GSL, which is available under the GPL with this statement:
randist/binomial.c
Copyright (C) 1996, 1997, 1998, 1999, 2000 James Theiler, Brian Gough This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The binomial distribution has the form, prob(k) = n!/(k!(n-k)!) * p^k (1-p)^(n-k) for k = 0, 1,..., n This is the algorithm from Knuth


getCitizen: 

- (Citizen*) getCitizen: (int)i;

Return the agent that is in the i'th offset in the citizenList


getCitizenList 

- (id) getCitizenList;

Return a list of all citizens in the model


getEntropyFeature: 

- (double) getEntropyFeature: (int)f;

Calculate and return the entropy for the indicated issue


getHarmonyAvg 

- (double) getHarmonyAvg;

Return the value of the harmonyAverager. It is a moving average of an overall average of agent experiences of how similar their opinions are with other agents.


getHarmonyVariance 

- (double) getHarmonyVariance;

Description forthcoming.


getHomeGrid: 

- (id) getHomeGrid: (int)i;

Return the neighborhood grid at the i'th offset


getIdenticalAvg 

- (double) getIdenticalAvg;

Return the value of the identicalAverager. It is a moving average of an overall average of agent experiences indicating the proportion of other agents with whom they are identical.


getIdenticalVariance 

- (double) getIdenticalVariance;

Description forthcoming.


getMultidimensionalEntropy 

- (double) getMultidimensionalEntropy;

Calculate and return the Total (multidimensional) Entropy value


getNumberOfChangesThisStep 

- (unsigned int) getNumberOfChangesThisStep;

Return the number of agents that changed an opinion during this step


getNumberOfInteractionsThisStep 

- (unsigned int) getNumberOfInteractionsThisStep;

Return the value of numberOfInteractionsThisStep


getVarianceFeature: 

- (double) getVarianceFeature: (int)f;

For the indicated opinion, return the variance of agent opinions


getWorkGrid: 

- (id) getWorkGrid: (int)i;

Return the work grid at the i'th offset


getWorld: Grid: 

- (id) getWorld: (int)w Grid: (int)grid;

Return the indicated Grid from the indicated World. World means a collection of grids, representing a set of neighborhoods or workplaces


incrFeature: Add: Subtract: 

- (void) incrFeature: (int)f Add: (int)amount1 Subtract: (int)amount2;

Tell the tabulator to add one agent to the tally of agents that hold opinion "amount1" on issue "f" AND remove an agent that holds opinion "amount2"


incrFeature: Value: 

- (void) incrFeature: (int)f Value: (int)amount;

Tell the tabulator to add one agent to the tally of agents that hold opinion "amount" on issue "f"


incrNumberOfChangesThisStep 

- (void) incrNumberOfChangesThisStep;

Increase by one the number of changes of opinion that agents report having during this period


incrNumberOfInteractionsThisStep 

- (void) incrNumberOfInteractionsThisStep;

Increase by one the number of interactions that occurred during this period


incrNumberOfStepsThisStep 

- (void) incrNumberOfStepsThisStep;

Increase by one the number of steps that agents report having taken during this period


initializeRNGs 

- (id) initializeRNGs;

Description forthcoming.


lispArchive 

- (id) lispArchive;

Serialize (save) the state of the simulation


lispArchive: 

- (id) lispArchive: (char*)inputName;

Serialize (save) the state of the simulation into a file with the given name


lispLoadCitizens: 

- (id) lispLoadCitizens: (const char*)lispfile;

Instead of creating the citizens on the fly, load the citizens that were saved in lisp format into the indicated file.


pulseFeature: Percentage: ChangeFrom: To: 

- (int) pulseFeature: (int)feature Percentage: (int)percent ChangeFrom: (int)val1 To: (int)val2;

Administer exogenous shock. For the indicated issue (feature), change an agent to have a different opinion. This method will change the opinions of the given percentage of all agents. It does so by collecting all agents who currently hold a particular opinion and then randomly selects the required number to adopt the other opinion.


pulseFeature: Percentage: ChangeTo: 

- (int) pulseFeature: (int)feature Percentage: (int)percent ChangeTo: (int)value;

Administer exogenous shock. For the indicated issue (feature), change an agent to have a different opinion. This method will change the opinions of the given percentage of all agents. It does so by collecting all agents who do not currently hold a particular opinion and then randomly selects the required number.


pulseFeature: Percentage: Magnitude: 

- (int) pulseFeature: (int)feature Percentage: (int)percent Magnitude: (int)mag;

Administer exogenous shock. For the indicated issue (feature), change an agent to have a different opinion. This method will change the opinions of the given percentage of all agents. It does so by collecting all agents, randomly selecting the required number, and then it increments their opinion by the indicated magnitude.


resetCounters 

- (void) resetCounters;

Reset counter variables to 0, so records can start fresh


setObserver: 

- (id) setObserver: (id)observer;

Set the value for the object that displays the simulation


stepReport 

- (void) stepReport;

Calculate the current time and initiate the text output of data at current step.


updateTabulator 

- (void) updateTabulator;

Cycle through all citizens and get their opinions on all the issues, and increment the tabulator to represent the state of opinion throughout the society


writeReportData 

- (void) writeReportData;

Does actual work of collecting data and writing into file


writeReportDataHeader 

- (void) writeReportDataHeader;

Writes variable names for columns in text output




Instance Variables for ModelSwarm Class

GammaDist1

@protected id GammaDist1;

Description forthcoming.


acquaintAverager

@protected id acquaintAverager;

Description forthcoming.


agentSwarm

@protected id agentSwarm;

Description forthcoming.


citizenList

@protected id citizenList;

Description forthcoming.


disturbanceSchedule

@protected id disturbanceSchedule;

Description forthcoming.


harmonyAverager

@protected id harmonyAverager;

Description forthcoming.


identicalAverager

@protected id identicalAverager;

Description forthcoming.


lastAcquaintCall

@protected timeval_t lastAcquaintCall;

Description forthcoming.


lastHarmonyCall

@protected timeval_t lastHarmonyCall;

Description forthcoming.


lastIdenticalCall

@protected timeval_t lastIdenticalCall;

Description forthcoming.


modelActions

@protected id modelActions;

Description forthcoming.


modelSchedule

@protected id modelSchedule;

Description forthcoming.


modelType

@protected int modelType;

Description forthcoming.


neighborhoodList

@protected id neighborhoodList;

Description forthcoming.


nofprofiles

@protected unsigned int nofprofiles;

Description forthcoming.


numCitizens

@protected int numCitizens;

Description forthcoming.


numCultureFeatures

@protected int numCultureFeatures;

Description forthcoming.


numWorkplaces

@protected int numWorkplaces;

Description forthcoming.


numberOfInteractionsThisStep

@protected int numberOfInteractionsThisStep;

Description forthcoming.


numberOfStepsThisStep

@protected int numberOfStepsThisStep;

Description forthcoming.


observerSwarm

@protected id observerSwarm;

Description forthcoming.


oneAtATime

@protected BOOL oneAtATime;

Description forthcoming.


outputFile

@protected FILE* outputFile;

Description forthcoming.


outputFileName

@protected char outputFileName;

Description forthcoming.


parochialism

@protected double parochialism;

Description forthcoming.


pplPerCell

@protected int pplPerCell;

Description forthcoming.


randomSeed

@protected int randomSeed;

Description forthcoming.


randomizeCitizenUpdateOrder

@protected BOOL randomizeCitizenUpdateOrder;

Description forthcoming.


startupSchedule

@protected id startupSchedule;

Description forthcoming.


tabulator

@protected long int** tabulator;

Description forthcoming.


totalImpact

@protected int totalImpact;

Description forthcoming.


variableCellSize

@protected BOOL variableCellSize;

Description forthcoming.


workXSize

@protected int workXSize;

Description forthcoming.


workplace

@protected MultiGrid2d* workplace;

Description forthcoming.


workplaceList

@protected id workplaceList;

Description forthcoming.


worldXSize

@protected int worldXSize;

Description forthcoming.