Agent¶
-
class
Agent
(agent_id, model, properties, agent_type='agent')¶ Agent for agent based simulation. A simulation requires the implementation of at least one inheriting class An agent does things in the simulation and interacts with others
-
act
(time, round_no, step_no)¶ - This method is called by the scheduler every timestep. Agents implement their logic here.
- param time
this is the current simulation time (equivalent to round_no+step_no*dt)
- param round_no
round number
- param step_no
step number of round
- return
None
-
begin_episode
(episode_no)¶ This method is called by the simulation at the beginning of an episode, e.g. to allow a soft reset of the agent. The default implementation does nothing.
- param episode_no
the number of the episode
- return
None
-
end_episode
(episode_no)¶ This method is called by the simulation at the end of an epsiode, to allow tidy up if necessary. The default implementation does nothing.
- param episode_no
the number of the episode
- return
None
-
get_property
(name)¶ - Get one property
- param name
Name of property
- return
Dictionary for property
-
get_property_value
(name)¶ - Retrieves the value of a property.
- param name
The name of the property whose value is to be retrieved.
- return
The value of the property.
-
initialize
()¶ - Initialize the agent - called by the framework directly after the agent is instantiated, useful for any kind of initialization code.
- return
None
-
static
is_event_relevant
(threshold)¶ - Function to differentiate relevant and irrelevant events. It generates a random number – if this is smaller than the threshold, the event is deemed relevant.
- param threshold
Threshold for relevance
- return
Boolean
-
receive_event
(event)¶ - Receive an event
- param event
Event instance
- return
None
-
receive_instantaneous_event
(event)¶ - Handle an event immediately, do not wait for another round
- param event
event instance
- return
None
-
register_event_handler
(states, event, handler)¶ - Register an event handler.
- param states
States for which the event handler is valid
- param event
event instance
- param handler
Actual handler
- return
None
-
serialize
()¶ - Serialize the agent.
- return
Returns a dictionary containing the agent state
-
set_property
(name, data)¶ - Configure an agent property by passing a dictionary specifying the property.
- param name
The name of the property whose data is being set.
- param data
Specification of property (dictionary)
- return
-
set_property_value
(name, value)¶ - Sets the value of a property.
- param name
The name of the property to set.
- param value
The value of the property to set.
- return
-
to_string
()¶ - ToString method
- return
current state
-