Package net.sf.tweety.agents
Class SynchronousProtocol
- java.lang.Object
-
- net.sf.tweety.agents.AbstractProtocol
-
- net.sf.tweety.agents.RigidProtocol
-
- net.sf.tweety.agents.SynchronousProtocol
-
- All Implemented Interfaces:
Protocol
- Direct Known Subclasses:
DirectGameProtocol
public class SynchronousProtocol extends RigidProtocol
This class models a synchronous protocol for multi-agent systems. This protocol asks all agents simultaneously for actions, and simultaneously executes these actions thereafter. The protocol can optionally be defined as rigid, i.e. if at any time an agent performs a "NO_OPERATION" he cannot perform any other action thereafter.
This protocol terminates when either
- an optional number of maximal steps has been required or
- every agent performs a NO_OPERATION at the same time or (if the protocol is defined to be rigid) after all agents performed one NO_OPERATION.- Author:
- Matthias Thimm
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
hasTerminated
This attribute indicates whether this protocol has terminated.private boolean
isRigid
Indicates whether this protocol is rigid.private int
numberOfSteps
This attribute indicates the number of steps to be performed until termination of this protocol.static int
UNLIMITED_EXECUTION
Indicates an unlimited number of execution steps of this protocol.
-
Constructor Summary
Constructors Constructor Description SynchronousProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem)
Creates a new (non-rigid) synchronous protocol for the given multi-agent system and unlimited number of steps.SynchronousProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem, boolean isRigid)
Creates a new synchronous protocol for the given multi-agent system and unlimited number of steps.SynchronousProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem, int numberOfSteps)
Creates a new (non-rigid) synchronous protocol for the given multi-agent system and the given number of steps.SynchronousProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem, int numberOfSteps, boolean isRigid)
Creates a new synchronous protocol for the given multi-agent system.
-
Method Summary
Modifier and Type Method Description protected java.util.Set<ActionEvent>
doStep()
Executes one step of the protocol.protected boolean
hasTerminated()
This method determines if this protocol has terminated, i.e.-
Methods inherited from class net.sf.tweety.agents.RigidProtocol
hasPerformedNoOperation, setHasPerformedNoOperation
-
Methods inherited from class net.sf.tweety.agents.AbstractProtocol
addProtocolListener, getMultiAgentSystem, notifyActionPerformed, notifyTerminated, removeProtocolListener, step
-
-
-
-
Field Detail
-
UNLIMITED_EXECUTION
public static final int UNLIMITED_EXECUTION
Indicates an unlimited number of execution steps of this protocol.- See Also:
- Constant Field Values
-
hasTerminated
private boolean hasTerminated
This attribute indicates whether this protocol has terminated.
-
numberOfSteps
private int numberOfSteps
This attribute indicates the number of steps to be performed until termination of this protocol.
-
isRigid
private boolean isRigid
Indicates whether this protocol is rigid.
-
-
Constructor Detail
-
SynchronousProtocol
public SynchronousProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem)
Creates a new (non-rigid) synchronous protocol for the given multi-agent system and unlimited number of steps.- Parameters:
multiAgentSystem
- a multi-agent system.
-
SynchronousProtocol
public SynchronousProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem, int numberOfSteps)
Creates a new (non-rigid) synchronous protocol for the given multi-agent system and the given number of steps.- Parameters:
multiAgentSystem
- a multi-agent system.numberOfSteps
- the number of steps for this protocol.
-
SynchronousProtocol
public SynchronousProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem, boolean isRigid)
Creates a new synchronous protocol for the given multi-agent system and unlimited number of steps.- Parameters:
multiAgentSystem
- a multi-agent system.isRigid
- whether this protocol is rigid.
-
SynchronousProtocol
public SynchronousProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem, int numberOfSteps, boolean isRigid)
Creates a new synchronous protocol for the given multi-agent system.- Parameters:
multiAgentSystem
- a multi-agent system.numberOfSteps
- the number of steps for this protocol.isRigid
- whether this protocol is rigid.
-
-
Method Detail
-
hasTerminated
protected boolean hasTerminated()
Description copied from class:AbstractProtocol
This method determines if this protocol has terminated, i.e. whether no further actions are possible.- Overrides:
hasTerminated
in classRigidProtocol
- Returns:
- "true" if this protocol system has terminated.
-
doStep
protected java.util.Set<ActionEvent> doStep() throws ProtocolTerminatedException
Description copied from class:AbstractProtocol
Executes one step of the protocol.- Specified by:
doStep
in classAbstractProtocol
- Returns:
- the set of events that occurred.
- Throws:
ProtocolTerminatedException
- if the protocol already terminated
-
-