Package teamwork :: Package multiagent :: Module GenericSociety :: Class GenericSociety
[hide private]
[frames] | no frames]

Class GenericSociety

source code

             object --+        
                      |        
                   dict --+    
                          |    
Multiagent.MultiagentSystem --+
                              |
                             GenericSociety

A taxonomy of generic agent models

In essence, a generic society is simply a dictionary of GenericModel objects. You can manipulate the society through the following operations:

  1. Creating a new society:
  2. Insert/overwrite a generic model:
  3. Get a generic model by name
  4. Get a list of model objects:
  5. Get a list of names of leaf nodes
  6. Get a list of leaf node model objects
  7. Delete a generic model
  8. Get a list of model names:
  9. Get a list of (name,model) tuples
  10. Create an instantiated agent model of a particular class
Instance Methods [hide private]
new empty dictionary

__init__(self, agents=[])
Initializes a collection to contain the given list of agents
source code
 
addMember(self, agent)
Adds the agent to this collection
source code
 
renameEntity(self, old, new) source code
 
merge(self, society)
Merges the contents of a new society into this one
source code
str[]
descendents(self, name)
Returns: the names of the given entity and all of its descendents in the hierarchy
source code
 
__delitem__(self, name)
del x[y]
source code
 
__xml__(self) source code
 
parse(self, element)
Extracts society elements from the provided XML Document
source code
 
importDict(self, hierarchy, modelClass=None)
Updates society from dictionary-style hierarchy
source code
 
__copyGeneric(self, generic)
Copies top-level generic values onto nested belief models
source code
 
leaves(self)
Returns a list of generic model names that are leaf nodes
source code
 
leafModels(self)
Returns a list of generic model objects that are leaf nodes
source code
 
instantiate(self, className, instanceName, objClass=None)
Returns a new instantiated agent model
source code

Inherited from Multiagent.MultiagentSystem: __str__, getMember, initialize, members, save

Inherited from dict: __cmp__, __contains__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __setitem__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__

Instance Variables [hide private]
  network
a dictionary representation of the descendent relationships in this society
  root
a list of all of the root models in this society
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, agents=[])
(Constructor)

source code 

Initializes a collection to contain the given list of agents

Returns:
new empty dictionary

Overrides: object.__init__

addMember(self, agent)

source code 

Adds the agent to this collection

Parameters:
Overrides: Multiagent.MultiagentSystem.addMember

Warning: will clobber any pre-existing agent with the same name

renameEntity(self, old, new)

source code 
Parameters:
  • old - the current name of the member
  • new - the new name of the member
  • old,new (str)

descendents(self, name)

source code 
Returns: str[]
the names of the given entity and all of its descendents in the hierarchy

__delitem__(self, name)
(Index deletion operator)

source code 

del x[y]

Overrides: dict.__delitem__
(inherited documentation)

__xml__(self)

source code 
Overrides: Multiagent.MultiagentSystem.__xml__

parse(self, element)

source code 

Extracts society elements from the provided XML Document

Overrides: Multiagent.MultiagentSystem.parse

importDict(self, hierarchy, modelClass=None)

source code 

Updates society from dictionary-style hierarchy

Parameters:
  • hierarchy (dict) - the specification of the generic society
  • modelClass (class) - the class for the individual generic agent models (default is GenericModel

instantiate(self, className, instanceName, objClass=None)

source code 

Returns a new instantiated agent model

Parameters:
  • className (str) - name of the relevant generic model
  • instanceName (str objClass: class to create agent object from (defaults to PsychEntity)) - name for the new instance