AnyLogic
Expand
Font size
All Superinterfaces:
AgentExtension, Serializable
All Known Subinterfaces:
ExtEnvironmentContinuous, ExtEnvironmentDiscrete, ExtEnvironmentGIS, ExtEnvironmentWithLayout, ExtEnvironmentWithMetrics

public interface ExtEnvironmentInteractive
extends AgentExtension
Extension interface for agent environment with communication enabled.
Author:
AnyLogic North America, LLC https://anylogic.com

Field Summary

Method Summary

Modifier and TypeMethodDescription
Collection<Agent>agents()
Returns the collection of all agents registered with this environment.
default voidapplyNetwork()
Discards all existing connections and establishes new connection network according to the current network settings.
voidapplyNetwork(Random r)
Discards all existing connections and establishes new connection network according to the current network settings, using the specified random number generator, if required by network type.
booleanareStepsEnabled()
Tests if the time steps are enabled.
voiddeliverToAllAgentsInside(Object msg)
Immediately delivers a message to all agents in the environment.
voiddeliverToRandomAgentInside(Object msg)
Immediately delivers a message to a random agent in the environment, if there are any agents.
voiddisableSteps()
Disables time steps.
voidenableSteps(double stepDuration)
Enables discrete time steps with a given duration.
doublegetNetworkConnectionsPerAgent()
Returns the average (or exact) number of connections per agent.
doublegetNetworkNeighborLinkProbability()
Returns the probability of an agent connection to be a neighbor.
intgetNetworkScaleFreeM()
Returns the M parameter of a scale free network.
NetworkTypegetNetworkType()
Returns the network type.
SpaceTypegetSpaceType()
Returns the space type of this environment, one of SPACE_CONTINUOUS, SPACE_DISCRETE, SPACE_GIS, SPACE_NONE
default AgentrandomAgentExcept(Agent agent)
Returns a randomly chosen agent in the environment except the given agent or null if there are no such agents
AgentrandomAgentExcept(Random r, Agent agent)
Returns a randomly chosen agent in the environment except the given agent or null if there are no such agents.
default AgentrandomAgentInside()
Returns a randomly chosen agent in the environment or null if there are no agents
AgentrandomAgentInside(Random r)
Returns a randomly chosen agent in the environment or null if there are no agents.
voidregister_xjal(Agent a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidregister_xjal(AgentList<?> population)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidsetNetworkRandom(double connectionsPerAgent)
Sets network type to random with a given average number of connections per agent.
voidsetNetworkRingLattice(int connectionsPerAgent)
Sets network type to ring lattice.
voidsetNetworkScaleFree(int m)
Sets the network type to "scale free".
voidsetNetworkSmallWorld(int connectionsPerAgent, double neighborLinkProbability)
Sets network type to "small world".
voidsetNetworkType_xjal(NetworkType networkType)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidsetNetworkUserDefined()
Sets network type to user-defined.
intsize()
Returns the number of agents registered with this environment.
StringtoStringNetwork_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
StringtoStringSpace_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidunregister_xjal(Agent a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

Methods inherited from interface com.anylogic.engine.AgentExtension

getAgent, next_xjal, onDestroy, onExtensionRemoved, priority, setNext_xjal, supportsInterface_xjal

Method Details

agents

Collection<Agent> agents()
Returns the collection of all agents registered with this environment. You may iterate over that collection.

size

int size()
Returns the number of agents registered with this environment.
Returns:
the number of agents registered with this environment

randomAgentInside

default Agent randomAgentInside()
Returns a randomly chosen agent in the environment or null if there are no agents
Returns:
a randomly chosen agent in the environment, or null

randomAgentInside

Agent randomAgentInside(Random r)
Returns a randomly chosen agent in the environment or null if there are no agents. This function uses the specified random number generator.
Parameters:
r - the random number generator.
Returns:
a randomly chosen agent in the environment, or null
Since:
8.0

randomAgentExcept

@AnyLogicInternalAPI
default Agent randomAgentExcept(Agent agent)
Returns a randomly chosen agent in the environment except the given agent or null if there are no such agents
Parameters:
agent - this agent will not be returned
Returns:
a randomly chosen agent in the environment, or null

randomAgentExcept

@AnyLogicInternalAPI
Agent randomAgentExcept(Random r,
 Agent agent)
Returns a randomly chosen agent in the environment except the given agent or null if there are no such agents. This function uses the specified random number generator.
Parameters:
r - the random number generator.
agent - this agent will not be returned
Returns:
a randomly chosen agent in the environment, or null
Since:
8.0

deliverToAllAgentsInside

void deliverToAllAgentsInside(Object msg)
Immediately delivers a message to all agents in the environment.
Parameters:
msg - the message

deliverToRandomAgentInside

void deliverToRandomAgentInside(Object msg)
Immediately delivers a message to a random agent in the environment, if there are any agents.
Parameters:
msg - the message

applyNetwork

default void applyNetwork()
Discards all existing connections and establishes new connection network according to the current network settings.

applyNetwork

void applyNetwork(Random r)
Discards all existing connections and establishes new connection network according to the current network settings, using the specified random number generator, if required by network type.
Parameters:
r - the random number generator.
Since:
8.0

disableSteps

void disableSteps()
Disables time steps.

enableSteps

void enableSteps(double stepDuration)
Enables discrete time steps with a given duration.
Parameters:
stepDuration - the duration of a step, normally 1

areStepsEnabled

boolean areStepsEnabled()
Tests if the time steps are enabled.
Returns:
true if the time steps are enabled, false otherwise

setNetworkUserDefined

void setNetworkUserDefined()
Sets network type to user-defined. As a result, a subsequent call of applyNetwork() will do nothing. This is also a default network type.

setNetworkRandom

void setNetworkRandom(double connectionsPerAgent)
Sets network type to random with a given average number of connections per agent. Call applyNetwork() to actually create network connections.
Parameters:
connectionsPerAgent - average number of connections per agent

setNetworkRingLattice

void setNetworkRingLattice(int connectionsPerAgent)
Sets network type to ring lattice. All agents are considered to be in a ring in their natural order and each agent is connected to a given number of closest neighbours. Call applyNetwork() to actually create network connections.
Parameters:
connectionsPerAgent - number of connections per agent (even)

setNetworkSmallWorld

void setNetworkSmallWorld(int connectionsPerAgent,
 double neighborLinkProbability)
Sets network type to "small world". Small world network can be obtained from a ring lattice by rewiring some links to long-distant links. Call applyNetwork() to actually create network connections.
Parameters:
connectionsPerAgent - number of connections per agent (even)
neighborLinkProbability - probability of connection to link neighbors

setNetworkScaleFree

void setNetworkScaleFree(int m)
Sets the network type to "scale free". Scale free network is constructed according to Barabasi, A. L. and R. Albert. 1999. Emergence of scaling in random networks. Science 286(5439): 509-512. Call applyNetwork() to actually create network connections.
Parameters:
m - parameter of the scale free network (start number of hubs?)

getNetworkType

NetworkType getNetworkType()
Returns the network type. Note that this type has not necessarily been applied.
Returns:
the network type

getNetworkConnectionsPerAgent

double getNetworkConnectionsPerAgent()
Returns the average (or exact) number of connections per agent. Applies to random, ring lattice and small world networks.
Returns:
the average (or exact) number of connections per agent

getNetworkNeighborLinkProbability

double getNetworkNeighborLinkProbability()
Returns the probability of an agent connection to be a neighbor. Applies to "small world" network.
Returns:
the probability of an agent connection to be a neighbor

getNetworkScaleFreeM

int getNetworkScaleFreeM()
Returns the M parameter of a scale free network. Applies to "scale free" network.
Returns:
the M parameter of a scale free network

register_xjal

@AnyLogicInternalAPI
void register_xjal(AgentList<?> population)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. Please use Agent.setEnvironment(Agent) instead.
Registers an agent population with this environment.
Parameters:
population - the agent population

register_xjal

@AnyLogicInternalAPI
void register_xjal(Agent a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. Please use Agent.setEnvironment(Agent) instead.
Registers an agent with this environment and places it at a random location regardless the layout type. No connections are created at this time.
Parameters:
a - the agent

unregister_xjal

@AnyLogicInternalAPI
void unregister_xjal(Agent a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. Please use Agent.setEnvironment(Agent) instead.
Unregisters an agent with this environment.
Parameters:
a - the agent

toStringNetwork_xjal

@AnyLogicInternalAPI
String toStringNetwork_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

getSpaceType

SpaceType getSpaceType()
Returns the space type of this environment, one of SPACE_CONTINUOUS, SPACE_DISCRETE, SPACE_GIS, SPACE_NONE
Returns:
one of SPACE_CONTINUOUS, SPACE_DISCRETE, SPACE_GIS, SPACE_NONE

toStringSpace_xjal

@AnyLogicInternalAPI
String toStringSpace_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

setNetworkType_xjal

@AnyLogicInternalAPI
void setNetworkType_xjal(NetworkType networkType)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. Please use one of setNetwork*() methods instead.
Parameters:
networkType -