Package org.tweetyproject.agents
Class MultiAgentSystem<T extends Agent>
java.lang.Object
org.tweetyproject.agents.MultiAgentSystem<T>
- Type Parameters:
T
- the agent class.
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
- Direct Known Subclasses:
GroundedGameSystem
,LotteryGameSystem
,StructuredArgumentationSystem
A multi-agent system is a collection of agents with some environment.
- Author:
- Matthias Thimm
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Indicates that the execution of this system's protocol should be repeated until it has terminated. -
Constructor Summary
ConstructorDescriptionMultiAgentSystem(Environment environment)
Creates a new empty multi-agent system with the given environment.MultiAgentSystem(Environment environment, Collection<? extends T> agents)
Creates a new multi-agent system with the given collection of agents. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll(Collection<? extends T> c)
void
clear()
boolean
boolean
containsAll(Collection<?> c)
boolean
void
execute(AbstractProtocol protocol)
Executes the given protocol till it terminates.boolean
execute(AbstractProtocol protocol, int numOfSteps)
Executes the given protocol for the given number of steps.Returns the environment of this multi-agent system.int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
int
size()
Object[]
toArray()
<S> S[]
toArray(S[] a)
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
EXECUTE_TILL_TERMINATION
public static final int EXECUTE_TILL_TERMINATIONIndicates that the execution of this system's protocol should be repeated until it has terminated.- See Also:
- Constant Field Values
-
-
Constructor Details
-
MultiAgentSystem
Creates a new empty multi-agent system with the given environment.- Parameters:
environment
- some environment.
-
MultiAgentSystem
Creates a new multi-agent system with the given collection of agents.- Parameters:
agents
- a collection of agents.environment
- some environment.
-
-
Method Details
-
getEnvironment
Returns the environment of this multi-agent system.- Returns:
- the environment of this multi-agent system.
-
execute
public boolean execute(AbstractProtocol protocol, int numOfSteps) throws ProtocolTerminatedException, IllegalArgumentExceptionExecutes the given protocol for the given number of steps. Set steps to Protocol.EXECUTE_TILL_TERMINATION to have the protocol executed till termination.- Parameters:
protocol
- a protocol.numOfSteps
- the number of steps to be executed.- Returns:
- "true" if the protocol has terminated after executing the given number of steps.
- Throws:
ProtocolTerminatedException
- if the protocol terminates before all steps could be executed.IllegalArgumentException
- if the given number of steps is zero or negative and not equal to Protocol.EXECUTE_TILL_TERMINATION.
-
execute
Executes the given protocol till it terminates.- Parameters:
protocol
- a protocol.- Throws:
ProtocolTerminatedException
- if the protocol has already terminated.
-
add
- Specified by:
add
in interfaceCollection<T extends Agent>
-
addAll
- Specified by:
addAll
in interfaceCollection<T extends Agent>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<T extends Agent>
-
contains
- Specified by:
contains
in interfaceCollection<T extends Agent>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T extends Agent>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T extends Agent>
-
iterator
-
remove
- Specified by:
remove
in interfaceCollection<T extends Agent>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T extends Agent>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T extends Agent>
-
size
public int size()- Specified by:
size
in interfaceCollection<T extends Agent>
-
toArray
- Specified by:
toArray
in interfaceCollection<T extends Agent>
-
toArray
public <S> S[] toArray(S[] a)- Specified by:
toArray
in interfaceCollection<T extends Agent>
-
hashCode
public int hashCode() -
equals
-