AnyLogic
Expand
Font size
All Superinterfaces:
AgentExtension, Serializable
All Known Subinterfaces:
ExtAgentContinuous, ExtAgentDiscrete, ExtAgentGIS
All Known Implementing Classes:
ExtAgentContinuousDelegate, ExtEntityContinuousDelegate

public interface ExtAgentInteractive
extends AgentExtension
An extension of Agent designed to support agent communication, in particular:
- time (continuous or discrete)
- connections between agents, networks (e.g. social) and their visualisation
- communication - message passing and broadcasting
Also, there are several extension classes for different space types.
Author:
AnyLogic North America, LLC https://anylogic.com

Field Summary

Method Summary

Modifier and TypeMethodDescription
voidaddConnection_xjal(Agent a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future
StringagentInfo() 
booleanconnectTo(Agent a)
Creates a bi-directional connection between this agent and a given other agent.
voidcopyToAndDestroyOnSpaceTypeChange_xjal(ExtAgentInteractive newExt) 
voiddeliver(Object msg, Agent dest)
Delivers a message to a given agent immediately during this method call.
voiddeliver(Object msg, MessageDeliveryType mode)
Delivers a message to an agent or a group of agents, as specified by the mode parameter immediately during this method call.
booleandisconnectFrom(Agent a)
Disconnects this agent from another given agent.
voiddisconnectFromAll()
Disconnects the agent from all other agents.
AgentgetConnectedAgent(int index)
Returns the connected agent with a given index.
<T extends Agent>
List<T>
getConnections()
Returns a collection of agents connected to this agent (bi-directionally), or empty collection if there have not been any connections yet.
intgetConnectionsNumber()
Returns the number of agents connected to this agent.
AgentgetEnvironment()
Returns the environment where this agent belongs to.
AgentgetRandomConnectedAgent()
Returns the randomly chosen connected agent.
SpaceTypegetSpaceType()
Returns the type of space this agent lives in, one of SPACE_CONTINUOUS, SPACE_DISCRETE, SPACE_GIS, SPACE_NONE
booleanisConnectedTo(Agent a)
Tests if this agent is connected to a given other agent.
voidreceive(Object msg)
Immediately delivers a message to this agent.
voidremoveConnection_xjal(Agent a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future
voidrestoreConnections_xjal(List<?> connections)
Deprecated.
voidsend(Object msg, Agent dest)
Sends a message to a given agent.
voidsend(Object msg, MessageDeliveryType mode)
Sends a message to an agent or a group of agents, as specified by the mode parameter.
voidsetEnvironment_xjal(Agent environment)
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

getEnvironment

Agent getEnvironment()
Returns the environment where this agent belongs to.
Returns:
the environment where this agent belongs to

getConnections

<T extends Agent> List<T> getConnections()
Returns a collection of agents connected to this agent (bi-directionally), or empty collection if there have not been any connections yet. You should not modify this collection.
Returns:
collection of connected agents, may be empty

getConnectionsNumber

int getConnectionsNumber()
Returns the number of agents connected to this agent.
Returns:
the number of agents connected to this agent

getConnectedAgent

Agent getConnectedAgent(int index)
Returns the connected agent with a given index.
Parameters:
index - the index of connection
Returns:
the connected agent with a given index

getRandomConnectedAgent

Agent getRandomConnectedAgent()
Returns the randomly chosen connected agent.
Returns:
the connected agent

isConnectedTo

boolean isConnectedTo(Agent a)
Tests if this agent is connected to a given other agent.
Parameters:
a - another agent
Returns:
true if the agents are connected, false otherwise

connectTo

boolean connectTo(Agent a)
Creates a bi-directional connection between this agent and a given other agent. Raises error if you try to connect to itself. Does nothing and returns false if agents are already connected.
Parameters:
a - another agent
Returns:
true if was not connected before, false if was already connected

disconnectFrom

boolean disconnectFrom(Agent a)
Disconnects this agent from another given agent.
Parameters:
a - another agent
Returns:
true if the agents were connected, false otherwise

disconnectFromAll

void disconnectFromAll()
Disconnects the agent from all other agents.

send

void send(Object msg,
 Agent dest)
Sends a message to a given agent. The message will be delivered during a separate event scheduled to occur in zero time after the current one. If you are OK with the message delivered immediately during this event, use deliver() method, which has better performance.
Parameters:
msg - a message
dest - the destination agent

send

void send(Object msg,
 MessageDeliveryType mode)
Sends a message to an agent or a group of agents, as specified by the mode parameter. The message will be delivered during a separate event scheduled to occur in zero time after the current one. If you are OK with the message delivered immediately during this event, use deliver() method, which has better performance.
Parameters:
msg - a message
mode - specifies the message sending mode (ALL, RANDOM, ...)

deliver

void deliver(Object msg,
 Agent dest)
Delivers a message to a given agent immediately during this method call. If you wish this to happen in a separate event, use send() method.
Parameters:
msg - a message
dest - the destination agent

deliver

void deliver(Object msg,
 MessageDeliveryType mode)
Delivers a message to an agent or a group of agents, as specified by the mode parameter immediately during this method call. If you wish this to happen in a separate event, use send() method.
Parameters:
msg - the message
mode - specifies the message sending mode (ALL, RANDOM, ...)

receive

void receive(Object msg)
Immediately delivers a message to this agent. Sender is set to null.
Parameters:
msg - the message

agentInfo

String agentInfo()

getSpaceType

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

setEnvironment_xjal

@AnyLogicInternalAPI
void setEnvironment_xjal(Agent environment)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future
Parameters:
environment -

addConnection_xjal

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

removeConnection_xjal

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

restoreConnections_xjal

@AnyLogicInternalAPI
@Deprecated
void restoreConnections_xjal(List<?> connections)
Deprecated.
This method is internal and shouldn't be called by user.
it may be removed/renamed in future

copyToAndDestroyOnSpaceTypeChange_xjal

@AnyLogicInternalAPI
void copyToAndDestroyOnSpaceTypeChange_xjal(ExtAgentInteractive newExt)