Package net.sf.tweety.agents
Class RoundRobinProtocol
- java.lang.Object
-
- net.sf.tweety.agents.AbstractProtocol
-
- net.sf.tweety.agents.RigidProtocol
-
- net.sf.tweety.agents.RoundRobinProtocol
-
- All Implemented Interfaces:
Protocol
- Direct Known Subclasses:
GroundedGameProtocol
public class RoundRobinProtocol extends RigidProtocol
This class models a round robin protocol for multi-agent systems. This protocol assumes some order of the agents and asks each agent for some action which is directly executed in the environment. This process is repeated for all agents. 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 there has been no actions for a full round 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 java.util.List<Agent>
agentsOrdered
The ordering of the agents.private int
agentsSkipped
The number of agents that skipped performing an action within the last round.private int
currendIdx
The index of the agent who may perform the next action.private boolean
isRigid
Indicates whether this protocol is rigid.private static org.slf4j.Logger
log
Logger
-
Constructor Summary
Constructors Constructor Description RoundRobinProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem)
Creates a new (non-rigid) round robin protocol for the given multi-agent system.RoundRobinProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem, boolean isRigid)
Creates a new (non-rigid) round robin 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
-
log
private static org.slf4j.Logger log
Logger
-
agentsOrdered
private java.util.List<Agent> agentsOrdered
The ordering of the agents.
-
currendIdx
private int currendIdx
The index of the agent who may perform the next action.
-
agentsSkipped
private int agentsSkipped
The number of agents that skipped performing an action within the last round.
-
isRigid
private boolean isRigid
Indicates whether this protocol is rigid.
-
-
Constructor Detail
-
RoundRobinProtocol
public RoundRobinProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem)
Creates a new (non-rigid) round robin protocol for the given multi-agent system.- Parameters:
multiAgentSystem
- a multi-agent system.
-
RoundRobinProtocol
public RoundRobinProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem, boolean isRigid)
Creates a new (non-rigid) round robin protocol for the given multi-agent system.- Parameters:
multiAgentSystem
- a multi-agent system.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
-
-