E
- The environment of the MASpublic class Amas<E extends Environment> extends java.lang.Object implements Schedulable
Modifier and Type | Class and Description |
---|---|
static class |
Amas.ExecutionPolicy
The executionPolicy informs if agents must wait each other after the
perception and the decisionAndSction phases or only after the
decisionAndCycle phase.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.List<Agent<? extends Amas<E>,E>> |
agents
List of agents present in the system
|
protected int |
cycle
Number of cycles executed by the system
|
protected E |
environment
Environment of the system
|
protected java.lang.Object[] |
params
Parameters that can be passed to the constructor.
|
DEFAULT_SLEEP
Constructor and Description |
---|
Amas(E environment,
Scheduling scheduling,
java.lang.Object... params)
Constructor of the MAS
|
Modifier and Type | Method and Description |
---|---|
void |
_addAgent(Agent<?,E> _agent)
Add an agent to the MAS.
|
void |
_removeAgent(Agent<?,E> _agent)
Remove an agent from the MAS
|
void |
cycle()
Cycle of the system
|
java.util.List<Agent<? extends Amas<E>,E>> |
getAgents()
Getter for the list of agents
|
int |
getCycle()
Getter for the current cycle number
|
java.util.concurrent.Semaphore |
getDecisionAndActionPhasesSemaphore()
Getter for the decisionAndActionPhasesSemaphore
|
E |
getEnvironment()
Getter for the environment
|
Amas.ExecutionPolicy |
getExecutionPolicy()
Getter for the execution policy
|
java.util.concurrent.Semaphore |
getPerceptionPhaseSemaphore()
Getter for the perceptionPhaseSemaphore
|
Scheduler |
getScheduler()
Getter for the scheduler
|
protected void |
informThatAgentDecisionAndActionAreFinished()
Inform that agent has finished the DecisionAndAction phase
|
protected void |
informThatAgentPerceptionIsFinished()
Inform that agent gas finished the perception phase.
|
protected void |
onInitialAgentsCreation()
This method should be overridden, the agents should be created in this method
|
protected void |
onInitialConfiguration()
This method is called at the very beginning of the amas creation.
|
protected void |
onReady()
This method is called when all agents are ready
|
protected void |
onRenderingInitialization()
The method in which the rendering initialization should be made.
|
void |
onSchedulingStarts()
When the scheduling starts we need to create the thread pool for agents
execution
|
void |
onSchedulingStops()
This method is called when the scheduler stops (by stopCondition or explicit
stop)
|
protected void |
onSystemCycleBegin()
This method is called before all agents have executed a cycle
|
protected void |
onSystemCycleEnd()
This method is called when all agents have executed a cycle
|
protected void |
onUpdateRender()
The method in which you can update the rendering.
|
void |
start()
Helper method to launch the scheduler
|
boolean |
stopCondition()
This method allows the system to stop the scheduler on certain conditions
|
protected final java.util.List<Agent<? extends Amas<E extends Environment>,E extends Environment>> agents
protected int cycle
protected final E extends Environment environment
protected java.lang.Object[] params
public Amas(E environment, Scheduling scheduling, java.lang.Object... params)
environment
- Environment of the systemscheduling
- Scheduling modeparams
- The params to initialize the amaspublic Amas.ExecutionPolicy getExecutionPolicy()
protected void onRenderingInitialization()
VUI
protected final void informThatAgentPerceptionIsFinished()
protected final void informThatAgentDecisionAndActionAreFinished()
protected void onInitialConfiguration()
protected void onReady()
public Scheduler getScheduler()
protected void onInitialAgentsCreation()
public final void _addAgent(Agent<?,E> _agent)
_agent
- the agent to add to the systempublic final void _removeAgent(Agent<?,E> _agent)
_agent
- the agent to remove from the systempublic final void cycle()
cycle
in interface Schedulable
protected void onUpdateRender()
onRenderingInitialization()
protected void onSystemCycleEnd()
protected void onSystemCycleBegin()
public final int getCycle()
public final E getEnvironment()
public boolean stopCondition()
stopCondition
in interface Schedulable
public java.util.List<Agent<? extends Amas<E>,E>> getAgents()
public void start()
public final void onSchedulingStarts()
onSchedulingStarts
in interface Schedulable
public final void onSchedulingStops()
Schedulable
onSchedulingStops
in interface Schedulable
public java.util.concurrent.Semaphore getDecisionAndActionPhasesSemaphore()
public java.util.concurrent.Semaphore getPerceptionPhaseSemaphore()