Package net.sf.tweety.agents
Class MultiAgentSystem<T extends Agent>
- java.lang.Object
-
- net.sf.tweety.agents.MultiAgentSystem<T>
-
- Type Parameters:
T- the agent class.
- All Implemented Interfaces:
Iterable<T>,Collection<T>
public class MultiAgentSystem<T extends Agent> extends Object implements Collection<T>
A multi-agent system is a collection of agents with some environment.- Author:
- Matthias Thimm
-
-
Field Summary
Fields Modifier and Type Field Description static intEXECUTE_TILL_TERMINATIONIndicates that the execution of this system's protocol should be repeated until it has terminated.
-
Constructor Summary
Constructors Constructor Description MultiAgentSystem(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 Type Method Description booleanadd(T e)booleanaddAll(Collection<? extends T> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)booleanequals(Object obj)voidexecute(AbstractProtocol protocol)Executes the given protocol till it terminates.booleanexecute(AbstractProtocol protocol, int numOfSteps)Executes the given protocol for the given number of steps.EnvironmentgetEnvironment()Returns the environment of this multi-agent system.inthashCode()booleanisEmpty()Iterator<T>iterator()booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()Object[]toArray()<S> S[]toArray(S[] a)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Field Detail
-
EXECUTE_TILL_TERMINATION
public static final int EXECUTE_TILL_TERMINATION
Indicates that the execution of this system's protocol should be repeated until it has terminated.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MultiAgentSystem
public MultiAgentSystem(Environment environment)
Creates a new empty multi-agent system with the given environment.- Parameters:
environment- some environment.
-
MultiAgentSystem
public MultiAgentSystem(Environment environment, Collection<? extends T> agents)
Creates a new multi-agent system with the given collection of agents.- Parameters:
agents- a collection of agents.environment- some environment.
-
-
Method Detail
-
getEnvironment
public Environment 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, IllegalArgumentException
Executes 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
public void execute(AbstractProtocol protocol) throws ProtocolTerminatedException
Executes the given protocol till it terminates.- Parameters:
protocol- a protocol.- Throws:
ProtocolTerminatedException- if the protocol has already terminated.
-
add
public boolean add(T e)
- Specified by:
addin interfaceCollection<T extends Agent>
-
addAll
public boolean addAll(Collection<? extends T> c)
- Specified by:
addAllin interfaceCollection<T extends Agent>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<T extends Agent>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<T extends Agent>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<T extends Agent>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T extends Agent>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<T extends Agent>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<T extends Agent>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<T extends Agent>
-
size
public int size()
- Specified by:
sizein interfaceCollection<T extends Agent>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<T extends Agent>
-
toArray
public <S> S[] toArray(S[] a)
- Specified by:
toArrayin interfaceCollection<T extends Agent>
-
hashCode
public int hashCode()
-
-