public class TimeSteppedEnvironment extends Environment
Modifier and Type | Class and Description |
---|---|
(package private) class |
TimeSteppedEnvironment.ActRequest |
static class |
TimeSteppedEnvironment.OverActionsPolicy
Policy used when a second action is requested and the agent still has another action pending execution
|
(package private) class |
TimeSteppedEnvironment.TimeOutThread |
Modifier and Type | Field and Description |
---|---|
private java.util.logging.Logger |
logger |
private int |
nbAgs |
private TimeSteppedEnvironment.OverActionsPolicy |
overActPol |
private java.util.Queue<TimeSteppedEnvironment.ActRequest> |
overRequests |
private java.util.Map<java.lang.String,TimeSteppedEnvironment.ActRequest> |
requests |
private int |
sleep |
private int |
step |
private long |
stepTimeout |
private TimeSteppedEnvironment.TimeOutThread |
timeoutThread |
executor
Constructor and Description |
---|
TimeSteppedEnvironment() |
Modifier and Type | Method and Description |
---|---|
Structure |
getActionInSchedule(java.lang.String agName) |
int |
getNbAgs()
Returns the number of agents in the MAS (used to test the end of a cycle)
|
java.util.Collection<Literal> |
getPercepts(java.lang.String agName)
stops perception while executing the step's actions
|
int |
getStep()
returns the current step counter
|
void |
init(java.lang.String[] args)
Called before the MAS execution with the args informed in
.mas2j project, the user environment could override it.
|
protected int |
requiredStepsForAction(java.lang.String agName,
Structure action) |
void |
scheduleAction(java.lang.String agName,
Structure action,
java.lang.Object infraData)
Called by the agent infrastructure to schedule an action to be
executed on the environment
|
void |
setNbAgs(int n)
Set the number of agents
|
void |
setOverActionsPolicy(TimeSteppedEnvironment.OverActionsPolicy p)
Sets the policy used for the second ask for an action while another action is not finished yet.
|
void |
setSleep(int s)
defines the time for a pause between cycles
|
void |
setTimeout(int to) |
private void |
startNewStep() |
protected void |
stepFinished(int step,
long elapsedTime,
boolean byTimeout)
to be overridden by the user class
|
protected void |
stepStarted(int step)
to be overridden by the user class
|
void |
stop()
Called just before the end of MAS execution, the user
environment could override it.
|
protected boolean |
testEndCycle(java.util.Set<java.lang.String> finishedAgs)
Returns true when a new cycle can start, it normally
holds when all agents are in the finishedAgs set.
|
protected void |
updateAgsPercept()
This method is called after the execution of the action and before to send 'continue' to the agents
|
protected void |
updateNumberOfAgents()
Updates the number of agents using the environment, this default
implementation, considers all agents in the MAS as actors in the
environment.
|
addPercept, addPercept, clearAllPercepts, clearPercepts, clearPercepts, consultPercepts, containsPercept, containsPercept, executeAction, getEnvironmentInfraTier, getLogger, informAgsEnvironmentChanged, informAgsEnvironmentChanged, isRunning, removePercept, removePercept, removePerceptsByUnif, removePerceptsByUnif, setEnvironmentInfraTier
private java.util.logging.Logger logger
private int step
private int nbAgs
private java.util.Map<java.lang.String,TimeSteppedEnvironment.ActRequest> requests
private java.util.Queue<TimeSteppedEnvironment.ActRequest> overRequests
private TimeSteppedEnvironment.TimeOutThread timeoutThread
private long stepTimeout
private int sleep
private TimeSteppedEnvironment.OverActionsPolicy overActPol
public void init(java.lang.String[] args)
Environment
init
in class Environment
public void setSleep(int s)
public void setTimeout(int to)
public void stop()
Environment
stop
in class Environment
protected void updateNumberOfAgents()
public int getNbAgs()
public void setNbAgs(int n)
public int getStep()
public void setOverActionsPolicy(TimeSteppedEnvironment.OverActionsPolicy p)
public void scheduleAction(java.lang.String agName, Structure action, java.lang.Object infraData)
Environment
scheduleAction
in class Environment
public Structure getActionInSchedule(java.lang.String agName)
protected boolean testEndCycle(java.util.Set<java.lang.String> finishedAgs)
finishedAgs
- the set of agents' name that already finished the current cycleprotected void updateAgsPercept()
private void startNewStep()
protected void stepStarted(int step)
protected void stepFinished(int step, long elapsedTime, boolean byTimeout)
protected int requiredStepsForAction(java.lang.String agName, Structure action)
public java.util.Collection<Literal> getPercepts(java.lang.String agName)
getPercepts
in class Environment