Package jason.control
Class ExecutionControl
java.lang.Object
jason.control.ExecutionControl
- Direct Known Subclasses:
ExecutionControlGUI
public class ExecutionControl
extends java.lang.Object
Base class for the user implementation of execution control.
This default implementation synchronise the agents execution, i.e., each agent will perform its next reasoning cycle only when all agents have finished its reasoning cycle.
Execution sequence:
- setExecutionControlInfraTier,
- init,
- (receivedFinishedCycle)*,
- stop.
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.locks.Condition
agFinishedCond
private int
cycleNumber
private java.util.Set<java.lang.String>
finished
protected ExecutionControlInfraTier
infraControl
private boolean
isRunning
private java.util.concurrent.locks.Lock
lock
protected static java.util.logging.Logger
logger
private int
nbAgs
private boolean
runningCycle
private RuntimeServices
runtime
-
Constructor Summary
Constructors Constructor Description ExecutionControl()
-
Method Summary
Modifier and Type Method Description protected void
allAgsFinished()
Called when all agents have finished the current cycleint
getCycleNumber()
protected int
getCycleTimeout()
returns the maximum number of milliseconds of a cycleExecutionControlInfraTier
getExecutionControlInfraTier()
int
getNbAgs()
Returns the number of agents in the MAS (used to test the end of a cycle)void
init(java.lang.String[] args)
This method is called when setExecutionControlInfraTier was already calledboolean
isRunning()
void
receiveFinishedCycle(java.lang.String agName, boolean breakpoint, int cycle)
Called when the agent agName has finished its reasoning cycle.void
setExecutionControlInfraTier(ExecutionControlInfraTier jasonControl)
void
setNbAgs(int n)
Set the number of agentsvoid
setRunningCycle(boolean rc)
protected void
startNewCycle()
void
stop()
This method is called when MAS execution is being finishedprotected 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.java.lang.String
toString()
void
updateNumberOfAgents()
Updates the number of agents in the MAS, this default implementation, considers all agents in the MAS as actors .Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
infraControl
-
finished
private java.util.Set<java.lang.String> finished -
cycleNumber
private volatile int cycleNumber -
runningCycle
private volatile boolean runningCycle -
isRunning
private volatile boolean isRunning -
nbAgs
private int nbAgs -
lock
private java.util.concurrent.locks.Lock lock -
agFinishedCond
private java.util.concurrent.locks.Condition agFinishedCond -
runtime
-
logger
protected static java.util.logging.Logger logger
-
-
Constructor Details
-
ExecutionControl
public ExecutionControl()
-
-
Method Details
-
getCycleTimeout
protected int getCycleTimeout()returns the maximum number of milliseconds of a cycle -
startNewCycle
protected void startNewCycle() -
updateNumberOfAgents
public void updateNumberOfAgents()Updates the number of agents in the MAS, this default implementation, considers all agents in the MAS as actors . -
getNbAgs
public int getNbAgs()Returns the number of agents in the MAS (used to test the end of a cycle) -
setNbAgs
public void setNbAgs(int n)Set the number of agents -
receiveFinishedCycle
public void receiveFinishedCycle(java.lang.String agName, boolean breakpoint, int cycle)Called when the agent agName has finished its reasoning cycle. breakpoint is true in case the agent selected one plan with "breakpoint" annotation. -
testEndCycle
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.- Parameters:
finishedAgs
- the set of agents' name that already finished the current cycle
-
setExecutionControlInfraTier
-
getExecutionControlInfraTier
-
init
public void init(java.lang.String[] args)This method is called when setExecutionControlInfraTier was already called -
stop
public void stop()This method is called when MAS execution is being finished -
allAgsFinished
protected void allAgsFinished()Called when all agents have finished the current cycle -
isRunning
public boolean isRunning() -
getCycleNumber
public int getCycleNumber() -
setRunningCycle
public void setRunningCycle(boolean rc) -
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-