|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
fr.lifl.jedi.model.Agent
public abstract class Agent
This class represents an agent family -- i.e. an entity of the simulated phenomenon -- in the JEDI simulation framework.
In JEDI, agents are physically represented in the environment with a rectangle surface
(see getSurface()
), for which :
getXPosition()
and
getYPosition()
methods.
getWidth()
and
getHeight()
methods.
Environment.canBePutAt(Agent, double, double)
and
Environment.canMoveForward(Agent, double)
.
Indeed, some agents might not be placed at the same position (their surface
cannot intersect).
For instance, a moving agent cannot be put at the same position than a wall.
Two methods are provided to handle this issue :
setSensitiveToObstacles(boolean)
(and isSensitiveToObstacles()
).
This method defines if an instance from this agent family can be placed at the same position
than an obstacle or not.
setObstacle(boolean)
(and isObstacle()
).
This method defines if instances from this agent family are considered as obstacles.
Agents sensitive to obstacle cannot be put at the same position than an obstacle.
An agent can move according to its direction (see getDirection()
), which is
expressed in degrees.
The methods getXPosition()
and getYPosition()
define the current position
of the center of the agent (the center of its surface).
The methods getPreviousXposition()
and getPreviousYposition()
define the position
that the agent had at the beginning of the time step.
An agent updates (see update()
) its state at the beginning of a time
step, before that any agent performs its interaction selection process.
In summary, the behavior of an agent is decomposed as following.
If the agent has the ability to initiate at least one interaction :
AbstractRealizableTuple
set.
InteractionSelectionPolicy
) to select a
tuple from this set.
If no tuple was selected, then the priority is decreased, otherwise, the loop is over.
An agent interacts only with the agents it perceives.
In JEDI, perceiving the set of neighboring agents is made in the method
perceive(Environment, Set)
.
An agent perceives all agents that lie in a particular
surface of the environment.
This surface is built thanks to the tools provided in
the singleton class HaloBuilder
.
The behavior of an agent (and its interaction selection process) is defined by its
interaction matrix line.
Please see getInteractionMatrixLine()
and InteractionMatrixLine
for more informations.
The method getInitiatedInteraction()
} returns the interaction the agent
initiated -- an instance of the AbstractRealizableTuple
class -- during the current
simulation step.
Obviously, the value it returns is consistent only at the end of a simulation step.
JEDI V 2.2 |
Created the 30th oct. 2008 |
Modified the 4th may 2009 |
Yoann Kubera |
SMAC Team (Systèmes Multi-Agents et Comportement) |
LIFL (Laboratoire d'Informatique Fondamentale de Lille) |
University of Lille, France |
Field Summary | |
---|---|
protected java.awt.geom.Rectangle2D.Double |
surface
For various reasons, an agent has to define the surface of the environment it occupies, for instance to avoid collisions with other agents. |
Constructor Summary | |
---|---|
Agent(double width,
double height,
InteractionMatrixLine line)
Constructor of the agent, that specifies the width and the height of the surface occupied by the agent. |
|
Agent(double width,
double height,
PhysicalHalo halo,
InteractionMatrixLine line)
Constructor of the agent, that specifies the width and the height of the surface occupied by the agent. |
|
Agent(InteractionMatrixLine line)
Constructor of the agent, that makes the assumption that an agent is a point. |
|
Agent(PhysicalHalo halo,
InteractionMatrixLine line)
Constructor of the agent, that makes the assumption that an agent is a point. |
Method Summary | |
---|---|
void |
afterStep()
Does some post-processing, after the end of the behavior of agents. |
void |
agentUpdate()
Method called by the simulation core in order to update the agent. |
void |
beforeStep()
Does some pre-processing, before starting the behavior of agents. |
double |
getDirection()
Gets the direction of the agent. |
PhysicalHalo |
getHalo()
Gets the halo of the agent -- i.e. |
double |
getHeight()
Gets the height of the agent. |
AbstractRealizableTuple<?> |
getInitiatedInteraction()
Gets the tuple that represents the interaction that was initiated by the agent during the simulation step. |
InteractionMatrixLine |
getInteractionMatrixLine()
Gets the interaction matrix line of the agent. |
double |
getPreviousXposition()
Gets the x coordinate of the position where the agent was at the beginning of the time step. |
double |
getPreviousYposition()
Gets the y coordinate of the position where the agent was at the beginning of the time step. |
java.awt.geom.Rectangle2D.Double |
getSurface()
For various reasons, an agent has to define the surface of the environment it occupies, for instance to avoid collisions with other agents. |
double |
getWidth()
Gets the width of the agent. |
double |
getXPosition()
Gets the position of the agents surface center along the x axis. |
double |
getYPosition()
Gets the position of the agents surface center along the y axis. |
boolean |
isActivable()
This method gets if the agent is activable. |
boolean |
isInEnvironment()
Checks if the agent is in the environment. |
boolean |
isObstacle()
Checks if the agent is considered as an obstacle. |
boolean |
isSensitiveToObstacles()
Checks if the agent is sensitive to obstacles. |
protected void |
perceive(Environment e,
java.util.Set<Agent> neighbors)
Triggers the perception phase of the agent. |
void |
setDirection(double d)
Sets the direction of the agent. |
void |
setHalo(PhysicalHalo halo)
Sets the halo of the agent -- i.e. |
void |
setInEnvironment(boolean b)
Sets if the agent is in the environment. |
void |
setInteractionMatrixLine(InteractionMatrixLine line)
Sets the interaction matrix line of the agent. |
void |
setNotActivable()
Set the agent as not activable. |
void |
setObstacle(boolean b)
Tells if the agent is considered as an obstacle. |
void |
setSensitiveToObstacles(boolean b)
Tells if the agent is sensitive to obstacles. |
void |
step(Environment e)
Makes the agent behave, according to its interaction matrix line. |
java.lang.String |
toString()
|
protected abstract void |
update()
Updates the state of the agent. |
void |
update(java.util.Observable o,
java.lang.Object not)
|
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.awt.geom.Rectangle2D.Double surface
For various reasons, an agent has to define the surface of the environment it occupies, for instance to avoid collisions with other agents.
JEDI makes the assumption that this surface is a rectangle :
The only entity that will manipulate this value is the environment class.
Constructor Detail |
---|
public Agent(double width, double height, PhysicalHalo halo, InteractionMatrixLine line)
By default, agents are neither sensitive to obstacles nor obstacles, and their direction points to the north (is equal to 0).
width
- the width of the surface occupied by
the agent.height
- the height of the surface occupied by
the agent.halo
- the halo of the agent, i.e. a surface
where the agent perceives other agents.
The halo is built thanks to the HaloBuilder
class.line
- the interaction matrix line of the agent.
It defines :
It can be null
if the agent has no
behavior.
InteractionMatrixLine
,
HaloBuilder
public Agent(double width, double height, InteractionMatrixLine line)
By default, agents are neither sensitive to obstacles nor obstacles, and their direction points to the north (is equal to 0).
With such a constructor, agents do not perceive other agents from the environment.
width
- the width of the surface occupied by
the agent.height
- the height of the surface occupied by
the agent.line
- the interaction matrix line of the agent.
It defines :
It can be null
if the agent has no
behavior.
InteractionMatrixLine
,
HaloBuilder
public Agent(PhysicalHalo halo, InteractionMatrixLine line)
By default, agents are neither sensitive to obstacles nor obstacles, and their direction points to the north (is equal to 0).
line
- the interaction matrix line of the agent.
It defines :
It can be null
if the agent has no
behavior.
halo
- the halo of the agent, i.e. a surface
where the agent perceives other agents. The halo is built thanks to the
HaloBuilder class.InteractionMatrixLine
public Agent(InteractionMatrixLine line)
By default, agents are neither sensitive to obstacles nor obstacles, and their direction points to the north (is equal to 0).
With such a constructor, agents do not perceive other agents from the environment.
line
- the interaction matrix line of the agent.
It defines :
It can be null
if the agent has no
behavior.
InteractionMatrixLine
Method Detail |
---|
public PhysicalHalo getHalo()
public void setHalo(PhysicalHalo halo)
halo
- the surface that represents what agents perceive.
Halo are created thanks to the HaloBuilder
singleton.
public InteractionMatrixLine getInteractionMatrixLine()
It defines :
It can be null
if the agent has no
behavior.
InteractionMatrixLine
public void setInteractionMatrixLine(InteractionMatrixLine line)
line
- the new interaction matrix line of the agent.
It defines :
It can be null
if the agent has no
behavior.
InteractionMatrixLine
public boolean isObstacle()
true
, then other agents that are sensitive to obstacles
cannot move onto its position.isSensitiveToObstacles()
public void setObstacle(boolean b)
b
- If true
, then other agents that are sensitive to obstacles
cannot move onto its position.isSensitiveToObstacles()
public boolean isSensitiveToObstacles()
true
, then the agent cannot move onto
a position if its surface will intersect the surface of an obstacle agent.isObstacle()
public void setSensitiveToObstacles(boolean b)
b
- true
, then the agent cannot move onto
a position if its surface will intersect the surface of an obstacle agent.isObstacle()
public java.awt.geom.Rectangle2D.Double getSurface()
For various reasons, an agent has to define the surface of the environment it occupies, for instance to avoid collisions with other agents.
JEDI makes the assumption that this surface is a rectangle :
The only entity that will manipulate this value
is the environment class.
Do not call this method in another context.
Call instead the methods getXPosition()
,
getYPosition()
, getWidth()
and
getHeight()
.
public double getXPosition()
public double getYPosition()
public double getPreviousXposition()
public double getPreviousYposition()
public double getWidth()
public double getHeight()
public boolean isInEnvironment()
This value is used for optimization purpose only.
The only entities that will manipulate
this attribute are the Environment
and SimulationThread
classes.
true
if the agent is
in the environment.public void setInEnvironment(boolean b)
This value is used for optimization purpose only.
The only entities that will manipulate
this attribute are the Environment
and SimulationThread
classes.
b
- true
if the agent
is in the environment.public double getDirection()
It belongs to the interval [-180; 180[, and corresponds to the angle expressed counterclockwise from the (0;1) vector.
Thus :
direction == 90
means 90°
to the left of the (0,1) vector;direction == -39
means 39°
to the right of the (0,1) vector;
public void setDirection(double d)
It belongs to the interval [-180; 180[, and corresponds to the angle expressed counterclockwise from the (0;1) vector.
Thus :
direction == 90
means 90°
to the left of the (0,1) vector;direction == -39
means 39°
to the right of the (0,1) vector;
d
- the new direction of the agent.public boolean isActivable()
This method returns false if :
SingleTargetInteraction
,
which SingleTargetInteraction.targetBecomesNotActivable()
method returns true
.
The value returned by this method determines if the agent is allowed to participate in the interaction during the time step.
It makes possible to forbid an agent to participate in more than one interaction during a simulation step.
true
if the agent is activable. In such a case, the agent
can participate in any interaction as a source or as a target.
If false
, it can only be the target of a SingleTargetInteraction
,
which SingleTargetInteraction.requiresActivableTarget()
method returns
false
.public void setNotActivable()
If this method is called, the can only be the target of a SingleTargetInteraction
,
which SingleTargetInteraction.requiresActivableTarget()
method returns
false
until the end of the simulation step.
This method is called only by the simulation core, and has not to be called by the user.
public void beforeStep()
public void afterStep()
protected abstract void update()
An agent updates its state at the beginning of a time step, before that any agent performs its interaction selection process.
public void agentUpdate()
This method calls update()
, and also
makes some processing.
protected void perceive(Environment e, java.util.Set<Agent> neighbors)
An agent sees all agents that lie in a particular
surface of the environment.
This surface is built thanks to the tools provided in
the singleton class HaloBuilder
.
e
- The environment in which perception is made.neighbors
- The list where neighboring agents are added.public AbstractRealizableTuple<?> getInitiatedInteraction()
public void step(Environment e)
If the agent has the ability to initiate at least one interaction :
AbstractRealizableTuple
set.
InteractionSelectionPolicy
) to select a
tuple from this set.
If no tuple was selected, then the priority is decreased, otherwise, the loop is over.
e
- The environment where the simulation takes place.InteractionMatrixLine
public void update(java.util.Observable o, java.lang.Object not)
update
in interface java.util.Observer
Observer.update(java.util.Observable, java.lang.Object)
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |