AnyLogic AnyLogic
Expand
Font size
All Superinterfaces:
AgentExtension, java.io.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

Fields inherited from interface com.anylogic.engine.AgentExtension

P_AGENT_INTERACTIVE_DELEGATE, P_AGENT_WITH_SPATIAL_METRICS_DELEGATE, P_AGENT_WITH_SPECIFIC_SPACE, P_AGENT_WITH_SPECIFIC_SPACE_DELEGATE, P_ENTITY_DELEGATE, P_ENV_WITH_SPECIFIC_SPACE, P_ROOT, P_SPACE, P_USER_EXT

Method Summary

All Methods Instance Methods Abstract Methods Default Methods 
java.util.Collection<Agent> agents()
Returns the collection of all agents registered with this environment.
default void applyNetwork()
Discards all existing connections and establishes new connection network according to the current network settings.
void applyNetwork​(java.util.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.
boolean areStepsEnabled()
Tests if the time steps are enabled.
void deliverToAllAgentsInside​(java.lang.Object msg)
Immediately delivers a message to all agents in the environment.
void deliverToRandomAgentInside​(java.lang.Object msg)
Immediately delivers a message to a random agent in the environment, if there are any agents.
void disableSteps()
Disables time steps.
void enableSteps​(double stepDuration)
Enables discrete time steps with a given duration.
double getNetworkConnectionsPerAgent()
Returns the average (or exact) number of connections per agent.
double getNetworkNeighborLinkProbability()
Returns the probability of an agent connection to be a neighbor.
int getNetworkScaleFreeM()
Returns the M parameter of a scale free network.
NetworkType getNetworkType()
Returns the network type.
SpaceType getSpaceType()
Returns the space type of this environment, one of SPACE_CONTINUOUS, SPACE_DISCRETE, SPACE_GIS, SPACE_NONE
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
Agent randomAgentExcept​(java.util.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 Agent randomAgentInside()
Returns a randomly chosen agent in the environment or null if there are no agents
Agent randomAgentInside​(java.util.Random r)
Returns a randomly chosen agent in the environment or null if there are no agents.
void register_xjal​(Agent a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void register_xjal​(AgentList<?> population)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void setNetworkRandom​(double connectionsPerAgent)
Sets network type to random with a given average number of connections per agent.
void setNetworkRingLattice​(int connectionsPerAgent)
Sets network type to ring lattice.
void setNetworkScaleFree​(int m)
Sets the network type to "scale free".
void setNetworkSmallWorld​(int connectionsPerAgent, double neighborLinkProbability)
Sets network type to "small world".
void setNetworkType_xjal​(NetworkType networkType)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void setNetworkUserDefined()
Sets network type to user-defined.
int size()
Returns the number of agents registered with this environment.
java.lang.String toStringNetwork_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
java.lang.String toStringSpace_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void unregister_xjal​(Agent a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Modifier and Type Method Description

Methods inherited from interface com.anylogic.engine.AgentExtension

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

Method Detail

agents

java.util.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​(java.util.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​(java.util.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​(java.lang.Object msg)
Immediately delivers a message to all agents in the environment.
Parameters:
msg - the message

deliverToRandomAgentInside

void deliverToRandomAgentInside​(java.lang.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​(java.util.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
java.lang.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
java.lang.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 -
How can we improve this article?