Class ExtendedAgent
- java.lang.Object
-
- fr.univ_artois.lgi2a.similar.microkernel.libs.abstractimpl.AbstractAgent
-
- fr.univ_artois.lgi2a.similar.extendedkernel.agents.ExtendedAgent
-
- All Implemented Interfaces:
IAgent
,IAgent4Engine
public class ExtendedAgent extends AbstractAgent
Models an agent in the extended kernel.On the opposite of the micro-kernel, where agent classes had to be created, this class is self-sufficient. The operational code of the perception, global state revision and decision processes is defined in separate classes. The agent class only stores a reference to these classes.
Benefits
This property has huge benefits:- The behavior of the agent can be changed modularly: for instance, a modification in the decision process won't modify the class where the memory revision process is defined;
- The behavior of the agent can evolve at runtime.
-
The definition of the initial global state of the agent, using the
AbstractAgent.initializeGlobalState(IGlobalState)
method. -
The specification of the global state revision model of the agent, using the
specifyGlobalStateRevisionModel(IAgtGlobalStateRevisionModel)
method. -
The specification of the levels where the agent initially lies, using the
AbstractAgent.includeNewLevel(LevelIdentifier, ILocalStateOfAgent, ILocalStateOfAgent)
method. -
The specification of the behavior of the agent in each level where it can lie, using the
specifyBehaviorForLevel(LevelIdentifier, IAgtPerceptionModel, IAgtDecisionModel)
method.
Agent specification
The specification of such agents requires four operations:
Introspection and intercession
Agent introspection is achieved with the following methods:
Agent intercession is achieved with the following methods:
- Author:
- Yoann Kubera
-
-
Constructor Summary
Constructors Constructor Description ExtendedAgent(AgentCategory category)
Creates a bare instance of an agent, using a specific category.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
decide(LevelIdentifier levelId, SimulationTimeStamp timeLowerBound, SimulationTimeStamp timeUpperBound, IGlobalState globalState, ILocalStateOfAgent publicLocalState, ILocalStateOfAgent privateLocalState, IPerceivedData perceivedData, InfluencesMap producedInfluences)
Produces the influences resulting from the decisions of an agent from a specific level, for a specific transitory period.IAgtDecisionModel
getDecisionModel(LevelIdentifier levelId)
Gets the decision model of the agent from that level.IAgtGlobalStateRevisionModel
getGlobalStateRevisionModel()
Gets the revision model of the global state of the agent.IAgtPerceptionModel
getPerceptionModel(LevelIdentifier levelId)
Gets the perception model of the agent from that level.IPerceivedData
perceive(LevelIdentifier level, SimulationTimeStamp timeLowerBound, SimulationTimeStamp timeUpperBound, Map<LevelIdentifier,ILocalStateOfAgent> publicLocalStates, ILocalStateOfAgent privateLocalState, IPublicDynamicStateMap dynamicStates)
Creates the data perceived by an agent located in a specific level.void
removeBehaviorForLevel(LevelIdentifier levelId)
Removes the behavior of the agent for the specified level.void
reviseGlobalState(SimulationTimeStamp timeLowerBound, SimulationTimeStamp timeUpperBound, Map<LevelIdentifier,IPerceivedData> perceivedData, IGlobalState globalState)
Revises the content of the global state of the agent, using the previous value of its global state and the data that were lastly perceived by the agent.void
specifyBehaviorForLevel(LevelIdentifier levelId, IAgtPerceptionModel perceptionMdl, IAgtDecisionModel decisionMdl)
Defines the behavior of an agent from a specific level of the simulation.void
specifyGlobalStateRevisionModel(IAgtGlobalStateRevisionModel revisionMdl)
Defines the revision model of the global state of the agent.-
Methods inherited from class fr.univ_artois.lgi2a.similar.microkernel.libs.abstractimpl.AbstractAgent
excludeFromLevel, getCategory, getGlobalState, getLevels, getPerceivedData, getPrivateLocalState, getPublicLocalState, getPublicLocalStates, includeNewLevel, initializeGlobalState, setPerceivedData
-
-
-
-
Constructor Detail
-
ExtendedAgent
public ExtendedAgent(AgentCategory category)
Creates a bare instance of an agent, using a specific category. The agent has then to be initialized by calls to the following methods:-
The definition of the initial global state of the agent, using the
AbstractAgent.initializeGlobalState(IGlobalState)
method. -
The specification of the global state revision model of the agent, using the
specifyGlobalStateRevisionModel(IAgtGlobalStateRevisionModel)
method. -
The specification of the levels where the agent initially lies, using the
AbstractAgent.includeNewLevel(LevelIdentifier, ILocalStateOfAgent, ILocalStateOfAgent)
method. -
The specification of the behavior of the agent in each level where it can lie, using the
specifyBehaviorForLevel(LevelIdentifier, IAgtPerceptionModel, IAgtDecisionModel)
method.
- Parameters:
category
- The category of the agent.This value can be the name of this class, or any other string representation modeling the equivalence class of the agent.
Examples:
- Car
- Prey
- Water drop
- Throws:
IllegalArgumentException
- if the argument isnull
.
-
The definition of the initial global state of the agent, using the
-
-
Method Detail
-
getGlobalStateRevisionModel
public IAgtGlobalStateRevisionModel getGlobalStateRevisionModel()
Gets the revision model of the global state of the agent.- Returns:
- The revision model of the global state of the agent.
- Throws:
NoSuchElementException
- If no global state revision model is defined for that agent.
-
specifyGlobalStateRevisionModel
public void specifyGlobalStateRevisionModel(IAgtGlobalStateRevisionModel revisionMdl)
Defines the revision model of the global state of the agent.- Parameters:
revisionMdl
- The revision model of the global state of the agent.- Throws:
IllegalArgumentException
- If the argument isnull
.
-
getPerceptionModel
public IAgtPerceptionModel getPerceptionModel(LevelIdentifier levelId)
Gets the perception model of the agent from that level.- Parameters:
levelId
- The identifier of the level.- Returns:
- The perception model of the agent from that level.
- Throws:
NoSuchElementException
- If no perception model is defined for that agent for the level identified bylevelId
.
-
getDecisionModel
public IAgtDecisionModel getDecisionModel(LevelIdentifier levelId)
Gets the decision model of the agent from that level.- Parameters:
levelId
- The identifier of the level.- Returns:
- The decision model of the agent from that level.
- Throws:
NoSuchElementException
- If no decision model is defined for that agent for the level identified bylevelId
.
-
specifyBehaviorForLevel
public void specifyBehaviorForLevel(LevelIdentifier levelId, IAgtPerceptionModel perceptionMdl, IAgtDecisionModel decisionMdl)
Defines the behavior of an agent from a specific level of the simulation.Note that this behavior will be used only if the agent is added to that level using the appropriate system influences (or if the agent initially lies in that level).
- Parameters:
levelId
- The identifier of the level for which a behavior is specified.perceptionMdl
- The perception model of the agent from that level.decisionMdl
- The decision model of the agent from that level.- Throws:
IllegalArgumentException
- If an argument isnull
or has an inappropriate value.
-
removeBehaviorForLevel
public void removeBehaviorForLevel(LevelIdentifier levelId)
Removes the behavior of the agent for the specified level.- Parameters:
levelId
- The identifier of the level for which the behavior of the agent is removed.
-
perceive
public IPerceivedData perceive(LevelIdentifier level, SimulationTimeStamp timeLowerBound, SimulationTimeStamp timeUpperBound, Map<LevelIdentifier,ILocalStateOfAgent> publicLocalStates, ILocalStateOfAgent privateLocalState, IPublicDynamicStateMap dynamicStates)
Creates the data perceived by an agent located in a specific level.This method corresponds to the application perceptiona, ]t,t+dtl[, l of this agent.
- Parameters:
level
- The level from which perception is made (i.e. "l" in the notations).timeLowerBound
- Is the lower bound of the transitory period of the level identified bylevel
from which the perception is made by this agent (i.e. "t" in the notations).timeUpperBound
- Is the upper bound of the transitory period of the level identified bylevel
from which the perception is made by this agent (i.e. t+dtl in the notations).publicLocalStates
- All the public local states of the agent.privateLocalState
- The private local state of the agent in the level from which perception is made (i.e. φa-( t,level
) in the notations).dynamicStates
- The dynamic state of the various levels that can be perceived from the levellevel
. This value has previously been disambiguated by a heuristic defined in the simulation engine.- Returns:
- The data being perceived by the agent from the level identified by
level
, for the transitory period ]timeLowerBound
,timeUpperBound
[.
-
reviseGlobalState
public void reviseGlobalState(SimulationTimeStamp timeLowerBound, SimulationTimeStamp timeUpperBound, Map<LevelIdentifier,IPerceivedData> perceivedData, IGlobalState globalState)
Revises the content of the global state of the agent, using the previous value of its global state and the data that were lastly perceived by the agent.This method corresponds to the application memoryReva, ]t,t+dt[ of this agent.
As a side effect of this method call, the value μa( t ) of the argument
globalState
is updated to become μa(]t,t+dt[)- Parameters:
timeLowerBound
- Is the lower bound of the transitory period for which the global state revision is made by this agent (i.e. "t" in the notations).timeUpperBound
- Is the upper bound of the transitory period for which the global state revision is made by this agent (i.e. "t+dt" in the notations).perceivedData
- The map containing the data that were lastly perceived from the various levels of the simulation.globalState
- The previous value of the global state of the agent being updated by this method call.
-
decide
public void decide(LevelIdentifier levelId, SimulationTimeStamp timeLowerBound, SimulationTimeStamp timeUpperBound, IGlobalState globalState, ILocalStateOfAgent publicLocalState, ILocalStateOfAgent privateLocalState, IPerceivedData perceivedData, InfluencesMap producedInfluences)
Produces the influences resulting from the decisions of an agent from a specific level, for a specific transitory period.This method corresponds to the application decisiona, ]t,t+dtl[,l of this agent.
- Parameters:
levelId
- The identifier of the level from which the decision is made (i.e. "l" in the notations).timeLowerBound
- Is the lower bound of the transitory period for which the decision is made by this agent (i.e. "t" in the notations).timeUpperBound
- Is the upper bound of the transitory period for which the decision is made by this agent (i.e. "t+dt" in the notations).globalState
- The revised global state of the agent when it made a decision (i.e. μa(t+dt) in the notations).publicLocalState
- The public local state of the agent in the level from which decision is made (i.e. φa+( t,level
) in the notations).privateLocalState
- The private local state of the agent in the level from which decision is made (i.e. φa-( t,level
) in the notations).perceivedData
- The data that were perceived about the level identified bylevelId
and its perceptible levels.producedInfluences
- The map where the influences resulting from the decisions are stored.
-
-