A
- The kind of Amas the agent refers toE
- The kind of Environment the agent AND the Amas refer topublic abstract class Agent<A extends Amas<E>,E extends Environment>
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Class and Description |
---|---|
static class |
Agent.Phase
These phases are used to synchronize agents on phase
|
Modifier and Type | Field and Description |
---|---|
protected A |
amas
Amas the agent belongs to
|
protected java.util.Map<Agent<A,E>,java.lang.Double> |
criticalities
Criticalities of the neighbors (and it self) as perceived at the beginning of
the agent's cycle
|
protected Agent.Phase |
currentPhase
The current phase of the agent
Agent.Phase |
protected java.util.List<Agent<A,E>> |
neighborhood
Neighborhood of the agent (must refer to the same couple amas, environment
|
protected java.lang.Object[] |
params
The parameters that can be user in the initialization process
onInitialization() |
Constructor and Description |
---|
Agent(A amas,
java.lang.Object... params)
The constructor automatically add the agent to the corresponding amas and
initialize the agent
|
Modifier and Type | Method and Description |
---|---|
protected int |
_computeExecutionOrder()
Compute the execution order from the layer and a random value.
|
protected void |
_onBeforeReady()
Called by the framework when all initial agents have been created and are
almost ready to be started
|
void |
addNeighbor(Agent<A,E>... agents)
Add neighbors to the agent
|
protected double |
computeCriticality()
This method must be overridden by the agents.
|
protected int |
computeExecutionOrderLayer()
This method must be overriden if you need to specify an execution order layer
|
void |
destroy()
Remove the agent from the system
|
A |
getAmas()
Getter for the AMAS
|
Agent.Phase |
getCurrentPhase()
Getter for the current phase of the agent
|
E |
getEnvironment()
Getter for the environment
|
int |
getExecutionOrder()
Get the latest computed execution order
|
int |
getId()
Return the id of the agent
|
protected Agent<A,E> |
getMostCriticalNeighbor(boolean includingMe)
Convenient method giving the most critical neighbor at a given moment
|
boolean |
isSynchronous() |
protected void |
onAct()
This method corresponds to the action phase of the agents and must be
overridden
|
protected void |
onAgentCycleBegin()
This method is called at the beginning of an agent's cycle
|
protected void |
onAgentCycleEnd()
This method is called at the end of an agent's cycle
|
protected void |
onDecide()
This method corresponds to the decision phase of the agents and must be
overridden
|
protected void |
onDecideAndAct()
Decide and act These two phases can often be grouped
|
protected void |
onDraw()
Deprecated.
Must be replaced by
onUpdateRender() |
void |
onePhaseCycle() |
protected void |
onExpose()
In this method the agent should expose some variables with its neighbor
|
protected void |
onInitialization()
Called before all agents are created
|
protected void |
onInitialize()
Deprecated.
Must be replaced by
onInitialization() |
protected void |
onPerceive()
This method corresponds to the perception phase of the agents and must be
overridden
|
protected void |
onReady()
Called when all initial agents have been created and are ready to be started
|
protected void |
onRenderingInitialization()
Called to initialize the rendering of the agent
|
protected void |
onSystemCycleBegin()
Deprecated.
This method is useless because the state of the agent is not
supposed to evolve before or after its cycle. Use
OnAgentCycleBegin/End instead.
This method is final because it must not be implemented.
Implement it will have no effect.
|
protected void |
onSystemCycleEnd()
Deprecated.
This method is useless because the state of the agent is not
supposed to evolve before or after its cycle. Use
OnAgentCycleBegin/End instead.
This method is final because it must not be implemented.
Implement it will have no effect.
|
protected void |
onUpdateRender()
This method should be used to update the representation of the agent for
example in a VUI
|
protected void |
phase1()
This method represents the perception phase of the agent
|
protected void |
phase2()
This method represents the decisionAndAction phase of the agent
|
void |
run()
This method is called automatically and corresponds to a full cycle of an
agent
|
protected void |
setAsynchronous() |
java.lang.String |
toString()
Agent toString
|
protected final java.util.List<Agent<A extends Amas<E>,E extends Environment>> neighborhood
protected final java.util.Map<Agent<A extends Amas<E>,E extends Environment>,java.lang.Double> criticalities
protected java.lang.Object[] params
onInitialization()
protected Agent.Phase currentPhase
Agent.Phase
public Agent(A amas, java.lang.Object... params)
amas
- Amas the agent belongs toparams
- The params to initialize the agent@SafeVarargs public final void addNeighbor(Agent<A,E>... agents)
agents
- The list of agent that should be considered as neighborprotected double computeCriticality()
protected void setAsynchronous()
protected int computeExecutionOrderLayer()
protected void onAgentCycleBegin()
protected void onAgentCycleEnd()
protected void onPerceive()
protected void onDecide()
protected void onAct()
protected void onExpose()
protected void onUpdateRender()
@Deprecated protected final void onDraw()
onUpdateRender()
protected void onReady()
protected final void _onBeforeReady()
protected void onInitialization()
@Deprecated protected final void onInitialize()
onInitialization()
protected void onRenderingInitialization()
@Deprecated protected final void onSystemCycleBegin()
@Deprecated protected final void onSystemCycleEnd()
public void run()
run
in interface java.lang.Runnable
public void onePhaseCycle()
protected final void phase1()
protected final void phase2()
protected int _computeExecutionOrder()
protected void onDecideAndAct()
protected final Agent<A,E> getMostCriticalNeighbor(boolean includingMe)
includingMe
- Should the agent also consider its own criticalitypublic int getExecutionOrder()
public A getAmas()
public void destroy()
public java.lang.String toString()
toString
in class java.lang.Object
public Agent.Phase getCurrentPhase()
public int getId()
public E getEnvironment()
public boolean isSynchronous()