- Declared in:
- Citizen.h
The Citizen is the root agent in this model. This class has the key record-keeping and scheduling role.
We do not ever intend that this class should be instantiated. Rather, subclasses which implement particular theories should be written and used in the models. The Citizen class contains general purpose variables and methods that we exect all subclasses are likely to need.
Subclassing Guide For starters, we suggest you allow Citizen's step method to work as it is. If you allow step to be called, it will control movement and will tell the agent to interact. The interact method will cause the agent to find someone and discuss with them. In order for this to function, it is necessary for a subclass to override these two methods:
- selectADiscussantInPosition: (Position *)position;
- adjustOpinionAgainst: other;
There are a number of class variables and class methods. Class variables save on storage because one value is set and used by all agents. The Class methods are the ones that begin with plus signs. There are a number of advantages in using Class methods and variables in the serialization part of this program. Class values need not be serialized, rather they are easily set at runtime.
Each Citizen has personal stances or opinions that we are calling "culture" in honor of Robert Axelrod. Original versions of this model benefitted greatly from the assistance of Rick Riolo of the University of Michigan and Lars Erik Cederman of UCLA.
The culture is kept in an integer array. The number of opinions is set by the numCultureFeatures parameter. The number of positions that exist for each issue is set by the numCultureTraits parameter. Every citizen holds some position on each issue at all times. The initial positions are assigned by code in the ModelSwarm. Typically, opinions are randomly assigned.
Each citizen is aware of various "positions" (2D grids) in which it can interact. One position is the home grid, another is the work grid. To allow the possibility that a model might have agents with many positions they would visit, we have put all positions into a Swarm Array, positions.
The Citizen class has vital record keeping tools, including the moving averages that summarize the experiences of the agents. These keep track of the rate of acquaintance among agents, the rate of similarity, and identicality (a word?).
Citizen also has machinery to schedule agent actions and move agents around.
We expect that subclasses will handle the problems of choosing discussants, and responding to the interaction. Some methods are included in this class to keep track of experiences/observations, and they can be used in subclasses.
The one method that is vital for any sublcass is "interact". In the root class Citizen, this is the method that chooses a discussant and then responds to the interaction. Since interact calls both the "selectADiscussantInPosition" and "adjustOpinionAgainst:" methods, then the subclass must either override interact or it must do something about selecting discussants and responding to them. Note the subclass HJCitizen is mainly about choosing discussants differently and responding to them strategically. Not that this class has code in it that mandates that a subclass must implement these last two methods.
Method summary
Returns the number of issues/features that this class is using.
Returns the number of opinions (traits) that the agents might hold for each issue/feature
Return the observerSwarm that objects of type Citizen are using
Set the consistentAdjustment parameter
The dayLength is the number of timesteps that are considered as a separate time frame for the agent. The day begins at home and the agent should return there at the end of the day
When agents change their opinions, they tell the centralized record keeper about it. This method tells the agent who the record keeper is.
A class method that sets the number of issues/culture features. All agents are able to access the variable numCultureFeatures.
A class method that sets the number of culture traits. All agents are able to access the variable numCultureTraits.
Sometimes it is useful to let the agent know the location of the class that is drawing graphs in the simultion. This does it.
In Axelrod's original model, only one agent could change as a result of interaction. We wanted to generalize a bit, so we created these toggles.
Set the YES
or NO
variable
indicating only the agent who initiates the
interaction--self--is able to change
its opinion in response to the interaction.
Set the parochialism parameter. This is the probability that an agent will look outside its current cell for a discussion partner. This is relevant only when there is more than one agent in a cell.
Do agents look for discussants within the truncated
VonNeumann neighborhood? If yes, then wrapAround
is YES
. If no, then the grid in the
position has to be a torus, and wrapAround is
NO
If the NO_MASTER_SCHEDULE CPP flag is used, then each agent is a Swarm unto itself, and so it has to create a schedule and activate its schedule within the larger condext. This ties the agent's schedule into the time stepping of the system.
All sublcasses must know how to adjustOpinionAgains: another agent
For serialization, each agent needs to dump out its instance variables, so that the agent can be brought back to life in exactly the same state.
Remove self from locations in which others can reach for interaction
Create the schedule on which actions can be placed. This is only used if there is no master schedule.
When a Citizen object is created, several record keeping objects must be created. This method creates those objects.
This does two things. It changes the culture feature f to v, and it also reports that change to the record keeper, the ModelSwarm.
Take a culture array and find out how many elements are the same as agent's own culture, and return that integer value
Create an attribute record for a contact. That means create an object where data about the other can be stored. Also it inserts that Attribute into the contacts map, which agents can use to lookup these attributes.
Finalizes the creation of objects from Citizen, and in so doing it sets initial values for a number of start-time variables.
For diagnostic information about the agent and his discussant
Sometimes, such as in showContacts, we want agents to be able to signal to us by drawing on the raster. Since the rasters represent only the home positions, this method gets world 0 and draws a color there.
Description forthcoming.
Return YES
or NO
indicating that the agent has changed an
opinion/trait during the current step
Return a Swarm Map of the agents that have been in contact.
Return a pointer to the first element of this agent's culture array
Return the value of feature f from this agent's culture array
Return culture feature f
Description forthcoming.
Return agent's identification number
Returns the flag indicating that the agent interacted with another agent during this period.
Return the number of contacts that have been made
Description forthcoming.
Return the (moving average) perceived likelihood that you have a randomly chosen feature in common with someone you come across
Return the (moving average) proportion of traits that are the same between this agent and the agent he interacts with
Return the (moving average) proportion of people agent interacts with who are identical with the agent
Move to Position 0, thought of as home.
Give the agent one of its positions, have it search
around for a discussant in there. This method takes
into account parochialism, looking within with
probability equal to 'paroch'. It may return
nil
if it does not find someone after
looking in all 4 neighboring cells
Here is the key method. The agent is told to find a discussant and then, if one is found, adjust opinion against: the input from the other.
When archived agents are reborn, they don't have all the information they need. We have to tell them to go get their positions from the model swarm, or else they don't ever situate themselves.
In a model with only two possible positions per agent, then moveToOtherPosition can be used to move from 1 to 0 or 0 to 1. This method figures out the current position, then moves to the other grid. The value 99 is "out of all positions", a value that is used if a person is simply unavailable for contact from others. Because we want to generalize to models with many different positions possible, this method is deprecated
Give a position object to the agent. From that position object, the agent can get coordinates where it is supposed to go and put itself there. Like 'go home' tells an agent to go to position 0 at known x,y coordinates. If the agent is currently in a world, it removes itself and goes where it is told
Suppose we want to investigate the impact of shocks on the model. This one changes feature f by a given magnitude
For diagnostic information about this agent, his position, and culture
At future time x, move self to the indicated world
At time future x, schedule self to initiate an interaction
At time x, schedule me for a step method
scheduleSleepAt will make the agent unavailable for contacts by others
All sublcasses must have rulse for selecting discussants
Set a string for the agent's name. Hopefully, it is unique
Set the change flag for the agent. At birth and at the
outset of each step, the change flag needs to be set
to NO
Set culture feature f to value v. This method is used when agents are created
Set citizen flexibility parameter. between 0 and 1
Determines how long agent stays home each day
An ID number is an integer, unique!
Set the interaction flag for the agent. At birth and at
the outset of each step, the interaction flag needs to
be set to NO
The introduction of serialization changed the semantics of the way agents track their locations. Here is one. The variable w indicates whether the values being set apply to a home or work position, and grid indicates which of the grids of that type is being used. The position of the agent in that grid is to be (xloc,yloc). There's some fancy footwork through which the agent then uses these values to retrive a pointer to the grid from the model swarm and then it encapsulates the information into a Position object
This tells the agents their coordinates in world w. It does not put them there.
For Master schedule models, the agents have to know where to insert actions to schedule themselves
If the model is run in GUI mode, this method will make contacts appear in white on the rasters
If the model is run in GUI mode, this method will make friends appear in red on the rasters, and the reds will be shaded by similarity
This is the central action method. The agent schedules its activities over a 'dayLength' period, beginning at home--positions[0] and then going to another place.
Given the other, check a randomly chosen feature. If we agree on that, then count that as a +1 in the acqMA. If they are not, add a 0. acqMA's value is thus the proportion of meetings that produce agreement
When agents interact, they gain information about he extent of their similarity. This method records that experience by updating the "attribute record" that the agent has stored. In the root Citizen class, all this does is take the attribute and set the similarity (number of shared features) in it. However, it passes an extra argument, which represents agreement on a randomly selected feature. Some subclasses want that extra info to do the book keeping they want.
Citizens keep records on the people that they interact with in a Swarm Map collection. So, if someone is a stranger, then an Attribute object is created and stored for the other. If the other is already known to this citizen, then the attribute information is updated. Subclasses can override or augment this method to make record keeping more or less elaborate
For each person that the agent has an interaction with, update the "same" (harmony) and "identical" moving averages.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.