|
MATES 3.0-rc2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mates.sim.Simulator
Simulator class. This is the kernel of MATES.
Nested Class Summary | |
class |
Simulator.MigrationInfo
Internal class for agent migration bookkeeping. |
Constructor Summary | |
Simulator()
Builds a simulator with a DefaultTransportModel and
FullyConnectedLinkModel |
|
Simulator(LinkModel link_model)
Builds a simulator with a DefaultTransportModel |
|
Simulator(LinkModel link_model,
TransportModel transport_model)
Primary constructor. |
|
Simulator(TransportModel transport_model)
Builds a simulator with a FullyConnectedLinkModel |
Method Summary | |
void |
addEventListener(EventListener listener,
java.lang.Class event_class)
Adds an event listener to the simulator. |
void |
addEventListener(EventListener listener,
Event event_type)
Adds an event listener to the simulator. |
void |
addEventListener(EventListener listener,
java.lang.String event_class)
Adds an event listener to the simulator. |
void |
addExperiment(Experiment experiment)
Adds a new experiment that is controlling this simulator. |
void |
addHost(Host host)
Adds a host to the simulator |
void |
agentCreated(Agent agent)
Sends an AgentCreatedEvent to all event listeners. |
void |
clearEventListeners()
Removes all event listeners. |
java.util.Hashtable |
getAgentsInTransit()
Returns a the agents currently in transit. |
long |
getCurrentIteration()
Returns the current iteration of the simulator. |
double |
getDefaultRadioRange()
Returns the default radio range of a host. |
Bounds |
getDomainBounds()
Returns the bounds object for the domain. |
double |
getDomainHeight()
Returns the height of the domain. |
double |
getDomainWidth()
Returns the width of the domain. |
Experiment |
getExperiment()
Returns the first experiment controlling this simulator. |
Experiment[] |
getExperiments()
Returns an array containing all of the experiments controlling this simulator. |
java.util.Vector |
getHosts()
Returns the hosts in the simulator. |
LinkModel |
getLinkModel()
Accessor for the simulation's link model. |
double |
getLinkQuality(Host host1,
Host host2)
Returns the link quality between two hosts, according to the link model. |
java.io.OutputStream |
getLogStream()
Returns the output stream for the log. |
java.util.Vector |
getNeighbors(Host host)
Returns the neighbors of a host. |
static int |
getNumThreads()
Returns the current number of threads each simulator is to run concurrently. |
java.util.Random |
getRandom()
Accessor for the random number generator of the simulator. |
Topology |
getTopology()
Returns the current network topology. |
void |
hostClicked(Host host,
java.awt.event.MouseEvent mouse_event)
Raises a new HostClickedEvent . |
boolean |
isValidPosition(Position position)
Returns true if position is within
the bounds of the domain. |
void |
iterate()
Iterates the entire simulation. |
void |
killAgent(Agent agent)
Kills an agent. |
void |
log(java.lang.Object source,
java.lang.String message)
Records a log message. |
boolean |
migrate(Agent agent,
Host destination)
Initiates an agent migration. |
UniqueID |
newUniqueID()
Creates a new unique identifier for an object. |
long |
numAgentsInTransit()
Returns the number of agents currently in transit. |
protected void |
raiseEvent(Event event)
Forwards an event to all event listeners |
boolean |
removeExperiment(Experiment experiment)
Removes an experiment that is controlling this simulator. |
void |
removeHost(Host host)
Removes a host from the simulator. |
void |
reset()
Removes all of the hosts, agents, and event listeners, resets the iteration counter to 0, and resets all of the statistics (e.g. average host degree). |
void |
setDefaultRadioRange(double radio_range)
Sets the default radio range of a host. |
void |
setDomainBounds(Bounds bounds)
Sets the object that defines the bounds of the domain. |
void |
setDomainHeight(double height)
Sets the height of the domain bounds. |
void |
setDomainWidth(double width)
Sets the width of the domain bounds. |
void |
setLinkModel(LinkModel link_model)
Sets this simulator's link model. |
void |
setLogStream(java.io.OutputStream stream)
Sets the output location for all log messages. |
static void |
setNumThreads(int new_num_threads)
Sets the number of threads that each simulator should run concurrently. |
void |
updateTopology()
Updates the topology based upon the current host positions and the link model. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Simulator(LinkModel link_model, TransportModel transport_model)
link_model
- the link model to usetransport_model
- the transport model to usepublic Simulator(LinkModel link_model)
DefaultTransportModel
link_model
- the link model to usepublic Simulator(TransportModel transport_model)
FullyConnectedLinkModel
transport_model
- the transport model to use.public Simulator()
DefaultTransportModel
and
FullyConnectedLinkModel
Method Detail |
public void addHost(Host host)
host
- the host to addpublic void removeHost(Host host)
host
- the host to be removed.public void addExperiment(Experiment experiment)
Experiment
is
created, its constructor automatically adds itself to its
simulator by calling this function.
getExperiments()
,
getExperiment()
,
removeExperiment(org.mates.sim.Experiment)
public Experiment[] getExperiments()
addExperiment(org.mates.sim.Experiment)
public Experiment getExperiment()
getExperiments()[0]
, however a check is performed
to make sure getExperiments()
does not return an
empty list. If there are no experiments associated with this
simulator, null
is returned.
getExperiments()
public boolean removeExperiment(Experiment experiment)
true
if the experiment was controlling
this simulator (and was therefore successfully removed)addExperiment(org.mates.sim.Experiment)
public static void setNumThreads(int new_num_threads)
public static int getNumThreads()
public long numAgentsInTransit()
public java.util.Hashtable getAgentsInTransit()
Agent
objects, while the values are the Simulator.MigrationInfo
bookkeeping objects associated with each agent.
public java.util.Vector getHosts()
public void reset()
public java.util.Random getRandom()
public double getLinkQuality(Host host1, Host host2)
host1
and
host2
public void setLinkModel(LinkModel link_model)
public LinkModel getLinkModel()
public Topology getTopology()
public java.util.Vector getNeighbors(Host host)
public UniqueID newUniqueID()
public void updateTopology()
public void setDomainBounds(Bounds bounds)
Bounds
object.
public Bounds getDomainBounds()
public double getDomainWidth()
java.lang.IllegalStateException
- if getDomainBounds()
is not instanceof
BoundingBox
.public void setDomainWidth(double width)
instanceof
BoundingBox
, they will be made one, with
dimensions of a square.
public void setDomainHeight(double height)
instanceof
BoundingBox
, they will be made one, with
dimensions of a square.
public double getDomainHeight()
java.lang.IllegalStateException
- if getDomainBounds()
is not instanceof
BoundingBox
.public boolean isValidPosition(Position position)
true
if position
is within
the bounds of the domain. This is equivalent to calling
getDomainBounds().contains(position)
.
getDomainBounds()
,
Bounds.contains(org.mates.util.Position)
public void iterate()
public long getCurrentIteration()
public void clearEventListeners()
public void setDefaultRadioRange(double radio_range)
public double getDefaultRadioRange()
public void addEventListener(EventListener listener, Event event_type)
public void addEventListener(EventListener listener, java.lang.Class event_class)
public void addEventListener(EventListener listener, java.lang.String event_class)
public void killAgent(Agent agent)
agent
- the agent to be killed.public void agentCreated(Agent agent)
AgentCreatedEvent
to all event listeners.
agent
- the agent that was createdpublic boolean migrate(Agent agent, Host destination)
new_host
are in
communication range.
This function returns true
if the migration is
valid. In other words, new_host
is a valid
destination and this agent is not already in the process of
migrating. This return value ensures that the migration
process has started; it has nothing to do with the success or
completion of the migration.
agent
- the agent to be migrateddestination
- the host to which the agent is migrating
protected void raiseEvent(Event event)
public void setLogStream(java.io.OutputStream stream)
System.out
. If null
, logging is
suppressed in the simulator and is left up to the experiment to
implement by registering to receive LogEvent
messages.
public java.io.OutputStream getLogStream()
null
.
public void hostClicked(Host host, java.awt.event.MouseEvent mouse_event)
HostClickedEvent
.
java.lang.NullPointerException
- if host
is null
public void log(java.lang.Object source, java.lang.String message)
|
MATES 3.0-rc2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |