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

Class MultiagentSimulation

source code

             object --+        
                      |        
                   dict --+    
                          |    
Multiagent.MultiagentSystem --+
                              |
                             MultiagentSimulation
Known Subclasses:

Base multiagent class that provides rudimentary state and turn-taking infrastructure

Instance Methods [hide private]
new empty dictionary

__init__(self, agents=[])
Initializes a simulation to contain the given list of agents.
source code
 
addMember(self, agent)
Adds the agent to this collection
source code
dict:StateKey→boolean
getStateKeys(self)
Returns: dictionary containing relevant state keys
source code
Distribution
getState(self)
Returns: the probability over the current states of all member agents
source code
 
deleteState(self, entity, feature)
Removes the given feature from the state vector
source code
str[]
getSequence(self)
Returns: the sequence of entities who will act in this simulaton
source code
 
initializeOrder(self)
Re-initializes the turn-taking order, in case of any addition/deletion of agents
source code
KeyedVector
generateOrder(self, entities=None)
Creates a new order vector
source code
str[]
next(self, order=None)
Computes the active agents in the next turn by determining which agents have an activation greater than threshold in the turn state
source code
KeyedTree
updateTurn(self, actions, debug=None)
Computes the (possibly cached) change in turn due to the specified actions
source code
Agent[]
activeMembers(self)
Returns: those agents who are able to take actions
source code
int
actorCount(self, level=0)
Returns: the total number of actors (including recursive beliefs) within this scenario
source code
int
actionCount(self, descend=True)
Returns: the total number of actions within this scenario
source code
 
generateActions(self, agents=None, result=None)
Generates all possible joint actions out of the given agents
source code
KeyedTree
createTurnDynamics(self, actions)
Computes the change in turn due to the specified actions
source code
 
applyTurn(self, delta, beliefs=None)
Applies provided turn changes
source code
 
__xml__(self) source code
 
parse(self, element, agentClass=None) source code
 
__copy__(self) source code
 
__deepcopy__(self, memo) source code

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

Inherited from dict: __cmp__, __contains__, __delitem__, __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__

Class Variables [hide private]
str turnFeature = '_turn'
the name of the feature labeling the turn status of each agent
  threshold = 0.5
the activation threshold for the agent's turnFeature valueb
Instance Variables [hide private]
teamwork.math.KeyedTree.KeyedTree _turnDynamics
the dynamics of turn taking
KeyedVector order
the base turn-taking order, which is the order set at the beginning of the simulation
int time
the number of epochs passed
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

Initializes a simulation to contain the given list of agents. If you would like to create your own turn state and dynamics, override the methods generateOrder and createTurnDynamics.

Parameters:
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

getStateKeys(self)

source code 
Returns: dict:StateKey→boolean
dictionary containing relevant state keys

getState(self)

source code 
Returns: Distribution
the probability over the current states of all member agents

deleteState(self, entity, feature)

source code 

Removes the given feature from the state vector

Parameters:
  • entity (str) - the entity on whom the feature currently exists
  • feature (str) - the state feature to remove

getSequence(self)

source code 
Returns: str[]
the sequence of entities who will act in this simulaton

generateOrder(self, entities=None)

source code 

Creates a new order vector

Returns: KeyedVector
the turn state vector suitable for the initial state of the simulation

next(self, order=None)

source code 

Computes the active agents in the next turn by determining which agents have an activation greater than threshold in the turn state

Parameters:
  • order (KeyedVector) - the order vector to use as the basis for computing the turn result (defaults to the current system turn state)
Returns: str[]
the names of those agents whose turn it is now. Each of the agents will thus act in parallel

updateTurn(self, actions, debug=None)

source code 

Computes the (possibly cached) change in turn due to the specified actions

Parameters:
  • actions (dict:str→Action[]) - the actions being performed, indexed by actor name
Returns: KeyedTree
the dynamics of change to the standing turn order based on the specified actions, suitable for passing to applyTurn to actually implement the changes

activeMembers(self)

source code 
Returns: Agent[]
those agents who are able to take actions

actorCount(self, level=0)

source code 
Parameters:
  • level (int) - The belief depth at which all agents will have their policies compiled, where 0 is the belief depth of the real agent. If the value of this flag is n, then all agents at belief depth≥n will have their policies compiled, while no agents at belief depth<n will.
Returns: int
the total number of actors (including recursive beliefs) within this scenario

actionCount(self, descend=True)

source code 
Parameters:
  • descend - flag, if True, the count includes actions in recursive beliefs; otherwise, not.
Returns: int
the total number of actions within this scenario

generateActions(self, agents=None, result=None)

source code 

Generates all possible joint actions out of the given agents

Parameters:
  • agents (Agent[]) - the agents eligible for action (defaults to currently eligible agents)

createTurnDynamics(self, actions)

source code 

Computes the change in turn due to the specified actions

Parameters:
Returns: KeyedTree
the dynamics of change to the standing turn order based on the specified actions, suitable for passing to applyTurn to actually implement the changes

applyTurn(self, delta, beliefs=None)

source code 

Applies provided turn changes

Parameters:
  • delta (KeyedTree) - changes, as computed by updateTurn
  • beliefs (dict) - the belief dictionary to be updated (defaults to this actual Simulation)

__xml__(self)

source code 
Overrides: Multiagent.MultiagentSystem.__xml__

parse(self, element, agentClass=None)

source code 
Overrides: Multiagent.MultiagentSystem.parse