-
Notifications
You must be signed in to change notification settings - Fork 0
How it works
For this project we had to use different types of agents that had not at all the same behavior. A small ecosystem.
So we've decided to find a general pattern design for programming our agents (and others).
We thus reached a layered design, with each layer who defined a particularity of the agent.
By corollary, the diagram of classes we used, for the model side of our application, looks like something like this.
By definition an agent is dependent on its environment but an environment doesn't know and doesn't care if there are agents who navigates it or changes it.
So, the environment layer is defined like this :
- The environment can be navigated by agents.
- The environment guarantees the smooth functioning of its physical.
- The environment considers agents as any other parties making body of it.
- The environment can generate stimuli.
It's the only layer that doesn't define directly the agents, however the agents are maked to navigate on an environment, so the environment needs to be clearly defined before programming a single agent.
An agent has several interactions with his environment and the other agents, and this layer is the accumulation of those interactions. If something needs to communicate with the agent, it must pass by the interaction layer before the agent process the message received.
So, the interaction layer is defined like this :
- The interaction layer implements all the motor functions that the agent use to interact with his environment or the other agents.
- The interaction layer implements all the sensor functions that the agent use to receive stimuli emit by the environment or the other agents.
- The interaction layer defines the stimuli that the agent can receive (An agent doesn't necessarily receive all types of stimuli).
- The interaction layer implements all methods and attribute of a body of the environment.
An agent is defined by a loop of actions that he always does, in the same order.
An action defines which motor function of the interaction layer it will be triggered, and how it will be triggered.
So, the behavior layer is defined like this :
- The behavior layer implements this loop of actions.
- The behavior layer defines in which order the actions will be done.
- The behavior layer should be thought in real time ('cause it is the only layer of the agents that can be run in parallel).
By definition an agent is able to gather information of the environment (that the interaction layer's work) and defining what actions do accordingly.
So, the reasonning layer is defined like this :
- The reasonning layer implements all the methods that the agent use to define which action done or not.
- The reasonning layer could returns several actions.
- The reasonning layer could be modules runs in parallel of the behavior layer and sent their results after.
- The reasonning layer could absolutly implements a neural network.
- The reasonning layer is the only one that can interact with the memory layer.
Sometimes, an agent needs to remember what it was done before, what it was his previous states or positions. Or remember with which other agents his was already interacted and how.
So, the memory layer is defined like this :
- The memory layer implements all the attributes the agent needs to remember things.
- The memory layer could implements long-term and short-term memories.
- The memory layer not necessary implements list or map, it's also could be files or database.
If a MAS is the set composed by the envrionment, agents and all their interactions, the Model class is not the MAS it creates the elements of the MAS and get some statistics from them.
Here the elements created are the environment, the infrastructure agents and the vehicle agents.
The environment class implements the infrastructure of the roads network of the simulation, as well as the vehicle agents' bodies.
It is also used to update the positions of the movable agents.
The agent class, and its children, is used to create the parts (the body and the brain) of the agent and also to get some statistics concerning the agent from the different parts of the agent.
The body class, and its children, is the implementation of the interaction layer from the Layered Agent patern.
It is created by the agent class and in interaction with the environment class and a brain class.
The brain class, and its children, is the implementation of several layer from the Layered Agent pattern :
- The run method (abstract in the mother class) is the implementation of the behavior layer, calling reasonning methods according with the messages received by the body class.
- The private methods are the implementation of the reasonning layer.
- Some attributes (with "memory" in their name) are the implementation of the memory layer, this memory attributes may only be used by the reasonning methods.
It is created by the agent class, and in interaction with a body class, giving it orders.


