- 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.
Method summaryPut the schedules to work by hanging them on the system clock.
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.
Set the list of citizens
- 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
Method summaryInitiates the creation of the model
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.
Create schedules that orchestrate the actions that occur in the model.
This is the central method that triggers all actions needed to create agents, the environment, record keepers, etc.
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.
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
The tabulator has counts for all opinions on all issues set equal to zero
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:
Finalizes the creation of the model
Close up the data output objects when this object is dropped
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.
Description forthcoming.
For the indicated opinion, return the average of agent opinions
Return a random draw from a Beta distribution
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
Return the agent that is in the i'th offset in the citizenList
Return a list of all citizens in the model
Calculate and return the entropy for the indicated issue
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.
Description forthcoming.
Return the neighborhood grid at the i'th offset
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.
Description forthcoming.
Calculate and return the Total (multidimensional) Entropy value
Return the number of agents that changed an opinion during this step
Return the value of numberOfInteractionsThisStep
For the indicated opinion, return the variance of agent opinions
Return the work grid at the i'th offset
Return the indicated Grid from the indicated World. World means a collection of grids, representing a set of neighborhoods or workplaces
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"
Tell the tabulator to add one agent to the tally of agents that hold opinion "amount" on issue "f"
Increase by one the number of changes of opinion that agents report having during this period
Increase by one the number of interactions that occurred during this period
Increase by one the number of steps that agents report having taken during this period
Description forthcoming.
Serialize (save) the state of the simulation
Serialize (save) the state of the simulation into a file with the given name
Instead of creating the citizens on the fly, load the citizens that were saved in lisp format into the indicated file.
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.
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.
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.
Reset counter variables to 0, so records can start fresh
Set the value for the object that displays the simulation
Calculate the current time and initiate the text output of data at current step.
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
Does actual work of collecting data and writing into file
Writes variable names for columns in text output