Class AbstractAgent
- java.lang.Object
-
- fr.univ_artois.lgi2a.similar.microkernel.libs.abstractimpl.AbstractAgent
-
- All Implemented Interfaces:
IAgent
,IAgent4Engine
- Direct Known Subclasses:
ExtendedAgent
,PassiveAgent
public abstract class AbstractAgent extends Object implements IAgent4Engine
An abstract implementation of theIAgent
andIAgent4Engine
interfaces, providing a default behavior to the generic methods.This class also provides a method to set the level-related information of the agent (public and private local states) as well as its global state.
- Author:
- Yoann Kubera
-
-
Constructor Summary
Constructors Constructor Description AbstractAgent(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
excludeFromLevel(LevelIdentifier levelIdentifier)
Removes a level from the specification of this agent.AgentCategory
getCategory()
Gets the 'category' of agents to which this instance belongs to.IGlobalState
getGlobalState()
Gets the global state of the agent.Set<LevelIdentifier>
getLevels()
Gets the collection of the levels where this agent lies, i.e. the levels where this agent has a local state.Map<LevelIdentifier,IPerceivedData>
getPerceivedData()
Gets the data that were lastly perceived by the agent, for all the levels where it lies.ILocalStateOfAgent
getPrivateLocalState(LevelIdentifier levelId)
Gets the private local state of the agent located in a specific level of the simulation.ILocalStateOfAgent
getPublicLocalState(LevelIdentifier levelId)
Gets the public local state of the agent located in a specific level of the simulation.Map<LevelIdentifier,ILocalStateOfAgent>
getPublicLocalStates()
Gets the public local states of the agent.void
includeNewLevel(LevelIdentifier levelIdentifier, ILocalStateOfAgent publicLocalState, ILocalStateOfAgent privateLocalState)
Include a new level in the specification of this agent.void
initializeGlobalState(IGlobalState initialGlobalState)
Sets the value of the initial global state of the agent.void
setPerceivedData(IPerceivedData perceivedData)
Sets the data that were lastly perceived by the agent from a specific level where it lies.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.univ_artois.lgi2a.similar.microkernel.agents.IAgent
decide, perceive, reviseGlobalState
-
-
-
-
Constructor Detail
-
AbstractAgent
public AbstractAgent(AgentCategory category)
Creates a bare instance of an agent, using a specific category. The agent has then to be initialized by calls to theinitializeGlobalState(IGlobalState)
andincludeNewLevel(LevelIdentifier, ILocalStateOfAgent, ILocalStateOfAgent)
methods.- 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
.
-
-
Method Detail
-
getCategory
public AgentCategory getCategory()
Gets the 'category' of agents to which this instance belongs to.This method can return the name of this class, or any other string representation modeling the equivalence class of the agent.
Examples:
- Car
- Prey
- Water drop
- Specified by:
getCategory
in interfaceIAgent
- Returns:
- The 'category' of the agent.
-
getGlobalState
public IGlobalState getGlobalState()
Gets the global state of the agent.This method returns the value μa(t) or μa(]t,t′[)∈𝕄a, where the value of ]t,t′[ is defined by the context in which this method is called.
Usage and safety
This method has to be used only in the simulation engine.
- Specified by:
getGlobalState
in interfaceIAgent
- Returns:
- The global state of the agent.
-
initializeGlobalState
public void initializeGlobalState(IGlobalState initialGlobalState)
Sets the value of the initial global state of the agent.- Parameters:
initialGlobalState
- The value of the initial global state of the agent. This state cannot benull
.- Throws:
IllegalArgumentException
- If the argument isnull
.
-
getLevels
public Set<LevelIdentifier> getLevels()
Gets the collection of the levels where this agent lies, i.e. the levels where this agent has a local state.This method returns the levels in which the agent is defined, i.e. a list containing the identifier of each level l∈𝕃 such that φa(]t,t′[, l) exists. The value of ]t,t′[ is defined by the context in which this method is called.
Usage and safety
This method has to be used only in the simulation engine.
This method has to ensure that two consecutive iterations over this set always return its items in the same order.
-
getPublicLocalState
public ILocalStateOfAgent getPublicLocalState(LevelIdentifier levelId)
Gets the public local state of the agent located in a specific level of the simulation.This method returns the value φa+(t,
levelIdentifier
) or φa+(]t,t′[,levelIdentifier
) ∈Φa+, where the value of ]t,t′[ is defined by the context in which this method is called.Usage and safety
This method has to be used only in the simulation engine.
- Specified by:
getPublicLocalState
in interfaceIAgent
- Parameters:
levelId
- The identifier of the level of the public local state;- Returns:
- The public local state of the agent in the specified level.
-
getPublicLocalStates
public Map<LevelIdentifier,ILocalStateOfAgent> getPublicLocalStates()
Gets the public local states of the agent.This method returns all the values φa+(t, l) or φa+(]t,t′[, l) ∈Φa+, where the value of ]t,t′[ is defined by the context in which this method is called.
Usage and safety
This method has to be used only in the simulation engine.
- Specified by:
getPublicLocalStates
in interfaceIAgent4Engine
- Returns:
- The public local states of the agent.
-
getPrivateLocalState
public ILocalStateOfAgent getPrivateLocalState(LevelIdentifier levelId)
Gets the private local state of the agent located in a specific level of the simulation.This method returns the value φa-(t,
levelIdentifier
) or φa-(]t,t′[,levelIdentifier
) ∈Φa-, where the value of ]t,t′[ is defined by the context in which this method is called.Usage and safety
This method has to be used only in the simulation engine or in the reaction of the level identified by
levelIdentifier
.- Specified by:
getPrivateLocalState
in interfaceIAgent
- Parameters:
levelId
- The identifier of the level of the private local state;- Returns:
- The private local state of the agent in the specified level.
-
includeNewLevel
public void includeNewLevel(LevelIdentifier levelIdentifier, ILocalStateOfAgent publicLocalState, ILocalStateOfAgent privateLocalState)
Include a new level in the specification of this agent.If the agent already lies in the specified level when this method is called, then this method does nothing.
- Specified by:
includeNewLevel
in interfaceIAgent4Engine
- Parameters:
levelIdentifier
- The identifier of the specified level.publicLocalState
- The public local state of the agent in that level.privateLocalState
- The private local state of the agent in that level.
-
excludeFromLevel
public void excludeFromLevel(LevelIdentifier levelIdentifier)
Removes a level from the specification of this agent.Usage and safety
A call to this method is safe as long as:
-
It is made in the context of the reaction to the system influence removing the agent from
the level identified by
levelIdentifier
(simulation engine).
- Specified by:
excludeFromLevel
in interfaceIAgent4Engine
- Parameters:
levelIdentifier
- The identifier of the level from which the agent has to be removed.
-
It is made in the context of the reaction to the system influence removing the agent from
the level identified by
-
getPerceivedData
public Map<LevelIdentifier,IPerceivedData> getPerceivedData()
Gets the data that were lastly perceived by the agent, for all the levels where it lies.This method returns a map containing the identifier of a level "l" as a key, and the element pa(]tl,tl+dtl[, l) as a value, where ]tl,tl+dtl[ is the most recent transitory period of the level "l" during the call of this method.
- Specified by:
getPerceivedData
in interfaceIAgent4Engine
- Returns:
- The data that were lastly perceived by the agent, for all the levels where it lies.
-
setPerceivedData
public void setPerceivedData(IPerceivedData perceivedData)
Sets the data that were lastly perceived by the agent from a specific level where it lies.This method defines the value of an item of the map containing the identifier of a level "l" as a key, and the element pa(]tl,tl+dtl[, l) as a value, where ]tl,tl+dtl[ is the most recent transitory period of the level "l" during the call of this method.
- Specified by:
setPerceivedData
in interfaceIAgent4Engine
- Parameters:
perceivedData
- The data that were lastly perceived by the agent from thelevelIdentifier
level.
-
-