Class AbstractAgent

  • All Implemented Interfaces:
    IAgent, IAgent4Engine
    Direct Known Subclasses:
    ExtendedAgent, PassiveAgent

    public abstract class AbstractAgent
    extends Object
    implements IAgent4Engine
    An abstract implementation of the IAgent and IAgent4Engine 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
    • 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 interface IAgent
        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 interface IAgent
        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 be null.
        Throws:
        IllegalArgumentException - If the argument is null.
      • 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.

        Specified by:
        getLevels in interface IAgent
        Returns:
        A collection containing the identifier of the levels where this agent lies.
      • 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 interface IAgent
        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 interface IAgent4Engine
        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 interface IAgent
        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 interface IAgent4Engine
        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 interface IAgent4Engine
        Parameters:
        levelIdentifier - The identifier of the level from which the agent has to be removed.
      • 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 interface IAgent4Engine
        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 interface IAgent4Engine
        Parameters:
        perceivedData - The data that were lastly perceived by the agent from the levelIdentifier level.