HJCitizen class documentation

Authors

Generated by pauljohn

Software documentation for the HJCitizen class

HJCitizen : SelectiveCitizen

Declared in:
HJCitizen.h

In HJCitizen, the emphasis is on customizing the way agents find each other and react. This class is subclassed from SelectiveCitizen and its ancestor Axelod, so that we can inherit/use the Axelrod methods if we want to. That is done by the instance variables and methods in SelectiveCitizen

Assuming we don't tell this class to use either the Axelrod select or AxelrodAdjust methods, then this class is mostly about customizing the selection of discussants and adjusting opinion against them.

The identity-based selection of discussants is managed here by using information in the contacts map. The default method uses similarity measured as the number of issues that the citizen and discussant agreed on the last time they met. This raises the problem of what happens when an agent meets a stranger. We have considered several variants of the "stranger model". Strangers (individuals that the citizen has not interacted with before) have an assumed similarity value that depends on the citizen's past experience with strangers. The citizen selects the individual from his candidate list with the highest similarity value.

The really important action in this class turns out to be in the way it overrides
- adjustOpinionAgainst: (id)other
and implements this one:
- (BOOL)respondToPersuasionFrom: (Citizen *)other Feature: (int)featureToTest OtherOpinion: (int)otherOpinion

Unless we tell one of these agents to use the Axelrod method (recall that Axelrod assumed adjustment was automatic), these agents will use one of the variants we have considered. We suggest you check the source code on this. But, briefly:

Method summary

adjustOpinionAgainst:

- (id) adjustOpinionAgainst: (id)other;

HJ allows citizens to use information from past interactions to select discussants and make decisions on opinion changes. Given the identity of the other, this method gathers information from the other and it sets in process the adjustment of opinion. It has triggers that depend on whether only-one-adjusts or not.


buildObjects

- (id) buildObjects;

Creates any objects needed for this class


calculateStability:Value:

- (int) calculateStability: (int)featureToTest Value: (int)otherOpinion;

This is an experimental method. Ask the agent to ascertain how stable its personal network is in light of input from another opinion.


createEnd

- (id) createEnd;

Completes the creation of the agent. Initializes some instance variables


lispInReset

- (void) lispInReset;

If agents are created from a lispIn read of a saved simulation, it is necessary to set some environment variables that are not saved with the object. This gets that work done. Most importantly, it cycles through the list of contacts that was saved and uses the agent ID numbers to retrieve other information about them.


lispOutDeep:

- (void) lispOutDeep: (id)stream;

Save the HJCitizen's variables into the lisp serialization file


pollMemoryOnFeature:OwnOpinion:OtherOpinion:Threshold:

- (double) pollMemoryOnFeature: (int)featureToTest OwnOpinion: (int)myOpinion OtherOpinion: (int)otherOpinion Threshold: (double)threshold;

Just polls recollections, without going back to see how contacts currently feel


pollOnFeature:OwnOpinion:OtherOpinion:Threshold:

- (double) pollOnFeature: (int)featureToTest OwnOpinion: (int)myOpinion OtherOpinion: (int)otherOpinion Threshold: (double)threshold;

If you poll friends, you find people you used to agree with and ask them again about a question. Note distinction from "pollMemoryOfFriends" which does not update recollections against their current attitudes. This returns the proportion of friends who support the other opinion.


respondToPersuasionFrom:Feature:OtherOpinion:

- (BOOL) respondToPersuasionFrom: (Citizen*)other Feature: (int)featureToTest OtherOpinion: (int)otherOpinion;

HJ opinion adjustment: given a citizen, and a particular feature, decide if you want to copy their opinion. Inside this method, the setting of the "persuasionModel" is checked and taken into account. Recall, persuasion Model 0: check with "friends" to see what they think 1: examine recollections of "friends" to see what they thought last time you talked


selectADiscussantInPosition:

- (Citizen*) selectADiscussantInPosition: (Position*)position;

If the instance variable "axelrodSelect is set to YES, then it will use the inherited Axelrod method. Otherwise, it will scan the immendiate environment for the other perceived as most similar to itself, and it employs its information about past contacts and a "stranger model" to compile its list of possibilities.


setPersuasionModel:

- (void) setPersuasionModel: (int)p;

The persuasion model defaults to 0, this method can set it otherwise.


setSimilarityModel:

- (id) setSimilarityModel: (int)s;

The similarity model defaults to 0, this method can set it otherwise.


showContacts

- (int) showContacts;

This method hilights the agent's contacts on a display raster


showFriends

- (int) showFriends;

This method hilights the agent's friends on a display raster


updateAttribute:Total:Selected:

- (Attribute*) updateAttribute: (Attribute*)aContact Total: (int)similarity Selected: (BOOL)agree;

Agents keep records on the attributes of others that they have met. After interacting, this method is used to update the contact information on a particular other agent. This takes the "attribute" object from the contact, and then records the similarity value. Some methods of recording similarity take the total similarity--number of shared features, while others take a binary indicator of agreement.