AnyLogic
Expand
Font size

Class Agent

All Implemented Interfaces:
AgentConstants, EnvironmentConstants, com.anylogic.engine.internal.Child, Serializable
Direct Known Subclasses:
FlowchartBlock

public class Agent
extends Utilities
implements com.anylogic.engine.internal.Child
This is a base class for all agent classes created by the user. Agent is the main building block of AnyLogic models; it can have parameters, variables, ports, events, statecharts and embedded agents and/or agent populations. Agent is the unit of dynamic creation of destruction.
Agent may dynamically obtain extensions (which will increase memory footprint of agent), see ext(Class)
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Field Summary

Modifier and TypeFieldDescription
static final Object_ARRIVAL_message_xjal
This variable shouldn't be accessed by user: it is used internally by AnyLogic and may be renamed/removed in future

Fields inherited from interface com.anylogic.engine.AgentConstants

AGENT_ORIENTATION_FRONT, AGENT_ORIENTATION_LEFT, AGENT_ORIENTATION_REAR, AGENT_ORIENTATION_RIGHT, ALL, ALL_CONNECTED, ALL_NEIGHBORS, AREA_ACCESS_RESTRICTION_BY_CAPACITY, AREA_ACCESS_RESTRICTION_BY_CONDITION, AREA_ACCESS_RESTRICTION_BY_SCHEDULE, AREA_ACCESS_RESTRICTION_BY_THROUGHPUT, AREA_ACCESS_RESTRICTION_MANUAL, CENTIMETER, CONVEYOR_BACKWARD, CONVEYOR_CUSTOM_STATION_AGENT_LOCATION_CENTER, CONVEYOR_CUSTOM_STATION_AGENT_LOCATION_NEAR_CONVEYOR, CONVEYOR_CUSTOM_STATION_AGENT_LOCATION_RANDOM, CONVEYOR_FORWARD, CONVEYOR_SIMPLE_STATION_DELAY_TYPE_MANUAL, CONVEYOR_SIMPLE_STATION_DELAY_TYPE_TIMEOUT, CONVEYOR_TYPE_BELT, CONVEYOR_TYPE_CELL, CONVEYOR_TYPE_ROLLER, CUBIC_METER, CUBIC_METER_PER_SECOND, CUSTOM_COLOR_SCHEME, DAY, DEG_PER_SECOND, DEGREE, DENSITY_VALUE_MAX, DENSITY_VALUE_MEAN, EAST, ELEVATOR_DIRECTION_DOWN, ELEVATOR_DIRECTION_NONE, ELEVATOR_DIRECTION_UP, ELEVATOR_DOOR_FRONT, ELEVATOR_DOOR_REAR, ELEVATOR_DOORS_FRONT, ELEVATOR_DOORS_FRONT_REAR, ELEVATOR_DOORS_FRONT_REAR_XJAL, ELEVATOR_DOORS_FRONT_XJAL, ELEVATOR_MOVEMENT_BY_SPEED, ELEVATOR_MOVEMENT_BY_TIME_PER_LEVEL, ELEVATOR_STATE_FAILED, ELEVATOR_STATE_IDLE, ELEVATOR_STATE_LOADING, ELEVATOR_STATE_MOVING, ESCALATOR_STAY_ALL, ESCALATOR_WALK_ALL, ESCALATOR_WALK_ON_LEFT_SIDE, ESCALATOR_WALK_ON_RIGHT_SIDE, EVENT_TIMEOUT_MODE_CYCLIC, EVENT_TIMEOUT_MODE_ONCE, EVENT_TIMEOUT_MODE_USER, EXCEEDED_QUEUE_CROWD_ROUND_AT_THE_END, EXCEEDED_QUEUE_EXTEND_TO_THE_FREE_SPACE, EXT_AGENT_CONTINUOUS, EXT_AGENT_DISCRETE, EXT_AGENT_GIS, EXT_AGENT_INTERACTIVE, EXT_AGENT_NETWORK, EXT_ENTITY, EXT_ENVIRONMENT_CONTINUOUS, EXT_ENVIRONMENT_DISCRETE, EXT_ENVIRONMENT_GIS, EXT_ENVIRONMENT_INTERACTIVE, EXT_SPACE, FLOW_STATISTICS_BOTH, FLOW_STATISTICS_LEFT, FLOW_STATISTICS_RIGHT, FOOT, FPM, FPS, FPS_SQ, HOUR, INCH, JIB_CRANE_CAT_HEAD, JIB_CRANE_FLAT_TOP, JIB_CRANE_INDUSTRIAL, JIB_CRANE_MOVEMENT_CONCURRENT, JIB_CRANE_MOVEMENT_STEP_BY_STEP, KILOGRAM, KILOGRAM_PER_SECOND, KILOMETER, KN, KPH, LIFT_PLATFORM_FLAT, LIFT_PLATFORM_ROLLER, LIFT_SELECTION_MODE_COMPARISON, LIFT_SELECTION_MODE_FIFO, LIFT_SELECTION_MODE_PRIORITY, LINEAR_COLOR_SCHEME, LITER, LITER_PER_SECOND, LOGARITHMIC_COLOR_SCHEME, METER, MILE, MILLIMETER, MILLISECOND, MINUTE, MONTH, MPH, MPS, MPS_SQ, NAUTICAL_MILE, NORTH, NORTHEAST, NORTHWEST, OBJECT_3D_INTERNAL_LIGHTING_GLOBAL, OBJECT_3D_INTERNAL_LIGHTING_INSIDE, OBJECT_3D_INTERNAL_LIGHTING_OFF, OBJECT_3D_XYZ_AXIS_ORDER, OBJECT_3D_YZX_AXIS_ORDER, OBJECT_3D_ZXY_AXIS_ORDER, OIL_BARREL, OIL_BARREL_PER_SECOND, OVERHEAD_CRANE_BRIDGE, OVERHEAD_CRANE_GANTRY, OVERHEAD_CRANE_GIRDER_DOUBLE_TIE, OVERHEAD_CRANE_GIRDER_SINGLE_FLAT, OVERHEAD_CRANE_MOVEMENT_CONCURRENT, OVERHEAD_CRANE_MOVEMENT_INDEPENDENT_HOIST, OVERHEAD_CRANE_MOVEMENT_STEP_BY_STEP, PALLET_RACK_LEFT_TO_RIGHT, PALLET_RACK_NO_DIRECTION, PALLET_RACK_RIGHT_TO_LEFT, PALLET_RACK_SINGLE_AISLE_LEFT, PALLET_RACK_SINGLE_AISLE_RIGHT, PALLET_RACK_TWO_AISLES, PALLET_RACK_TWO_PALLET_RACKS, PARKING_LOT_PARALLEL, PARKING_LOT_PERPENDICULAR, PATH_CONVEYOR, PATH_DASHEDLINE, PATH_LINE, PATH_RAILROAD, PATH_ROAD, PEDESTRIAN_MAP_TYPE, PER_DAY, PER_HOUR, PER_MILLISECOND, PER_MINUTE, PER_MONTH, PER_SECOND, PER_WEEK, PER_YEAR, POSITION_CHOICE_ARRANGED, POSITION_CHOICE_BY_ATTRACTORS, POSITION_CHOICE_RANDOM, RACK_PLACEMENT_BACK_TO_BACK, RACK_PLACEMENT_STAND_ALONE, RACK_TYPE_DRIVE_IN, RACK_TYPE_FIFO_FLOW, RACK_TYPE_LIFO_FLOW, RACK_TYPE_SELECTIVE, RAD_PER_SECOND, RADIAN, RAILWAY_SWITCH_ALL_TO_ALL, RAILWAY_SWITCH_DOUBLE_SLIP, RAILWAY_SWITCH_SINGLE_SLIP, RANDOM, RANDOM_CONNECTED, RANDOM_NEIGHBOR, ROAD_LEFT_HAND, ROAD_LINE_DOUBLE, ROAD_LINE_DOUBLE_DASHED, ROAD_LINE_SINGLE, ROAD_LINE_SINGLE_DASHED, ROAD_RIGHT_HAND, RPM, SECOND, SERVICE_GROUP_BEHAVIOR_DEPENDS_ON_INCOMING_GROUP, SERVICE_GROUP_BEHAVIOR_SAME_FOR_ALL_GROUPS, SERVICE_GROUP_INDIVIDUAL_SERVING, SERVICE_GROUP_ONE_MEMBER_IS_SERVED_OTHERS_WAIT_IN_AREA, SERVICE_GROUP_ONE_MEMBER_IS_SERVED_OTHERS_WAIT_IN_QUEUE, SERVICE_QUEUE_CLOSEST_NON_EMPTY, SERVICE_QUEUE_CLOSEST_STRICT, SERVICE_QUEUE_CUSTOM, SERVICE_QUEUE_LONGEST, SERVICE_QUEUE_NEXT_ROUND_ROBIN, SERVICE_QUEUE_PRIORITY, SERVICE_TYPE_LINEAR, SERVICE_TYPE_POINT, SIGNAL_GREEN, SIGNAL_NONE, SIGNAL_RED, SIGNAL_YELLOW, SIMPLE_STATION_LOADING_MODE_AFTER_UNLOADING, SIMPLE_STATION_LOADING_MODE_SIMULTANEOUS_WITH_UNLOADING, SIMPLE_STATION_PROCESSING_WHEN_AGENT_ENTERS, SIMPLE_STATION_PROCESSING_WHEN_CAPACITY_FULL, SOUTH, SOUTHEAST, SOUTHWEST, SPACE_CONTINUOUS, SPACE_CONTINUOUS_2D, SPACE_DISCRETE, SPACE_DISCRETE_2D, SPACE_GIS, SPACE_UNDEFINED, SQ_CENTIMETER, SQ_FOOT, SQ_INCH, SQ_KILOMETER, SQ_METER, SQ_MILE, SQ_MILLIMETER, SQ_NAUTICAL_MILE, SQ_YARD, TON, TON_PER_SECOND, TRANSFER_MODE_AUTOMATIC, TRANSFER_MODE_MANUAL, TRANSPORTER_MAP_TYPE, TURN, TURN_STATION_MODE_ANGLE, TURN_STATION_MODE_ORIENTATION, WALL_FILL_HATCHING, WALL_FILL_NONE, WALL_FILL_SOLID, WEEK, WEST, WINDOW_3D_NAVIGATION_FULL, WINDOW_3D_NAVIGATION_LIMITED_TO_Z_ABOVE_ZERO, WINDOW_3D_NAVIGATION_NONE, WINDOW_3D_NAVIGATION_ROTATION_ONLY, YARD, YEAR

Constructor Summary

ConstructorDescription
Agent()
Create constructor.
This is a way for e.g.
Agent(Engine engine, Agent owner, AgentList<?> ownerPopulation)
Constructs the agent, sets up its owner and list (if replicated).

Method Summary

Modifier and TypeMethodDescription
static Engine_initGetEngine_xjal(Agent owner)
This method shouldn't be called by user. It is public due to technical reasons.
voidaddAgentToContents(Agent agent)
Adds a given agent to the contents of this agent.
voidaddEntityToContents(Agent agent)
Deprecated.
voidaddExt_xjal(AgentExtension ext)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future
StringagentInfo() 
Collection<Agent>agents()
Returns the collection of all agents registered with this environment.
List<? extends Agent>agentsInRange(double distance)
Returns the unsorted list of agents (from the population this agent lives in), which are within the given distance from this agent
List<? extends Agent>agentsInRange(double distanceInUnits, LengthUnits units)
Returns the unsorted list of agents (from the population this agent lives in), which are within the given distance from this agent
final <T extends Agent>
List<T>
agentsInRange(Iterable<T> agents, double distance)
Returns the unsorted list of agents from the given collection which are within the given distance from this agent
final <T extends Agent>
List<T>
agentsInRange(Iterable<T> agents, double distanceInUnits, LengthUnits units)
Returns the unsorted list of agents from the given collection which are within the given distance from this agent
voidapplyLayout()
Rearranges agents in this environment according to the selected layout type.
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.
voidassignInitialConditions_xjal()
This method shouldn't be normally called by user.
This function assigns initial conditions for stocks and for flow aux variables
booleanconnectTo(Agent a)
Creates a bi-directional connection between this agent and a given other agent.
<T extends Agent>
List<T>
contents() 
final voidcreate()
Creates the agent embedded objects; also calls user's onBeforeCreate() at the beginning and onCreate() at the end.
voidcreateAndStart(Agent anyAgent)
Assigns the owner of the agent to the top-level agent of the model, creates the internal structure of the agent (internally embedded agents, statecharts etc.) and starts it (thus its statechart and events start living).
final voidcreateAsEmbedded()
Internal method to be called for embedded agents inside doCreate() of an upper-level agent.
FlowchartBlockcurrentBlock()
Returns the current flowchart block this agent is being processed in.
voiddeleteSelf()
Removes this agent from the agent population (replicated agent list) it belongs to.
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.
voiddeliverToAllAgentsInside(Object msg)
Immediately delivers a message to all agents in the environment.
voiddeliverToAllConnected(Object msg)
Delivers a message to all connected agents.
voiddeliverToAllNeighbors(Object msg)
Delivers a message to all neighbors.
voiddeliverToRandomAgentInside(Object msg)
Immediately delivers a message to a random agent in the environment, if there are any agents.
voiddeliverToRandomConnected(Object msg)
Delivers a message to a randomly chosen connected agent.
voiddeliverToRandomNeighbor(Object msg)
Delivers a message to a randomly chosen neighbor.
voiddisableSteps()
Disables time steps.
booleandisconnectFrom(Agent a)
Disconnects this agent from another given agent.
voiddisconnectFromAll()
Disconnects the agent from all other agents.
doubledistanceByRoute(Agent other)
Calculates the distance from this agent to another one by route.
Only for agents in GIS environment.
doubledistanceTo(double x, double y)
Calculates the distance from this agent to a given point in continuous 3D or GIS space.
doubledistanceTo(double x, double y, double z)
Calculates the distance from this agent to a given point in continuous space.
doubledistanceTo(double x, double y, double z, LengthUnits units)
Calculates the distance from this agent to a given point in continuous space.
doubledistanceTo(double x, double y, LengthUnits units)
Calculates the distance from this agent to a given point in continuous 3D or GIS space.
doubledistanceTo(Agent other)
Calculates the distance from this agent to another one in continuous 3D space or GIS space.
In case of GIS environment returns distance measured in meters
doubledistanceTo(Agent other, LengthUnits units)
Calculates the distance from this agent to another one in continuous 3D space or GIS space.
In case of GIS environment returns distance measured in meters
doubledistanceTo(Point p)
Calculates the distance from this agent to a given point.
doubledistanceTo(Point p, LengthUnits units)
Calculates the distance from this agent to a given point.
voiddoAfterCreate()
Internal callback to perform additional "after all agents created" actions.
voiddoCreate()
Creates the agent embedded objects.
If there are any embedded objects, this method should be implemented in subclass to instantiate them, setup their parameters and call agent.createAsEmbedded() method on each agent.
voiddoFinish()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
voiddoStart()
Starts activities (e.g.
voiddrawLinksToAgents(boolean underAgents, LinkToAgentAnimator animator)
This method automatically generated by AnyLogic.
voidenableSteps(double stepDuration)
Enables discrete time steps with a given duration.
RuntimeExceptionerror(Throwable cause, String errorText)
Signals an error during the model run by throwing a RuntimeException with errorText preceded by the agent full name.
RuntimeExceptionerrorInModel(Throwable cause, String errorText)
Signals an model logic error during the model run by throwing a ModelException with errorText preceded by the agent full name.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments.
doubleevaluateRateOf(EventRate e)
Evaluates the rate expression of a rate event.
Must be implemented in a subclass if there are any rate events.
doubleevaluateRateOf(TransitionRate t)
Evaluates the rate expression of a rate transition.
Must be implemented in a subclass if there are any rate transitions.
doubleevaluateTimeoutOf(EventTimeout e)
Evaluates timeout expression of a timeout event.
Must be implemented in a subclass if there are any timeout events.
doubleevaluateTimeoutOf(TransitionTimeout t)
Evaluates timeout expression of a timeout transition.
Must be implemented in a subclass if there are any timeout transitions.
voidexecuteActionOf(EventCondition e)
Executes action of a condition event.
Implementation in a subclass can be skipped if the action(s) are empty.
voidexecuteActionOf(EventRate e)
Executes action of a rate event.
Implementation in a subclass can be skipped if the action(s) are empty.
voidexecuteActionOf(EventTimeout e)
Executes action of a timeout event.
Implementation in a subclass can be skipped if the action(s) are empty.
voidexecuteActionOf(Statechart<?> s)
Executes startup action of a statechart: calls actions of the statechart entry point, entry action of initial states, starts the corresponding transitions, etc., and sets up the initially active simple state.
Must be implemented in a subclass if there are any statecharts.
voidexecuteActionOf(TransitionCondition t)
Executes action of a condition transition.
Implementation in a subclass can be skipped if the action(s) are empty.
voidexecuteActionOf(TransitionMessage t, int msg)
Executes action of a message transition for int message type - depends on the message.
Implementation in a subclass can be skipped if the action(s) are empty.
voidexecuteActionOf(TransitionMessage t, Object msg)
Executes action of a message transition for Object message type - depends on the message.
Implementation in a subclass can be skipped if the action(s) are empty.
voidexecuteActionOf(TransitionRate t)
Executes action of a rate transition.
Implementation in a subclass can be skipped if the action(s) are empty.
voidexecuteActionOf(TransitionTimeout t)
Executes action of a timeout transition.
Implementation in a subclass can be skipped if the action(s) are empty.
booleanexecuteOnReceiveActionOf(Port<?,?> p, Object msg)
Executes action code associated with a message being received at a port.
booleanexecuteOnSendActionOf(Port<?,?> p, Object msg)
Executes action associated with a message being sent via a port.
final <T extends AgentExtension>
T
ext(Class<T> c)
Returns an extension of given type.
booleanfinishSimulation()
Engine command applicable only in RUNNING or PAUSED state (in other states does nothing and returns false).
voidformulasExecute_xjal()
This method shouldn't be normally called by user.
Executes formulas defined in this agent.
AgentgetAgentAtCell(int r, int c)
Returns the agent located in the cell with a given row and column, or null.
AgentgetAgentNextToMe(CellDirection dir)
Returns the agent next to this agent in a given direction, if any.
SpaceTypegetAgentSpaceType()
Returns agent space type, if this is an agent and it has spatial information.
intgetAgentTypeId()
Returns the unique identifier of agent's type
AgentAnimationSettingsgetAnimationSettingsOf(Agent ao)
Returns the animation settings of a simple (not replicated) embedded object.
Must be implemented in a subclass if there are any embedded objects.
AgentAnimationSettingsgetAnimationSettingsOf(AgentList<?> aocollection)
Returns the animation settings of a replicated embedded object.
Must be implemented in a subclass if there are any replicated embedded objects.
doublegetBlockEnterTime()
Returns the time this agent entered its current flowchart block.
intgetC()
Returns the column of the agent's cell.
intgetCameras3D(Map<String,Camera3D> output)
Adds all Camera3D of this agent to the given map output, if it is not null.
Default implementation does nothing and returns 0.
ColorgetColor()
Returns the color of the item's default animation shape.
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.
<T extends Enum<T> & IStatechartState<?, T>>
T
getContainerStateOf(T state)
Deprecated.
ConveyorNetwork[]getConveyorNetworks()
Returns array of conveyor networks located in this agent, or empty array
AgentList<Agent>getDefaultPopulation()
Returns the default population (contained in top-level agent) or null if root couldn't be found
intgetDifferentialFlatEquationsCount_xjal()
This method shouldn't be normally called by user.
Set<DynamicEvent>getDynamicEvents()
Returns the set of all currently existing dynamic events of this agent.
List<Object>getEmbeddedObjects()
Creates and returns a list of embedded objects if there are any, null if there are none.
EnginegetEngine()
Returns the simulation engine where this object belongs to.
AgentgetEnvironment()
Returns the environment where this agent belongs to.
SpaceTypegetEnvironmentSpaceType()
Returns agent space type, if this is an environment and it has spatial information.
IExperimentHostgetExperimentHost()
Returns the experiment host object of the model, or some dummy object with no functionality if there is none.
doublegetFirstOccurrenceTime(EventTimeout e)
Returns the (absolute) time of first occurrence of a timeout event (of Once or Cyclic mode).
doublegetFlowchartEntryTime()
Returns the time the entity has entered the first block in the flowchart, or Double.NaN if this agent hasn't yet visited any flowchart
final StringgetFullName()
Returns the name of the agent prefixed by the path from the top-level agent to this one.
doublegetGISHeading()
Returns current heading angle (measured in radians CW, starting from North direction) of agent moving in GIS space.
AbstractShapeGISMapgetGISMap()
Returns AbstractShapeGISMap object used in this GIS environment.
Throws error if environment has space type different from GIS.
doublegetHeight()
Returns the height of the agent (measured in meters) - used by conveyors and other blocks which require it during processing.
doublegetHeight(LengthUnits units)
Returns the height of the agent (measured in the given units) - used by conveyors and other blocks which require it during processing.
intgetId()
Returns the unique identifier of this agent in the context of the model run
intgetIdOf(Statechart<?> s)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
Returns some ordinal number of this statechart in the agent type (like id, among all statecharts, respecting agent type inheritance)
intgetIndex()
For a list-based agent population, returns its index in the list, otherwise returns -1.
intgetInitialAlgebraicFlatEquationsCount_xjal()
This method shouldn't be normally called by user.
intgetInitialFormulaFlatEquationsCount_xjal()
This method shouldn't be normally called by user.
SDIntegrationManagergetIntegrationManager_xjal()
This method shouldn't be normally called by user.
Returns static integration manager defined in derived classes.
doublegetLat()
Deprecated.
use getLatitude()
doublegetLatitude()
Returns the current (up-to-date) latitude of the agent in continuous GIS space.
LayoutTypegetLayoutType()
Returns the layout type.
doublegetLength()
Returns the length of the agent (measured in meters) - used by conveyors and other blocks which require it during processing.
doublegetLength(LengthUnits units)
Returns the length of the agent (measured in the given units) - used by conveyors and other blocks which require it during processing.
LevelgetLevel()
Returns the level this agent lives in, actual for agents in continuous space.
Level[]getLevels()
Returns array of levels located in this agent, or empty array
LinkToAgentCollection<? extends Agent,? extends Agent>getLinkToAgentStandard_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
doublegetLon()
Deprecated.
use getLongitude()
doublegetLongitude()
Returns the current (up-to-date) longitude of the agent in continuous GIS space.
EventTimeout.ModegetModeOf(EventTimeout e)
Returns mode of a timeout event: Cyclic, Once, User.
Must be implemented in a subclass if there are any timeout events.
final StringgetName()
Returns the name of this agent, i.e.
StringgetNameOf(Agent ao)
Returns the name of a simple (not replicated) embedded object.
Must be implemented in a subclass if there are any embedded objects.
StringgetNameOf(AgentList<?> aocollection)
Returns the name of a replicated embedded object.
Must be implemented in a subclass if there are any replicated embedded objects.
StringgetNameOf(EventCondition e)
Returns the name of a condition event.
Must be implemented in a subclass if there are any condition events.
StringgetNameOf(EventRate e)
Returns the name of a rate event.
Must be implemented in a subclass if there are any rate events.
StringgetNameOf(EventTimeout e)
Returns the name of a timeout event.
Must be implemented in a subclass if there are any timeout events.
StringgetNameOf(Port<?,?> p)
Returns the name of a port.
Must be implemented in a subclass if there are any ports.
StringgetNameOf(Statechart<?> s)
Returns the name of a statechart.
Must be implemented in a subclass if there are any statecharts.
StringgetNameOf(TransitionCondition t)
Returns the name of a condition transition.
Must be implemented in a subclass if there are any condition transitions.
StringgetNameOf(TransitionMessage t)
Returns the name of a message transition.
Must be implemented in a subclass if there are any message transitions.
StringgetNameOf(TransitionRate t)
Returns the name of a rate transition.
Must be implemented in a subclass if there are any rate transitions.
StringgetNameOf(TransitionTimeout t)
Returns the name of a timeout transition.
Must be implemented in a subclass if there are any timeout transitions.
StringgetNameOfState(IStatechartState<?,?> state)
Returns the name of a statechart state.
Must be implemented in a subclass if there are any states.
final <T extends Agent>
T
getNearestAgent(Iterable<T> agents)
Returns the nearest agent from the given collection
final <T extends Agent>
T
getNearestAgentByRoute(Iterable<T> agents)
Returns the nearest agent from the given collection.
Agent[]getNeighbors()
Returns the array of neighbor agents, subject to the current neighborhood type (Euclidean - {N,S,E,W}, Moore - also {..,NW,NW,SE,SW})
INetworkgetNetwork()
Returns the network this agent lives in, actual for agents in continuous space.
doublegetNetworkConnectionRange()
Returns the range of agent connections.
doublegetNetworkConnectionsPerAgent()
Returns the average (or exact) number of connections per agent.
doublegetNetworkNeighborLinkProbability()
Returns the probability of an agent connection to be a neighbour.
INodegetNetworkNode()
Returns the network node this agent currently is located in, actual for agents in continuous space.
INetwork[]getNetworks()
Returns array of networks located in this agent, or empty array
intgetNetworkScaleFreeM()
Returns the M parameter of a scale free network.
NetworkTypegetNetworkType()
Returns the network type.
AgentgetOwner()
Returns the owner agent that encapsulates this one, null if this is the top-level agent in the model.
ShapeEmbeddedObjectPresentationgetOwnerShape()
Returns the shape on owner's presentation, this object presentation belongs to.
May return null if this object's presentation isn't located anywhere or when it has no own presentation (e.g.
<T> TgetParameter(String name)
Returns the value of parameter with the given name.
This method should be overridden in subclasses.
Throws error if there is no parameter with the given name.
String[]getParameterNames()
Returns array of all not dynamic parameter names.
voidgetPhaseVector_xjal(double[] D, int idxD, double[] A, int idxA)
This method shouldn't be normally called by user.
Assigns given arrays with current variables values
voidgetPhaseVectorForInitialConditions_xjal(double[] A, int idxA)
This method shouldn't be normally called by user.
Assigns given arrays with current variables values (the function is used while solving initial conditions loops)
AgentList<?>getPopulation()
For agent population returns the List of agents embedded in the owner object where this agent belongs to, null if the object is not replicated
PositiongetPosition()
Returns the current (up-to-date) x, y (and z in case of 3D space) coordinate of the agent in continuous space and its orientation as well.
PositiongetPosition(Position out)
Returns the current (up-to-date) x, y (and z in case of 3D space) coordinate of the agent in continuous space and its orientation as well.
doublegetPresentationScaleOnOwnerSpace()
Returns the scale of the agent presentation animation on its space or 1.0 if space isn't defined
ShapeTopLevelPresentationGroupgetPresentationShape() 
intgetR()
Returns the row of the agent's cell.
RailwayNetwork[]getRailwayNetworks()
Returns array of railway networks located in this agent, or empty array
AgentgetRandomConnectedAgent()
Returns the randomly chosen connected agent.
AgentList<?>getReplicatedCollection()
Deprecated.
This method may be removed in the next release.
AgentList<?>getReplicatedList()
For agent population returns the List of agents embedded in the owner object where this agent belongs to, null if the object is not replicated
voidgetRightPart_xjal(double[] DR, int idxDR, double[] AR, int idxAR)
This method shouldn't be normally called by user.
Calculates right parts of differential equations and algebraic equations to the given arrays
voidgetRightPartForInitialConditions_xjal(double[] AR, int idxAR)
This method shouldn't be normally called by user.
Returns right part while solving algebraic loops in initial conditions
RoadNetwork[]getRoadNetworks()
Returns array of road networks located in this agent, or empty array
AgentgetRootAgent()
Returns the top-level agent or null if root couldn't be found
doublegetRotation()
Returns the current rotation angle (in radians) of the agent in continuous 3D space or GIS space.
IRouteProvidergetRouteProvider()
Returns the provider of routes for agent movement
intgetRuntimeAlgebraicFlatEquationsCount_xjal()
This method shouldn't be normally called by user.
intgetRuntimeFormulaFlatEquationsCount_xjal()
This method shouldn't be normally called by user.
ScalegetScale()
Returns the scale used by the space of this agent.
The default scale is 10 pixels per meter
AgentgetSpace()
Returns the agent representing space this agent lives in
doublegetSpeed()
Returns the current value of the agent speed in continuous/GIS space.
doublegetSpeed(SpeedUnits units)
Returns the current value of the agent speed in continuous/GIS space.
StatechartgetStatechartOf(TransitionCondition t)
Returns the statechart where the condition transition belongs to.
Must be implemented in a subclass if there are any condition transitions.
StatechartgetStatechartOf(TransitionMessage t)
Returns the statechart where the message transition belongs to.
Must be implemented in a subclass if there are any message transitions.
StatechartgetStatechartOf(TransitionRate t)
Returns the statechart where the rate transition belongs to.
Must be implemented in a subclass if there are any rate transitions.
StatechartgetStatechartOf(TransitionTimeout t)
Returns the statechart where the timeout transition belongs to.
Must be implemented in a subclass if there are any timeout transitions.
doublegetTargetLat()
Returns the latitude of the target location if moving, otherwise current latitude in GIS space, measured in degrees (-90 ...
doublegetTargetLon()
Returns the longitude of the target location if moving, otherwise current longitude in GIS space, measured in degrees (-180 ...
doublegetTargetX()
Returns the x of the target location if moving, otherwise current x in continuous 3D space or GIS space.
In case of GIS environment this is the latitude, measured in degrees (-90 ...
doublegetTargetY()
Returns the y of the target location if moving, otherwise current y in continuous 3D space or GIS space.
In case of GIS environment this is the longitude, measured in degrees (-180 ...
doublegetTargetZ()
Returns the z of the target location if moving, otherwise current z in continuous space.
doublegetVelocity()
Deprecated.
this function is deprecated since AnyLogic 7.1.
doublegetVerticalRotation()
Returns the current vertical rotation angle of the agent in 3D space.
doublegetWidth()
Returns the width of the agent (measured in meters) - used by conveyors and other blocks which require it during processing.
doublegetWidth(LengthUnits units)
Returns the width of the agent (measured in the given units) - used by conveyors and other blocks which require it during processing.
doublegetX()
Returns the current (up-to-date) x coordinate of the agent in continuous space.
PointgetXYZ()
Returns the current (up-to-date) x, y (and z in case of 3D space) coordinate of the agent in continuous space.
PointgetXYZ(Point out)
Returns the current (up-to-date) x, y (and z in case of 3D space) coordinate of the agent in continuous space.
doublegetY()
Returns the current (up-to-date) y coordinate of the agent in continuous space.
doublegetZ()
Returns the current (up-to-date) z coordinate of the agent in continuous space.
voidgoToPopulation(AgentList newPopulation)
Changes the population of agent.
voidhighlight(boolean yes)
Turns on/off highlighting of this agent animation.
voidinstantiateBaseStructure_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
booleaninState(IStatechartState<?,?> state)
Returns true if the corresponding statechart of this agent is at the specified state, i.e.
booleanisAgent()
Returns true if this is at least an informational agent (may be with or without spatial properties).
booleanisAutomaticHorizontalRotation()
Returns true if agent is set to be rotated during movement, false otherwise
booleanisAutomaticVerticalRotation()
Returns true if agent is set to be rotated (in vertical direction, along Z-axis) during movement in 3D, false otherwise.
The returned value has no effect if isAutomaticHorizontalRotation() is false
booleanisConnectedTo(Agent a)
Tests if this agent is connected to a given other agent.
booleanisEmbeddedAgentPresentationVisible(Agent embeddedAgent)
This method is internal and shouldn't be called by user.
This method works only for single embedded objects (not population) inside this agent.
Method may be removed/renamed in future. It is public due to technical reasons.
booleanisEnvironment()
Returns true if this is an environment for agents (at least informational environment).
booleanisLoggingToDB(LoggingType loggingType)
Returns true if this agent and its internals may log their data/changes/activity to AnyLogic built-in database (logging options are configurable in the properties of Database / Log in the Projects tree inside AnyLogic)
booleanisLoggingToDB(EventOriginator e)
Return true if the given event (or dynamic event) is logged to database (note that this may be overridden by logging settings of Agent).
Default implementation returns true.
booleanisMoving()
Tests if the agent is currently moving in continuous 3D space or GIS space.
booleanisNextCellInsideSpace(CellDirection dir)
Returns true if there is an adjacent cell in a given direction.
booleanisPublicPresentationDefined()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
booleanisReplicated()
Returns true if this object is embedded in its owner as replicated, i.e.
booleanisSpacePositionSet_xjal()
Deprecated.
voidjumpTo(double x, double y)
Instantly moves the agent to a given location in continuous 3D or GIS space.
voidjumpTo(double x, double y, double z)
Instantly moves the agent to a given location.
voidjumpTo(INode node)
Instantly moves the agent to a given network location.
voidjumpTo(INode node, Point location)
Instantly moves the agent to a given network location.
voidjumpTo(Point location)
Instantly moves the agent to a given location without.
voidjumpTo(String geographicPlace)
Finds first geographic point on the Earth and calls method jumpTo(latitude, longitude) with coordinates of the found point
voidjumpToCell(int r, int c)
Moves the agent into a cell with the given row and column.
booleanjumpToRandomEmptyCell()
Finds a random empty cell and places the agent there.
<T extends Enum<T> & IStatechartState<?, T>>
void
logToDB(Statechart<T> statechart, Transition transition, T fromState)
If logging enabled this method will be called in #exitState(short, Transition, boolean, Statechart) method
<T extends Enum<T> & IStatechartState<?, T>>
void
logToDBEnterState(Statechart<T> statechart, T state)
If logging enabled this method will be called in #exitState(short, Transition, boolean, Statechart) method
<T extends Enum<T> & IStatechartState<?, T>>
void
logToDBExitState(Statechart<T> statechart, T state)
If logging enabled this method will be called in #exitState(short, Transition, boolean, Statechart) method
voidmarkParametersAreSet()
This methods should be used to mark agents created using no-argument constructor as having all the parameters set.
voidmoveTo(double x, double y)
Starts movement in the direction of the given target location in continuous 3D or GIS space.
"On arrival" code is executed when movement is finished.
voidmoveTo(double x, double y, double z)
Starts movement in the direction of the given target location in continuous 3D.
"On arrival" code is executed when movement is finished.
voidmoveTo(double x, double y, double z, Path3D path)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveTo(double x, double y, Path2D path)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveTo(Agent agent)
Starts movement in the direction of the given agent.
"On arrival" code is executed when movement is finished.
voidmoveTo(Attractor attractor)
Starts movement to the given attractor.
"On arrival" code is executed when movement is finished.
voidmoveTo(INode node)
Starts movement to the given network node.
"On arrival" code is executed when movement is finished.
voidmoveTo(INode node, Point location)
Starts movement to the given network node.
"On arrival" code is executed when movement is finished.
voidmoveTo(Point location)
Starts movement in the direction of the given target location in continuous 3D.
"On arrival" code is executed when movement is finished.
voidmoveTo(Point location, Path3D path)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveTo(String geographicPlace)
Finds first geographic point on the Earth and calls method moveTo(latitude, longitude) with coordinates of the found point
voidmoveToInTime(double x, double y, double tripTime)
Starts movement in the direction of the given target location in continuous 3D or GIS space.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(double x, double y, double z, double tripTime)
Starts movement in the direction of the given target location in continuous 3D.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(double x, double y, double z, double tripTime, TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(double x, double y, double z, Path3D path, double tripTime)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveToInTime(double x, double y, double z, Path3D path, double tripTime, TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveToInTime(double x, double y, double tripTime, TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D or GIS space.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(double x, double y, Path2D path, double tripTime)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveToInTime(double x, double y, Path2D path, double tripTime, TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveToInTime(Agent agent, double tripTime)
Starts movement in the direction of the given agent.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(Agent agent, double tripTime, TimeUnits units)
Starts movement in the direction of the given agent.
Changes the speed of the agent in order to reach target in tripTime.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(Attractor attractor, double tripTime)
Starts movement to the given attractor.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(Attractor attractor, double tripTime, TimeUnits units)
Starts movement to the given attractor.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(INode node, double tripTime)
Starts movement to the given network node.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(INode node, double tripTime, TimeUnits units)
Starts movement to the given network node.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(INode node, Point location, double tripTime)
Starts movement to the given network node.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(INode node, Point location, double tripTime, TimeUnits units)
Starts movement to the given network node.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(Point location, double tripTime)
Starts movement in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(Point location, double tripTime, TimeUnits units)
Starts movement in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToInTime(Point location, Path3D path, double tripTime)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveToInTime(Point location, Path3D path, double tripTime, TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D space along a given path.
voidmoveToNearestAgent(Iterable<? extends Agent> agents)
Starts movement to the nearest agent from the given collection.
voidmoveToNearestAgent(Iterable<? extends Agent> agents, double tripTime)
Starts movement to the nearest agent from the given collection.
voidmoveToNextCell(CellDirection dir)
Moves the agent to an adjacent cell in a given direction.
voidmoveToStraight(double x, double y)
Starts straight movement (ignoring network/routes) in the direction of the given target location.
"On arrival" code is executed when movement is finished.
voidmoveToStraight(double x, double y, double z)
Starts straight movement (ignoring network) in the direction of the given target location.
"On arrival" code is executed when movement is finished.
voidmoveToStraight(Agent agent)
Starts straight movement (ignoring network/routes) in the direction of the given agent.
"On arrival" code is executed when movement is finished.
voidmoveToStraight(Point location)
Starts straight movement (ignoring network/routes) in the direction of the given target location.
"On arrival" code is executed when movement is finished.
voidmoveToStraightInTime(double x, double y, double z, double tripTime)
Starts straight movement (ignoring network) in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToStraightInTime(double x, double y, double z, double tripTime, TimeUnits units)
Starts straight movement (ignoring network) in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToStraightInTime(Point location, double tripTime)
Starts straight movement (ignoring network/routes) in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidmoveToStraightInTime(Point location, double tripTime, TimeUnits units)
Starts straight movement (ignoring network/routes) in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
voidnothingChanged()
If called during an event execution, prevents the engine from calling onChange() of the agent that originated the event.
voidonAfterStepEnvironment()
A callback that is called when at the end of every step after the agents have performed all their step actions.
voidonArrival()
A callback that is called when the agent arrives to the target location after movement initiated by moveTo() in continuous 2D space.
voidonBeforeCreate()
Is called at the very start of create() method, i.e.
voidonBeforeStep()
A callback that is called at the beginning of every step in discrete time before onStep() of any agent is called.
voidonBeforeStepEnvironment()
A callback that is called at the beginning of every step before the agents are asked to perform any their step actions.
voidonChange()
Notification to the agent meaning "some of your data may have changed during this event".
voidonCreate()
Is called at the very end of create() method, i.e.
voidonDestroy()
Must be called when the agent is dynamically disposed.
voidonEngineFinished()
Is called by the engine when it finishes running and is intended to wrap up a single simulation run (e.g.
voidonEnterFlowchartBlock(Agent oldBlock, Agent block)
A callback that is called when the agent enters flowchart block (being an 'entity')
voidonExitFlowchartBlock(Agent block)
A callback that is called when the agent exits flowchart block (being an 'entity')
voidonOwnerChanged_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
voidonReceive(Object msg, Agent sender)
A callback that is called when the agent receives a message from another agent.
voidonReleaseResource(Agent unit)
A callback that is called when the agent releases resource
voidonSeizeResource(Agent unit)
A callback that is called when the agent seizes resource
voidonStartup()
Is called after all activities are started in the object (initial events are scheduled) and onStartup() has been called for the embedded objects, but before any steps are made.
voidonStep()
A callback that is called at every step in discrete time after onStep() of any agent is called.
booleanpauseSimulation()
Engine command applicable only in RUNNING state (in other states does nothing and returns false).
voidputPhaseVector_xjal(double[] D, int idxD, double[] A, int idxA)
This method shouldn't be normally called by user.
Assigns variables values from the given arrays
voidputPhaseVectorForInitialConditions_xjal(double[] A, int idxA)
This method shouldn't be normally called by user.
Assigns variables values from the given arrays (the function is is used while solving initial conditions loops)
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.
CellPositionrandomEmptyCell()
Tries to find a pseudo-randomly located empty cell and return its row and column in the array with two elements.
The current implementation is 100% fairly random.
PointrandomPointOfSpace()
Returns the random location inside within the space bounds of this environment
voidreceive(Object msg)
Immediately delivers a message to this agent.
booleanremoveAgentFromContents(Agent agent)
Removes the given agent from the contents of this agent.
booleanremoveEntityFromContents(Agent agent)
Deprecated.
booleanremoveExt_xjal(AgentExtension ext)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
This method removes the given extension if it is found in this agent and return true if it was successfully removed
voidremoveFromFlowchart()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
AgentresourceUnitOfPool(Agent pool)
Returns the first occurrence of resource unit of a given pool among the seized resource units, or null if not found.
<T extends Agent>
List<T>
resourceUnits()
Returns the list of resource units seized by the entity, or empty list if there are none.
<T extends Agent>
List<T>
resourceUnitsOfPool(Agent pool)
Returns resource units currently seized by this entity from the given ResourcePool block
<T extends Agent>
List<T>
resourceUnitsOfSeize(Agent seize)
Return resource units currently seized by this entity in the given Seize block
final voidrestoreCollection_xjal(AgentList<?> collection)
Deprecated.
voidrestoreConnections_xjal(List<?> connections)
Deprecated.
voidrestoreOwner(Object owner)
Deprecated.
booleanrunSimulation()
Engine command applicable only in PAUSED state (in other states does nothing and returns false).
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.
voidsendToAll(Object msg)
Sends a message to all agents in the same environment this agent lives in.
voidsendToAllConnected(Object msg)
Sends a message to all connected agents.
voidsendToAllNeighbors(Object msg)
Sends a message to all neighbors.
voidsendToRandom(Object msg)
Sends a message to a randomly chosen agent in the same environment this agent lives in.
voidsendToRandomConnected(Object msg)
Sends a message to a randomly chosen connected agent.
voidsendToRandomNeighbor(Object msg)
Sends a message to a randomly chosen neighbor.
voidsetAgentSpaceType(SpaceType spaceType)
Sets this agent to use the space of the given type.
Will throw an error if agent already has different space type
voidsetAutomaticHorizontalRotation(boolean yes)
Tells agent to rotate automatically during movements.
voidsetAutomaticVerticalRotation(boolean yes)
Tells agent to rotate automatically (in vertical direction, along Z-axis) during movements in 3D.
Has no effect if isAutomaticHorizontalRotation() is false
voidsetCell(int r, int c)
Puts the agent into a given cell.
voidsetColor(Color color)
Sets the color of the item's default animation shape.
For custom agent type animation shapes, please use setFillColor and other setters.
voidsetDestroyed()
Marks this object as subject to destruction after the current step is finished.
voidsetDimensions(double lengthInMeters, double widthInMeters, double heightInMeters)
Sets the length, width, height of the agent
voidsetDimensions(double lengthInUnits, double widthInUnits, double heightInUnits, LengthUnits units)
Sets the length, width, height of the agent
voidsetEngine(Engine engine)
Sets the simulation engine for the object.
voidsetEnvironment(Agent env)
Sets up time, space, etc.
voidsetHeight(double heightInMeters)
Sets the height of the agent
voidsetHeight(double heightInUnits, LengthUnits units)
Sets the height of the agent
voidsetId(int id) 
voidsetLatLon(double latitude, double longitude)
Sets the coordinates of the agent location.
voidsetLayoutType(LayoutType type)
Sets the layout type.
voidsetLength(double lengthInMeters)
Sets the length of the agent.
voidsetLength(double lengthInUnits, LengthUnits units)
Sets the length of the agent.
voidsetLevel(Level level)
Sets this agent to live in the level, actual for agents in continuous space.
voidsetLocation(Agent agent)
Takes position of given agent and sets it to this agent.
voidsetLocation(Attractor attractor)
Sets the current network location for the agent
voidsetLocation(INode node)
This method is used for initialization only, for dynamic assignment, please use jumpTo(INode).
Sets the coordinates of the agent location and puts it into network node (if network is defined).
Should only be used to initialize the agent location.
voidsetLocation(Point point)
This method is used for initialization only, for dynamic assignment, please use jumpTo(Point).
Sets the coordinates of the agent location.
Should only be used to initialize the agent location.
voidsetLocationRandomInside(INode node)
This method is used for initialization only, for dynamic assignment, please use jumpTo(INode).
Sets the coordinates of the agent location to the randomly chosen point inside the given node and puts it into network node (if network is defined).
Should only be used to initialize the agent location.
voidsetNetwork(INetwork network)
Sets this agent to live in the network, actual for agents in continuous and GIS space.
voidsetNetworkAllInRange(double connectionRange)
Sets network type to the one when agents are connected if the distance between them is not longer that a given one.
voidsetNetworkNode(Attractor attractor)
Sets the current network location for the agent
voidsetNetworkNode(INode node)
Sets the current network location for the agent
voidsetNetworkNode(INode node, Point position)
Deprecated.
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".
voidsetNetworkUserDefined()
Sets network type to user-defined.
booleansetParameter(String name, Object value, boolean callOnChange)
Sets the value to parameter with the given name.
This method should be overridden in subclasses.
voidsetParametersToDefaultValues()
Sets all not dynamic parameters to their default values.
This method must be implemented in a subclass, during code generation, and it must call super method.
This method is designed to be used in custom experiments for easier setup of top-level agent in certain situations.
voidsetPosition(Position position)
This method is used for initialization only, for dynamic assignment, please use jumpTo(double, double).
Sets the coordinates and orientation of the agent location.
Should only be used to initialize the agent location.
voidsetRotation(double rotation)
Sets the rotation angle (in radians) of the agent animation in continuous 3D space or GIS space.
voidsetRouteProvider(IRouteProvider routeProvider)
Stops agent if it is moving.
voidsetSpace(Agent space)
Sets the space for agent.
voidsetSpeed(double speedInMPS)
Changes speed of the agent in continuous/GIS space (measured in meters per second).
If the agent is moving, it continues moving with the new speed.
voidsetSpeed(double speedInUnits, SpeedUnits units)
Changes speed of the agent in continuous/GIS space (measured in the given units).
If the agent is moving, it continues moving with the new speed.
voidsetupExt_xjal(AgentExtension ext)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future
voidsetupInitialConditions_xjal(Class<?> callerClass)
This method shouldn't be normally called by user.
voidsetupSpace(double width, double height)
Sets the space to the given dimensions.
voidsetupSpace(double width, double height, double zHeight)
Sets the space to the given dimensions.
voidsetupSpace(double width, double height, int rows, int columns, NeighborhoodType neighborhoodType)
Sets the space type to discrete with the given dimensions and neighbourhood type.
voidsetupSpace(AbstractShapeGISMap gisMap)
Sets the environment to have GIS space to be based on given gisMap.
voidsetVelocity(double v)
Deprecated.
this function is deprecated since AnyLogic 7.1.
voidsetVerticalRotation(double rotation)
Sets the vertical rotation (angle in radians), along Z-axis of the agent animation in 3D space.
voidsetWidth(double widthInMeters)
Sets the width of the agent
voidsetWidth(double widthInUnits, LengthUnits units)
Sets the width of the agent
voidsetXY(double x, double y)
Sets the coordinates of the agent location.
voidsetXYZ(double x, double y, double z)
This method is used for initialization only, for dynamic assignment, please use jumpTo(double, double).
Sets the coordinates of the agent location in continuous 3D space.
Should only be used to initialize the agent location.
voidsetXYZ(Point location)
This method is used for initialization only, for dynamic assignment, please use jumpTo(double, double).
Sets the coordinates of the agent location in continuous 3D space.
Should only be used to initialize the agent location.
doublespaceCellHeight()
Returns the height of the cell in discrete space.
doublespaceCellWidth()
Returns the width of the cell in discrete space.
intspaceColumns()
Returns the number of columns in the space.
doublespaceHeight()
Returns the height of environment continuous or discrete space.
intspaceRows()
Returns the number of rows in the space.
doublespaceWidth()
Returns the width of environment continuous or discrete space.
doublespaceZHeight()
Returns the height of environment space along Z-axis.
final voidstart()
Starts activities (e.g.
final voidstartAsEmbedded()
Internal method to be called for embedded agents inside doStart() of an upper-level agent.
<T extends Enum<T> & IStatechartState<?, T>>
boolean
stateContainsState(T compstate, T simpstate)
Deprecated.
voidstop()
Stops movement in continuous 3D or GIS space.
booleanstopSimulation()
Engine command applicable only in any non-IDLE state (in IDLE state does nothing and returns false).
voidswapWithAgent(Agent anotherAgent)
Swaps the cell location of this agent with another agent.
voidswapWithCell(int r, int c)
Swaps this agent with an agent at the cell with the given row and column.
voidswapWithNextCell(CellDirection dir)
Swaps the agent with an agent at the adjacent cell in a given direction.
booleantestConditionOf(EventCondition e)
Tests the condition expression of a condition event.
Must be implemented in a subclass if there are any condition events.
booleantestConditionOf(TransitionCondition t)
Tests the condition expression of a transition event.
Must be implemented in a subclass if there are any condition transitions.
booleantestGuardOf(TransitionCondition t)
Tests the guard expression of a condition transition.
Implementation in a subclass can be skipped if the guard(s) are empty.
booleantestGuardOf(TransitionMessage t)
Tests the guard expression of a message transition.
Implementation in a subclass can be skipped if the guard(s) are empty.
booleantestGuardOf(TransitionRate t)
Tests the guard expression of a rate transition.
Implementation in a subclass can be skipped if the guard(s) are empty.
booleantestGuardOf(TransitionTimeout t)
Tests the guard expression of a timeout transition.
Implementation in a subclass can be skipped if the guard(s) are empty.
booleantestMessageOf(TransitionMessage t, Object msg)
Tests the message received by the statechart against the trigger description of a message transition - for Object message type.
Must be implemented in a subclass if there are any message transitions.
final doubletimeToArrival()
Returns the time to arrival to the target location in continuous 2D space or GIS space, in model-time units.
If the agent is not moving, returns 0.
final doubletimeToArrival(TimeUnits units)
Returns the time to arrival to the target location in continuous 2D space or GIS space, in model-time units.
If the agent is not moving, returns 0.
doubletoLengthUnits(double lengthInPixels, LengthUnits units)
Converts the given pixel length to the length units (using scale of this agent which acts as 'Space')
doubletoPixels(double lengthInUnits, LengthUnits units)
Converts the length in the given length units to pixels (using scale of this agent which acts as 'Space')
StringtoString()
Returns a (possibly, multi-line) textual information on the agent.
final <T extends AgentExtension>
T
tryExt(Class<T> c)
Returns an extension of given type only if this object already contains such extension.
voidwarning(String warningText)
Signals a warning during the model run with warningText preceded by the agent full name.
Warnings may be turned off in the AnyLogic preferences (runtime section) or by API: AnyLogicRuntimePreferences.setEnableWarnings(Boolean).
This method checks against numerous warnings output: In case of multiple warnings having equal warningText, only the first 10 of them are displayed.
voidwarning(String warningTextFormat, Object... args)
Signals a warning during the model run with warningText preceded by the agent full name.

Methods inherited from class com.anylogic.engine.Utilities

addToDate, addToDate, atan2fast, bernoulli, bernoulli, beta, beta, beta, beta, beta, binomial, binomial, binomial, binomial, binomial, briefInfoOn, castNumberTypes, castTypes, castTypesBack, cauchy, cauchy, cauchy, chi2, chi2, chi2, convertMarkupSegmentDescriptors_xjal, copyToClipboard, copyToClipboard, copyToClipboard, createTableElementDatabaseBuilder, createTrajectoryGIS, createURL_xjal, date, dateToTime, day, deleteFrom, difference, difference, differenceInCalendarUnits, differenceInCalendarUnits, differenceInDateUnits, differenceInDateUnits, differenceInDateUnits, differenceInDateUnits, dirToAngle, dropTime, erlang, erlang, erlang, error, error, error, errorInModel, errorInModel, errorInModel, executeAction, executeExpression, executeExpression, executeStatement, exponential, exponential, exponential, exponential, exponential, exponential, findExistingFile, format, format, format, format, format, format, format, formatAmountUnits, formatDayOfWeek, formatFlowRateUnits, formatGeoHeading, formatLatitude, formatLengthUnits, formatLengthUnits, formatLongitude, formatMonth, formatSpeedUnits, formatTimeInterval, gamma, gamma, gamma, gamma, gamma, gammaLog, geometric, geometric, getAmPm, getAmPm, getCanonicalPath, getDatabaseConnection, getDateWithTimeNextTo, getDayOfMonth, getDayOfMonth, getDayOfWeek, getDayOfWeek, getDayOfYear, getDefaultRandomGenerator, getDistance, getDistance, getDistanceFromPointToLine, getDistanceFromPointToLineSq, getDistanceFromPointToSegment, getDistanceFromPointToSegment, getDistanceFromPointToSegmentSq, getDistanceFromPointToSegmentSq, getDistanceGIS, getDistanceGIS, getDistanceSq, getDistanceSq, getFullName, getHour, getHour, getHourOfDay, getHourOfDay, getLength, getLength, getLengthSq, getLengthSq, getMillisecond, getMillisecond, getMinute, getMinute, getMonth, getMonth, getName, getNearestPointOnSegment, getNearestPointOnSegment, getPerformanceParallelWorkersCount_xjal, getRandom, getRandom, getResult, getSecond, getSecond, getTime, getTimeoutToNextTime, getYear, getYear, gumbel1, gumbel1, gumbel2, gumbel2, hour, hypergeometric, hypergeometric, insertInto, inspectOf, inspectOfLink_xjal, isFinite, isLineIntersectingLine, isLineIntersectingRectangle, isLoggingClassToDB, isPointInsideRay, isPointInsideRectangle, isPointInsideSegment, isPointOnTheSameLine, isRayIntersectingSegment, joinArrays_xjal, laplace, laplace, layoutTypeToString, limit, limit, limitMax, limitMax, limitMin, limitMin, logarithmic, logarithmic, logistic, logistic, lognormal, lognormal, logToDB, logToDB, logToDB, logToDB, millisecond, minute, month, negativeBinomial, negativeBinomial, negativeBinomial, negativeBinomial, normal, normal, normal, normal, normal, normal, pareto, pareto, pareto, pert, pert, poisson, poisson, poisson, poisson, prepareBeforeExperimentStart_xjal, prepareStatement, pulse, pulseTrain, quantum, ramp, random, randomColor, randomFalse, randomFalse, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomlyCreate, randomlyCreate, randomlyCreate, randomlyCreate, randomTrue, randomTrue, randomWhere, randomWhere, randomWhere, randomWhere, rayleigh, rayleigh, rayleigh, roundToDecimal, roundToInt, second, selectAndDoForEach, selectArrayOfDouble, selectArrayOfInt, selectExists, selectExists, selectFirstValue, selectFirstValue, selectFirstValue, selectFirstValue, selectFrom, selectResultSet, selectTableFunction, selectUniqueValue, selectUniqueValue, selectUniqueValue, selectUniqueValue, selectValues, selectValues, setDefaultRandomGenerator, shuffle, sqlGetObject, sqlGetObject, sqlGetObject, sqlGetObject, sqlSetObject, sqr, step, time, time, timeToDate, toBoxedDouble_xjal, toDate, toDate, toDate, toDateInMillis, toLatitude, toLongitude, toModelRate, toModelTime, toRateUnits, toStringAlignedNameValues, toTimeout, toTimeout, toTimeoutInCalendar, toTimeUnits, trace, trace, traceln, traceln, traceln, traceln, traceln, traceToDB, traceToDB, triangular, triangular, triangular, triangular, triangular, triangularAV, triangularAV, uniform, uniform, uniform, uniform, uniform, uniform_discr, uniform_discr, uniform_discr, uniform_pos, uniform_pos, update, week, weibull, weibull, weibull, weibull, weibull, xidz, year, zidz

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Details

_ARRIVAL_message_xjal

@AnyLogicInternalCodegenAPI
public static final Object _ARRIVAL_message_xjal
This variable shouldn't be accessed by user: it is used internally by AnyLogic and may be renamed/removed in future

Constructor Details

Agent

public Agent(Engine engine,
 Agent owner,
 AgentList<?> ownerPopulation)
Constructs the agent, sets up its owner and list (if replicated). Should not create any embedded objects: parameters must be set by the owner after construction and only then create() should be called.
Parameters:
engine - the simulation engine
owner - owner agent that encapsulates this one, or null if this is root
ownerPopulation - collection of agent populations where this object belongs to or null if not replicated

Agent

public Agent()
Create constructor.
This is a way for e.g. simple creation of entities. Note that object is created BUT parameters are not set and its structure is neither created nor started. To set default values of parameters please call setParametersToDefaultValues(), and to create structure and start please either call createAndStart(Agent) or goToPopulation(AgentList) note that these 2 functions will call setParametersToDefaultValues() if it hasn't yet been called or if the agent has been created using other constructor (with parameters or with Engine-Agent-Population). Note that these functions are automatically called by AnyLogic libraries, therefore you don't need to call them for entities.
All the agents in the running model should have owner either in the form of population (replicated agent collection or default population of top-level agent - may be accessed through a special extension automatically placed in the top-level agent of the model) or in the form of direct link (only for agents embedded in the AnyLogic IDE).
The only agent in the model having null owner is top-level agent.

Method Details

setEngine

public void setEngine(Engine engine)
Sets the simulation engine for the object. Is needed when a default constructor is invoked.
Parameters:
engine - the simulation engine that will handle this object

getEngine

public Engine getEngine()
Returns the simulation engine where this object belongs to.
Specified by:
getEngine in class Presentable
Returns:
the simulation engine.

getId

public int getId()
Returns the unique identifier of this agent in the context of the model run
Returns:
the unique identifier of this agent
Since:
7.2

setId

@AnyLogicInternalAPI
public void setId(int id)

getAgentTypeId

@AnyLogicInternalAPI
public int getAgentTypeId()
Returns the unique identifier of agent's type
Returns:
the unique identifier of agent's type
Since:
7.2

logToDB

@AnyLogicInternalAPI
public <T extends Enum<T> & IStatechartState<?,
T>>
void logToDB(Statechart<T> statechart,
 Transition transition,
 T fromState)
If logging enabled this method will be called in #exitState(short, Transition, boolean, Statechart) method

logToDBEnterState

@AnyLogicInternalAPI
public <T extends Enum<T> & IStatechartState<?,
T>>
void logToDBEnterState(Statechart<T> statechart,
 T state)
If logging enabled this method will be called in #exitState(short, Transition, boolean, Statechart) method

logToDBExitState

@AnyLogicInternalAPI
public <T extends Enum<T> & IStatechartState<?,
T>>
void logToDBExitState(Statechart<T> statechart,
 T state)
If logging enabled this method will be called in #exitState(short, Transition, boolean, Statechart) method

getExperimentHost

public IExperimentHost getExperimentHost()
Description copied from class: Presentable
Returns the experiment host object of the model, or some dummy object with no functionality if there is none.
Specified by:
getExperimentHost in class Presentable
Returns:
the experiment host object of the model

getName

public final String getName()
Returns the name of this agent, i.e. the name of its instance in the owner object, with the index in square brackets for replicated objects. For the top-level agent returns "root". For default population, the population name is "<population>".
Returns:
the short name of the object not including path from root

getFullName

public final String getFullName()
Returns the name of the agent prefixed by the path from the top-level agent to this one.
Returns:
the full name of the object including path from root

toString

public String toString()
Returns a (possibly, multi-line) textual information on the agent. By default returns its full name, but mat be overridden in subclasses.
Overrides:
toString in class Object
Returns:
the textual info on the agent

error

public RuntimeException error(Throwable cause,
 String errorText)
Description copied from class: Utilities
Signals an error during the model run by throwing a RuntimeException with errorText preceded by the agent full name.
Specified by:
error in class Utilities
Parameters:
cause - the cause (which will be saved for more detailed message), may be null
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw error("my message");

errorInModel

public RuntimeException errorInModel(Throwable cause,
 String errorText)
Description copied from class: Utilities
Signals an model logic error during the model run by throwing a ModelException with errorText preceded by the agent full name.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments. Examples are 'entity was unable to leave flowchart block because subsequent block was busy', 'insufficient capacity of pallet rack' etc.
Specified by:
errorInModel in class Utilities
Parameters:
cause - the cause (which will be saved for more detailed message), may be null
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw errorInModel("my message");

warning

public void warning(String warningText)
Description copied from class: Utilities
Signals a warning during the model run with warningText preceded by the agent full name.
Warnings may be turned off in the AnyLogic preferences (runtime section) or by API: AnyLogicRuntimePreferences.setEnableWarnings(Boolean).
This method checks against numerous warnings output:
  • In case of multiple warnings having equal warningText, only the first 10 of them are displayed.
  • When more than 1000 warnings having different warningText occur, all the subsequent warnings (including new occurrences of those in the first 1000) will stop displaying.
  • Be careful with using dynamically changing warningText (e.g. listing names of agents), it could be better to use Utilities.warning(String, Object...).
Specified by:
warning in class Utilities
Parameters:
warningText - the text describing the warning that will be displayed.

warning

public void warning(String warningTextFormat,
 Object... args)
Description copied from class: Utilities
Signals a warning during the model run with warningText preceded by the agent full name. The method allows warning format syntax like in String.format(String, Object...) method.
Warnings may be turned off in the AnyLogic preferences (runtime section) or by API: AnyLogicRuntimePreferences.setEnableWarnings(Boolean).
This method checks against numerous warnings output:
  • In case of multiple warnings having equal warningTextFormat, only the first 10 of them are displayed.
  • It is safe to raise numerous warnings with equal format string (which defines the warning type) but varying args - AnyLogic will take care to display only 10 first warnings of each warning type.
  • When more than 1000 warnings having different warningTextFormat occur, all the subsequent warnings (including new occurrences of those in the first 1000) will stop displaying.
  • Don't use dynamically changing warningTextFormat (e.g. listing names of agents), use args instead.
Specified by:
warning in class Utilities
See Also:

getOwner

public Agent getOwner()
Returns the owner agent that encapsulates this one, null if this is the top-level agent in the model.
Returns:
owner agent or null

getScale

public Scale getScale()
Returns the scale used by the space of this agent.
The default scale is 10 pixels per meter
Returns:
the scale used by the space of this agent

toLengthUnits

public double toLengthUnits(double lengthInPixels,
 LengthUnits units)
Converts the given pixel length to the length units (using scale of this agent which acts as 'Space')
Parameters:
lengthInPixels - the length in pixels (in the scope of this agent which acts as 'Space')
units - length units
Returns:
result in length units

toPixels

public double toPixels(double lengthInUnits,
 LengthUnits units)
Converts the length in the given length units to pixels (using scale of this agent which acts as 'Space')
Parameters:
lengthInUnits - the length in units
units - length units
Returns:
result in pixels (in the scope of this agent which acts as 'Space')

getNetworks

public INetwork[] getNetworks()
Returns array of networks located in this agent, or empty array
Returns:
array of networks located in this agent

getLevels

public Level[] getLevels()
Returns array of levels located in this agent, or empty array
Returns:
array of levels located in this agent

getRailwayNetworks

public RailwayNetwork[] getRailwayNetworks()
Returns array of railway networks located in this agent, or empty array
Returns:
array of railway networks located in this agent

getRoadNetworks

public RoadNetwork[] getRoadNetworks()
Returns array of road networks located in this agent, or empty array
Returns:
array of road networks located in this agent

getConveyorNetworks

public ConveyorNetwork[] getConveyorNetworks()
Returns array of conveyor networks located in this agent, or empty array
Returns:
array of conveyor networks located in this agent

getOwnerShape

@AnyLogicLegacyAPI
public ShapeEmbeddedObjectPresentation getOwnerShape()
Returns the shape on owner's presentation, this object presentation belongs to.
May return null if this object's presentation isn't located anywhere or when it has no own presentation (e.g. it is of plain Agent class)
Returns:
the shape on owner's presentation, this object presentation belongs to

getEmbeddedObjects

public List<Object> getEmbeddedObjects()
Creates and returns a list of embedded objects if there are any, null if there are none. For a agent population its list is included in the result, not each object, therefore the resulting list contains either instances of Agent or of AgentList<? extends Agent>
This function must be implemented in a subclass if there is at least one embedded object.
Returns:
the newly created list of all embedded objects, or null

isReplicated

public boolean isReplicated()
Returns true if this object is embedded in its owner as replicated, i.e. as a member of a list of objects.
Returns:
true if this object is replicated, false otherwise.

getIndex

public int getIndex()
For a list-based agent population, returns its index in the list, otherwise returns -1. Current implementation is very inefficient (linear complexity) and will be changed!
Returns:
index of this object in the replicated list or -1
Throws:
RuntimeException - if agent population is not list-based.

getReplicatedCollection

@AnyLogicLegacyAPI
@Deprecated
public AgentList<?> getReplicatedCollection()
Deprecated.
This method may be removed in the next release. Please use getReplicatedList() instead

getReplicatedList

@AnyLogicLegacyAPI
public AgentList<?> getReplicatedList()
For agent population returns the List of agents embedded in the owner object where this agent belongs to, null if the object is not replicated
Returns:
the List where this object belongs to, or null

getPopulation

public AgentList<?> getPopulation()
For agent population returns the List of agents embedded in the owner object where this agent belongs to, null if the object is not replicated
Returns:
the List where this object belongs to, or null

goToPopulation

public void goToPopulation(AgentList newPopulation)
Changes the population of agent. Agent will leave its current environment (if any was) and come into environment of the newPopulation (if it lives in an environment).
If newPopulation is null then the agent will go into 'default population' of top-level agent of model and will leave its environment (if any was).
Parameters:
newPopulation - the new population or null if the agent is intended to go into 'default population' of top-level agent of model.

onOwnerChanged_xjal

@AnyLogicInternalCodegenAPI
public void onOwnerChanged_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.

instantiateBaseStructure_xjal

@AnyLogicInternalCodegenAPI
public void instantiateBaseStructure_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.

deleteSelf

public void deleteSelf()
Removes this agent from the agent population (replicated agent list) it belongs to. Throws error if agent belongs to some flowchart block (it is an 'entity'). Also throws error if the agent doesn't belong to any population (e.g. when it is a single, not replicated agent.
Since:
7.0

removeFromFlowchart

@AnyLogicInternalCodegenAPI
public void removeFromFlowchart()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.

onBeforeCreate

@AnyLogicInternalCodegenAPI
public void onBeforeCreate()
Is called at the very start of create() method, i.e. when all parameters have been initialized but before the internal structure like embedded objects is created. By default this method does nothing, but can be defined by the user.
Since:
7.2
See Also:
onCreate()

onCreate

@AnyLogicInternalCodegenAPI
public void onCreate()
Is called at the very end of create() method, i.e. when all parameters have been initialized, embedded objects are created (and their onCreate() has been called), but before any activities are started (no events are scheduled yet), thus also before the startup code is executed. By default this method does nothing, but can be defined by the user.

onStartup

@AnyLogicInternalCodegenAPI
public void onStartup()
Is called after all activities are started in the object (initial events are scheduled) and onStartup() has been called for the embedded objects, but before any steps are made. By default this method does nothing, but can be defined by the user by filling out the startup code section.

onChange

public void onChange()
Notification to the agent meaning "some of your data may have changed during this event". Causes:
1. Re-evaluation of conditions in events and statechart transitions with Condition triggers
2. Re-calculation of rates in events and statechart transitions with Rate triggers
By default this method is called if the agent originates an event or if a message is received by one of its ports. This can be prevented by calling nothingChanged().
You can also manually call this function if you wish some agent to notice the change even if it had no events.

nothingChanged

public void nothingChanged()
If called during an event execution, prevents the engine from calling onChange() of the agent that originated the event. Has effect only within one event. Does not affect other agents where the user may have manually called onChange() or it may have got called by ports, etc.

getDynamicEvents

public Set<DynamicEvent> getDynamicEvents()
Returns the set of all currently existing dynamic events of this agent. The user should not change this set.
Returns:
the set of active dynamic events

isPublicPresentationDefined

@AnyLogicInternalCodegenAPI
public boolean isPublicPresentationDefined()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.

isEmbeddedAgentPresentationVisible

@AnyLogicInternalCodegenAPI
public boolean isEmbeddedAgentPresentationVisible(Agent embeddedAgent)
This method is internal and shouldn't be called by user.
This method works only for single embedded objects (not population) inside this agent.
Method may be removed/renamed in future. It is public due to technical reasons.

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(EventTimeout e)
Returns the name of a timeout event.
Must be implemented in a subclass if there are any timeout events.
Parameters:
e - the event
Returns:
event name

getModeOf

@AnyLogicInternalCodegenAPI
public EventTimeout.Mode getModeOf(EventTimeout e)
Returns mode of a timeout event: Cyclic, Once, User.
Must be implemented in a subclass if there are any timeout events.
Parameters:
e - the event
Returns:
event mode

getFirstOccurrenceTime

@AnyLogicInternalCodegenAPI
public double getFirstOccurrenceTime(EventTimeout e)
Returns the (absolute) time of first occurrence of a timeout event (of Once or Cyclic mode). Must be implemented in a subclass if there are any such timeout events.
Parameters:
e - the event
Returns:
the time of first occurrence, 0 by default

evaluateTimeoutOf

@AnyLogicInternalCodegenAPI
public double evaluateTimeoutOf(EventTimeout e)
Evaluates timeout expression of a timeout event.
Must be implemented in a subclass if there are any timeout events.
Parameters:
e - the event
Returns:
the timeout value

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(EventTimeout e)
Executes action of a timeout event.
Implementation in a subclass can be skipped if the action(s) are empty.
Parameters:
e - the event

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(EventRate e)
Returns the name of a rate event.
Must be implemented in a subclass if there are any rate events.
Parameters:
e - the event
Returns:
event name

evaluateRateOf

@AnyLogicInternalCodegenAPI
public double evaluateRateOf(EventRate e)
Evaluates the rate expression of a rate event.
Must be implemented in a subclass if there are any rate events.
Parameters:
e - the event
Returns:
the rate value

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(EventRate e)
Executes action of a rate event.
Implementation in a subclass can be skipped if the action(s) are empty.
Parameters:
e - the event

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(EventCondition e)
Returns the name of a condition event.
Must be implemented in a subclass if there are any condition events.
Parameters:
e - the event
Returns:
event name

testConditionOf

@AnyLogicInternalCodegenAPI
public boolean testConditionOf(EventCondition e)
Tests the condition expression of a condition event.
Must be implemented in a subclass if there are any condition events.
Parameters:
e - the event
Returns:
result of condition evaluation

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(EventCondition e)
Executes action of a condition event.
Implementation in a subclass can be skipped if the action(s) are empty.
Parameters:
e - the event

isLoggingToDB

@AnyLogicInternalCodegenAPI
public boolean isLoggingToDB(EventOriginator e)
Return true if the given event (or dynamic event) is logged to database (note that this may be overridden by logging settings of Agent).
Default implementation returns true. Must be implemented in a subclass if there are any events with logging turned off.
Parameters:
e - the event
Returns:
false to force disable logging, otherwise true

isLoggingToDB

public boolean isLoggingToDB(LoggingType loggingType)
Description copied from class: Utilities
Returns true if this agent and its internals may log their data/changes/activity to AnyLogic built-in database (logging options are configurable in the properties of Database / Log in the Projects tree inside AnyLogic)
Overrides:
isLoggingToDB in class Utilities
Parameters:
loggingType - type of logging
Returns:
true if logged, false otherwise

inState

public boolean inState(IStatechartState<?,?> state)
Returns true if the corresponding statechart of this agent is at the specified state, i.e. exactly in the state for a simple state and in one of its inner states for a composite state.
Parameters:
state - the state
Returns:
true if state is currently active
Since:
7.0.2

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(Statechart<?> s)
Returns the name of a statechart.
Must be implemented in a subclass if there are any statecharts.
Parameters:
s - the statechart
Returns:
statechart name

getIdOf

@AnyLogicInternalCodegenAPI
public int getIdOf(Statechart<?> s)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
Returns some ordinal number of this statechart in the agent type (like id, among all statecharts, respecting agent type inheritance)
Parameters:
s - the statechart
Returns:
statechart id

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(Statechart<?> s)
Executes startup action of a statechart: calls actions of the statechart entry point, entry action of initial states, starts the corresponding transitions, etc., and sets up the initially active simple state.
Must be implemented in a subclass if there are any statecharts.
Parameters:
s - the statechart

getNameOfState

public String getNameOfState(IStatechartState<?,?> state)
Returns the name of a statechart state.
Must be implemented in a subclass if there are any states.
Parameters:
state - the state
Returns:
state name
See Also:
IStatechartState.name()

stateContainsState

@Deprecated
@AnyLogicInternalCodegenAPI
public <T extends Enum<T> & IStatechartState<?,
T>>
boolean stateContainsState(T compstate,
 T simpstate)
Deprecated.
This method is internal, deprecated and will be removed in the next release.>

getContainerStateOf

@Deprecated
@AnyLogicInternalCodegenAPI
public <T extends Enum<T> & IStatechartState<?,
T>>
T getContainerStateOf(T state)
Deprecated.
This method is internal, deprecated and will be removed in the next release.>

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(TransitionTimeout t)
Returns the name of a timeout transition.
Must be implemented in a subclass if there are any timeout transitions.
Parameters:
t - the transition
Returns:
transition name

evaluateTimeoutOf

@AnyLogicInternalCodegenAPI
public double evaluateTimeoutOf(TransitionTimeout t)
Evaluates timeout expression of a timeout transition.
Must be implemented in a subclass if there are any timeout transitions.
Parameters:
t - the transition
Returns:
the timeout value

testGuardOf

@AnyLogicInternalCodegenAPI
public boolean testGuardOf(TransitionTimeout t)
Tests the guard expression of a timeout transition.
Implementation in a subclass can be skipped if the guard(s) are empty.
Parameters:
t - the transition
Returns:
result of guard evaluation

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(TransitionTimeout t)
Executes action of a timeout transition.
Implementation in a subclass can be skipped if the action(s) are empty.
Parameters:
t - the transition

getStatechartOf

@AnyLogicInternalCodegenAPI
public Statechart getStatechartOf(TransitionTimeout t)
Returns the statechart where the timeout transition belongs to.
Must be implemented in a subclass if there are any timeout transitions.
Parameters:
t - the transition.
Returns:
the statechart of the transition

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(TransitionRate t)
Returns the name of a rate transition.
Must be implemented in a subclass if there are any rate transitions.
Parameters:
t - the transition
Returns:
transition name

evaluateRateOf

@AnyLogicInternalCodegenAPI
public double evaluateRateOf(TransitionRate t)
Evaluates the rate expression of a rate transition.
Must be implemented in a subclass if there are any rate transitions.
Parameters:
t - the transition
Returns:
the rate value

testGuardOf

@AnyLogicInternalCodegenAPI
public boolean testGuardOf(TransitionRate t)
Tests the guard expression of a rate transition.
Implementation in a subclass can be skipped if the guard(s) are empty.
Parameters:
t - the transition
Returns:
result of guard evaluation

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(TransitionRate t)
Executes action of a rate transition.
Implementation in a subclass can be skipped if the action(s) are empty.
Parameters:
t - the transition

getStatechartOf

@AnyLogicInternalCodegenAPI
public Statechart getStatechartOf(TransitionRate t)
Returns the statechart where the rate transition belongs to.
Must be implemented in a subclass if there are any rate transitions.
Parameters:
t - the transition.
Returns:
the statechart of the transition

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(TransitionCondition t)
Returns the name of a condition transition.
Must be implemented in a subclass if there are any condition transitions.
Parameters:
t - the transition
Returns:
transition name

testConditionOf

@AnyLogicInternalCodegenAPI
public boolean testConditionOf(TransitionCondition t)
Tests the condition expression of a transition event.
Must be implemented in a subclass if there are any condition transitions.
Parameters:
t - the transition
Returns:
result of condition evaluation

testGuardOf

@AnyLogicInternalCodegenAPI
public boolean testGuardOf(TransitionCondition t)
Tests the guard expression of a condition transition.
Implementation in a subclass can be skipped if the guard(s) are empty.
Parameters:
t - the transition
Returns:
result of guard evaluation

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(TransitionCondition t)
Executes action of a condition transition.
Implementation in a subclass can be skipped if the action(s) are empty.
Parameters:
t - the transition

getStatechartOf

@AnyLogicInternalCodegenAPI
public Statechart getStatechartOf(TransitionCondition t)
Returns the statechart where the condition transition belongs to.
Must be implemented in a subclass if there are any condition transitions.
Parameters:
t - the transition.
Returns:
the statechart of the transition

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(TransitionMessage t)
Returns the name of a message transition.
Must be implemented in a subclass if there are any message transitions.
Parameters:
t - the transition
Returns:
transition name

testMessageOf

@AnyLogicInternalCodegenAPI
public boolean testMessageOf(TransitionMessage t,
 Object msg)
Tests the message received by the statechart against the trigger description of a message transition - for Object message type.
Must be implemented in a subclass if there are any message transitions.
Parameters:
t - the transition.
msg - the message received
Returns:
true if the message matches the trigger, false otherwise

testGuardOf

@AnyLogicInternalCodegenAPI
public boolean testGuardOf(TransitionMessage t)
Tests the guard expression of a message transition.
Implementation in a subclass can be skipped if the guard(s) are empty.
Parameters:
t - the transition
Returns:
result of guard evaluation

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(TransitionMessage t,
 Object msg)
Executes action of a message transition for Object message type - depends on the message.
Implementation in a subclass can be skipped if the action(s) are empty.
Parameters:
t - the transition
msg - the message received

executeActionOf

@AnyLogicInternalCodegenAPI
public void executeActionOf(TransitionMessage t,
 int msg)
Executes action of a message transition for int message type - depends on the message.
Implementation in a subclass can be skipped if the action(s) are empty.
Parameters:
t - the transition
msg - the message received

getStatechartOf

@AnyLogicInternalCodegenAPI
public Statechart getStatechartOf(TransitionMessage t)
Returns the statechart where the message transition belongs to.
Must be implemented in a subclass if there are any message transitions.
Parameters:
t - the transition.
Returns:
the statechart of the transition

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(Port<?,?> p)
Returns the name of a port.
Must be implemented in a subclass if there are any ports.
Parameters:
p - the port
Returns:
port name

executeOnSendActionOf

@AnyLogicInternalCodegenAPI
public boolean executeOnSendActionOf(Port<?,?> p,
 Object msg)
Executes action associated with a message being sent via a port. The code may analyze the message and prevent the port from continuing processing it by returning false.
Implementation in a subclass can be skipped if all actions are empty. Otherwise, for all empty actions true must be returned.
Parameters:
p - the port
msg - the message being sent

executeOnReceiveActionOf

@AnyLogicInternalCodegenAPI
public boolean executeOnReceiveActionOf(Port<?,?> p,
 Object msg)
Executes action code associated with a message being received at a port. The code may analyze the message and prevent the port from continuing processing it by returning false.
Implementation in a subclass can be skipped if all actions are empty. Otherwise, for all empty actions true must be returned.
Parameters:
p - the port
msg - the message being received

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(Agent ao)
Returns the name of a simple (not replicated) embedded object.
Must be implemented in a subclass if there are any embedded objects.
Parameters:
ao - the embedded agent
Returns:
embedded object name

getNameOf

@AnyLogicInternalCodegenAPI
public String getNameOf(AgentList<?> aocollection)
Returns the name of a replicated embedded object.
Must be implemented in a subclass if there are any replicated embedded objects.
Parameters:
aocollection - the embedded collection of agents
Returns:
embedded object list name

getAnimationSettingsOf

@AnyLogicInternalCodegenAPI
public AgentAnimationSettings getAnimationSettingsOf(Agent ao)
Returns the animation settings of a simple (not replicated) embedded object.
Must be implemented in a subclass if there are any embedded objects.
Parameters:
ao - the embedded agent
Returns:
embedded object animation settings

getAnimationSettingsOf

@AnyLogicInternalCodegenAPI
public AgentAnimationSettings getAnimationSettingsOf(AgentList<?> aocollection)
Returns the animation settings of a replicated embedded object.
Must be implemented in a subclass if there are any replicated embedded objects.
Parameters:
aocollection - the embedded collection of agents
Returns:
embedded object list animation settings

getCameras3D

@AnyLogicInternalCodegenAPI
public int getCameras3D(Map<String,Camera3D> output)
Adds all Camera3D of this agent to the given map output, if it is not null.
Default implementation does nothing and returns 0.
Parameters:
output - the map for 3D cameras (field name -> 3D camera), not cleared by this method, may be null: in this case the method only returns the number of 3D cameras.
Returns:
the number of 3D cameras in this agent

drawLinksToAgents

@AnyLogicInternalCodegenAPI
public void drawLinksToAgents(boolean underAgents,
 LinkToAgentAnimator animator)
This method automatically generated by AnyLogic. Users shouldn't explicitly use it. This method should be overridden to draw all links
Parameters:
underAgents - this argument tell which links should be drawn (true = links which are drawn behind agent animations, false - links which are drawn on top of agent animations)

_initGetEngine_xjal

@AnyLogicInternalCodegenAPI
public static Engine _initGetEngine_xjal(Agent owner)
This method shouldn't be called by user. It is public due to technical reasons.

createAndStart

public void createAndStart(Agent anyAgent)
Assigns the owner of the agent to the top-level agent of the model, creates the internal structure of the agent (internally embedded agents, statecharts etc.) and starts it (thus its statechart and events start living). This method should be called for all agents customly created in modeler's "java code" by using no-argument constructor.
This method shouldn't be called for any agents created in usual way in the AnyLogic IDE and for agents created in AnyLogic library blocks (like Source, PedSource etc.) as well as it shouldn't be called twice.
Parameters:
anyAgent - absolutely any valid agent of the model, it is needed to obtain top-level agent of the model (which will become the true 'owner' of created agent), should be not null and should have a reference to a valid Engine.

getRootAgent

public Agent getRootAgent()
Returns the top-level agent or null if root couldn't be found
Returns:
the top-level agent

getDefaultPopulation

public AgentList<Agent> getDefaultPopulation()
Returns the default population (contained in top-level agent) or null if root couldn't be found
Returns:
the default population

setParametersToDefaultValues

public void setParametersToDefaultValues()
Sets all not dynamic parameters to their default values.
This method must be implemented in a subclass, during code generation, and it must call super method.
This method is designed to be used in custom experiments for easier setup of top-level agent in certain situations.

markParametersAreSet

public void markParametersAreSet()
This methods should be used to mark agents created using no-argument constructor as having all the parameters set. This will prevent agents for parameters initialization in the first place where they will be sent (in library blocks, populations etc. - they usually call setParametersToDefaultValues() and then call create() and start())

setParameter

public boolean setParameter(String name,
 Object value,
 boolean callOnChange)
Sets the value to parameter with the given name.
This method should be overridden in subclasses.
Parameters:
name - the name of (not dynamic) parameter
value - the value to be set
callOnChange - true to call on change code
Returns:
true if successful, false if parameter wasn't found

getParameter

public <T> T getParameter(String name)
Returns the value of parameter with the given name.
This method should be overridden in subclasses.
Throws error if there is no parameter with the given name.
Parameters:
name - the name of (not dynamic) parameter
Returns:
the value
Since:
7.2

getParameterNames

public String[] getParameterNames()
Returns array of all not dynamic parameter names.
Returns:
names of parameters
Since:
7.2
See Also:
getParameter(String)

create

public final void create()
Creates the agent embedded objects; also calls user's onBeforeCreate() at the beginning and onCreate() at the end. Is called after the agent has been constructed and its parameters have been setup by the owner object.
If there are any embedded objects, doCreate() method should be implemented in subclass

createAsEmbedded

@AnyLogicInternalCodegenAPI
public final void createAsEmbedded()
Internal method to be called for embedded agents inside doCreate() of an upper-level agent.
Since:
8.4

doAfterCreate

@AnyLogicInternalCodegenAPI
public void doAfterCreate()
Internal callback to perform additional "after all agents created" actions.
Since:
8.4

doCreate

@AnyLogicInternalCodegenAPI
public void doCreate()
Creates the agent embedded objects.
If there are any embedded objects, this method should be implemented in subclass to instantiate them, setup their parameters and call agent.createAsEmbedded() method on each agent.
Since:
7.2

start

@AnyLogicInternalCodegenAPI
public final void start()
Starts activities (e.g. schedules initial events) in this agent: events, statecharts and embedded objects, submits equations. Method doStart() should be implemented in subclasses by default does nothing.

startAsEmbedded

@AnyLogicInternalCodegenAPI
public final void startAsEmbedded()
Internal method to be called for embedded agents inside doStart() of an upper-level agent.
Since:
8.4

doStart

@AnyLogicInternalCodegenAPI
public void doStart()
Starts activities (e.g. schedules initial events) in this agent: events, statecharts and embedded objects, submits equations. Should be implemented in subclasses, by default does nothing.
If there are any embedded objects, this method should be implemented in subclass to call agent.startAsEmbedded() method on each agent.
Since:
7.2

stopSimulation

public boolean stopSimulation()
Engine command applicable only in any non-IDLE state (in IDLE state does nothing and returns false). If the state is RUNNING, sets a flag that, when tested by the model execution thread, causes it to terminate. Further behavior depends on context where this method is called:
  • When this method is called from the model execution thread, or from control action code, or from on-click code of a shape, it returns true immediately, leaving the model in PLEASE_WAIT state. Model is stopped and destroyed some time later (After Simulation Run code of an experiment or On Destroy code of top-level agent may be used to handle this moment)
    It is more recommended to use finishSimulation() method in such situations
  • When this method is called from other locations (e.g. user-defined concurrent thread), it waits for the model execution thread to terminate and then destroys the model (calls root.onDestroy()) and forgets it. Then puts the engine into IDLE state and returns true.
See Also:
Engine.stop()

finishSimulation

public boolean finishSimulation()
Engine command applicable only in RUNNING or PAUSED state (in other states does nothing and returns false). Sets a flag that, when tested by the engine, causes it to finish after completing the current event execution. Further behavior depends on context where this method is called:
  • When this method is called from the model execution thread, control action code, or from on-click code of a shape, it returns true immediately. Model is finished just after current event execution (After Simulation Run code of an experiment may be used to handle this moment)
  • When this method is called from other locations (e.g. user-defined concurrent thread), it waits for the model execution thread to terminate and returns true.
Note that by the time this method finishes, the engine may be in FINISHED, or ERROR state.
Returns:
false if the engine state does not allow pausing
See Also:
Engine.finish()

pauseSimulation

public boolean pauseSimulation()
Engine command applicable only in RUNNING state (in other states does nothing and returns false). Puts the engine into PLEASE_WAIT state and then sets a flag that, when tested by the engine, causes it to pause after completing the current event execution. Further behavior depends on context where this method is called:
  • When this method is called from the model execution thread, from control action code, or from on-click code of a shape, it returns true immediately. Model is finished just after current event execution
  • When this method is called from other locations (e.g. user-defined concurrent thread), it waits for the model execution thread to terminate and returns true.
Note that by the time this method finishes, the engine may be in PAUSED, FINISHED, or ERROR state.
Returns:
false if the engine state does not allow pausing
See Also:
Engine.pause()

runSimulation

public boolean runSimulation()
Engine command applicable only in PAUSED state (in other states does nothing and returns false). Puts the engine into RUNNING state and then starts the model execution in a separate thread. The execution may discontinue due to the one of the following reasons
- there are no more events to execute (state -> FINISHED)
- stopTime is reached (state -> FINISHED)
- pause() was called (state -> PAUSED)
- top-level agent has been destroyed (state -> FINISHED)
- exception occurred during event execution or agent destruction (state -> ERROR)
This method should never be called from the model execution thread!
Please note that by the time this method finishes, then engine may already be in PAUSED, FINISHED, or ERROR state.
Returns:
false if the engine state does not allow running
See Also:
Engine.run()

setDestroyed

@AnyLogicInternalCodegenAPI
public void setDestroyed()
Marks this object as subject to destruction after the current step is finished. Only this method should be called during a step, and not onDestroy()!

onDestroy

@AnyLogicInternalCodegenAPI
public void onDestroy()
Must be called when the agent is dynamically disposed. Deletes all event entries belonging to the agent from the engine and unsubmits equations.
Don't call this method during step, use setDestroyed() instead

onEngineFinished

@AnyLogicInternalCodegenAPI
public void onEngineFinished()
Is called by the engine when it finishes running and is intended to wrap up a single simulation run (e.g. collect some results).
This is a user's extension point, by default does nothing.
Please note that Output elements which are calculated "On simulation end", are initialized after this method is called
Since:
8.0

doFinish

@AnyLogicInternalCodegenAPI
public void doFinish()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
Since:
8.0

getIntegrationManager_xjal

@AnyLogicInternalCodegenAPI
public SDIntegrationManager getIntegrationManager_xjal()
This method shouldn't be normally called by user.
Returns static integration manager defined in derived classes.
Returns:
static integration manager defined in derived classes

getDifferentialFlatEquationsCount_xjal

@AnyLogicInternalCodegenAPI
public int getDifferentialFlatEquationsCount_xjal()
This method shouldn't be normally called by user.

getRuntimeAlgebraicFlatEquationsCount_xjal

@AnyLogicInternalCodegenAPI
public int getRuntimeAlgebraicFlatEquationsCount_xjal()
This method shouldn't be normally called by user.

getRuntimeFormulaFlatEquationsCount_xjal

@AnyLogicInternalCodegenAPI
public int getRuntimeFormulaFlatEquationsCount_xjal()
This method shouldn't be normally called by user.

getInitialAlgebraicFlatEquationsCount_xjal

@AnyLogicInternalCodegenAPI
public int getInitialAlgebraicFlatEquationsCount_xjal()
This method shouldn't be normally called by user.

getInitialFormulaFlatEquationsCount_xjal

@AnyLogicInternalCodegenAPI
public int getInitialFormulaFlatEquationsCount_xjal()
This method shouldn't be normally called by user.

getPhaseVector_xjal

@AnyLogicInternalCodegenAPI
public void getPhaseVector_xjal(double[] D,
 int idxD,
 double[] A,
 int idxA)
This method shouldn't be normally called by user.
Assigns given arrays with current variables values
Parameters:
D -
A -

putPhaseVector_xjal

@AnyLogicInternalCodegenAPI
public void putPhaseVector_xjal(double[] D,
 int idxD,
 double[] A,
 int idxA)
This method shouldn't be normally called by user.
Assigns variables values from the given arrays
Parameters:
D -
A -

getRightPart_xjal

@AnyLogicInternalCodegenAPI
public void getRightPart_xjal(double[] DR,
 int idxDR,
 double[] AR,
 int idxAR)
This method shouldn't be normally called by user.
Calculates right parts of differential equations and algebraic equations to the given arrays
Parameters:
DR -
AR -

formulasExecute_xjal

@AnyLogicInternalCodegenAPI
public void formulasExecute_xjal()
This method shouldn't be normally called by user.
Executes formulas defined in this agent.

getPhaseVectorForInitialConditions_xjal

@AnyLogicInternalCodegenAPI
public void getPhaseVectorForInitialConditions_xjal(double[] A,
 int idxA)
This method shouldn't be normally called by user.
Assigns given arrays with current variables values (the function is used while solving initial conditions loops)
Parameters:
A -
idxA -

putPhaseVectorForInitialConditions_xjal

@AnyLogicInternalCodegenAPI
public void putPhaseVectorForInitialConditions_xjal(double[] A,
 int idxA)
This method shouldn't be normally called by user.
Assigns variables values from the given arrays (the function is is used while solving initial conditions loops)
Parameters:
A -
idxA -

getRightPartForInitialConditions_xjal

@AnyLogicInternalCodegenAPI
public void getRightPartForInitialConditions_xjal(double[] AR,
 int idxAR)
This method shouldn't be normally called by user.
Returns right part while solving algebraic loops in initial conditions

assignInitialConditions_xjal

@AnyLogicInternalCodegenAPI
public void assignInitialConditions_xjal()
This method shouldn't be normally called by user.
This function assigns initial conditions for stocks and for flow aux variables

setupInitialConditions_xjal

@AnyLogicInternalCodegenAPI
public void setupInitialConditions_xjal(Class<?> callerClass)
This method shouldn't be normally called by user.

restoreCollection_xjal

@AnyLogicInternalAPI
@Deprecated
public final void restoreCollection_xjal(AgentList<?> collection)
Deprecated.
This method is internal and shouldn't be called by user.
it will be removed/renamed in future.

restoreOwner

@AnyLogicInternalCodegenAPI
@Deprecated
public void restoreOwner(Object owner)
Deprecated.
This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading
Specified by:
restoreOwner in interface com.anylogic.engine.internal.Child
Parameters:
owner - owner of this object, usually Agent, Experiment or ShapeGroup

tryExt

public final <T extends AgentExtension> T tryExt(Class<T> c)
Returns an extension of given type only if this object already contains such extension. Returns null when no such extension is defined
Parameters:
c - extension type, use one of EXT_* constants or your custom extension class (if any is defined)
Returns:
the extension object or null
See Also:
ext(Class)

ext

public final <T extends AgentExtension> T ext(Class<T> c)
Returns an extension of given type. Creates extension if not yet created. In some cases another method tryExt(Class) might be useful, e.g. for testing whether object has some extension or not -- without any implicit creation.
Note that when you define your custom extension class you should register it.
This method may throw error if requested extension is incompatible with extensions this object already has (e.g. requested "Discrete space Agent" while the object already has "Continuous space Agent" extension).
Users shouldn't store the reference to the returned extension. Instead, they should store the reference to the underlying agent and, in case of any need, call this method to obtain the extension. (Technical info: the reason of such limitation is that the agent, at any time, may get another extension which could override some methods implemented in the previously added extension) .
Parameters:
c - extension type, use one of EXT_* constants or your custom extension class (if any is defined)
Returns:
the extension object, never null
See Also:
tryExt(Class)

addExt_xjal

@AnyLogicInternalAPI
public void addExt_xjal(AgentExtension ext)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future

setupExt_xjal

@AnyLogicInternalCodegenAPI
public void setupExt_xjal(AgentExtension ext)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future

removeExt_xjal

@AnyLogicInternalAPI
public boolean removeExt_xjal(AgentExtension ext)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
This method removes the given extension if it is found in this agent and return true if it was successfully removed

isAgent

@AnyLogicLegacyAPI
public boolean isAgent()
Returns true if this is at least an informational agent (may be with or without spatial properties). Returns false if this is not an agent yet
Returns:
true if this object is an agent
See Also:
getAgentSpaceType()

isEnvironment

@AnyLogicLegacyAPI
public boolean isEnvironment()
Returns true if this is an environment for agents (at least informational environment). Returns false if this object doesn't define any environment yet
Returns:
true if this object is an environment for agents
See Also:
getEnvironmentSpaceType()

setAgentSpaceType

@AnyLogicInternalCodegenAPI
public void setAgentSpaceType(SpaceType spaceType)
Sets this agent to use the space of the given type.
Will throw an error if agent already has different space type
Parameters:
spaceType - type of agent space type, one of SPACE_* constants

getAgentSpaceType

public SpaceType getAgentSpaceType()
Returns agent space type, if this is an agent and it has spatial information. Returns SPACE_UNDEFINED if there is no agent spatial information defined in this object
Returns:
space type of agent, one of SPACE_* constants

getEnvironmentSpaceType

public SpaceType getEnvironmentSpaceType()
Returns agent space type, if this is an environment and it has spatial information. Returns SPACE_UNDEFINED if there is no environment spatial information defined in this object
Returns:
space type of environment, one of SPACE_* constants

onBeforeStepEnvironment

@AnyLogicInternalCodegenAPI
public void onBeforeStepEnvironment()
A callback that is called at the beginning of every step before the agents are asked to perform any their step actions. Should be defined in a subclass if an action is needed.

onAfterStepEnvironment

@AnyLogicInternalCodegenAPI
public void onAfterStepEnvironment()
A callback that is called when at the end of every step after the agents have performed all their step actions. Should be defined in a subclass if an action is needed.

agents

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

randomAgentInside

public 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

public 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

disableSteps

public void disableSteps()
Disables time steps.

enableSteps

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

areStepsEnabled

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

deliverToAllAgentsInside

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

deliverToRandomAgentInside

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

setNetworkUserDefined

public 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

public 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

public 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

public 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 neighbours

setNetworkScaleFree

public 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

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

getNetworkConnectionsPerAgent

public 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

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

getNetworkScaleFreeM

public 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

applyNetwork

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

applyNetwork

public 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

spaceWidth

public double spaceWidth()
Returns the width of environment continuous or discrete space.
Returns:
the width of environment space

spaceHeight

public double spaceHeight()
Returns the height of environment continuous or discrete space.
Returns:
the height of environment space

spaceCellWidth

public double spaceCellWidth()
Returns the width of the cell in discrete space.
Returns:
the width of the cell in discrete space

spaceCellHeight

public double spaceCellHeight()
Returns the height of the cell in discrete space.
Returns:
the height of the cell in discrete space

setNetworkAllInRange

public void setNetworkAllInRange(double connectionRange)
Sets network type to the one when agents are connected if the distance between them is not longer that a given one. This network type is only possible in continuous space. Call applyNetwork() to actually create network connections.
Parameters:
connectionRange - the maximum distance between connected agents
In case of GIS space, measured in meters

getNetworkConnectionRange

public double getNetworkConnectionRange()
Returns the range of agent connections. Applies to "all in range" network.
In case of GIS space, it is measured in meters
Returns:
the range of agent connections

setLayoutType

public void setLayoutType(LayoutType type)
Sets the layout type. To apply the layout call applyLayout(). The default layout is LAYOUT_USER_DEFINED, i.e. arbitrary.
Parameters:
type - the new layout type

getLayoutType

public LayoutType getLayoutType()
Returns the layout type. Note that this type has not necessarily been applied.
Returns:
the layout type

applyLayout

public void applyLayout()
Rearranges agents in this environment according to the selected layout type.
See Also:
setLayoutType(LayoutType)

setupSpace

public void setupSpace(double width,
 double height,
 double zHeight)
Sets the space to the given dimensions. The dimension are used only when various layouts are applied and do not restrict the location or movement of the agents.
This method should only be called when the environment is empty.
Parameters:
width - the width of the space
height - the height of the space
zHeight - the height of the space along Z-axis

setupSpace

public void setupSpace(double width,
 double height)
Sets the space to the given dimensions. The dimension are used only when various layouts are applied and do not restrict the location or movement of the agents.
This method should only be called when the environment is empty.
Parameters:
width - the width of the space
height - the height of the space

spaceZHeight

public double spaceZHeight()
Returns the height of environment space along Z-axis.
Returns:
the z-height of environment space

randomPointOfSpace

public Point randomPointOfSpace()
Returns the random location inside within the space bounds of this environment
Returns:
the random location inside within the space bounds of this environment

setupSpace

public void setupSpace(double width,
 double height,
 int rows,
 int columns,
 NeighborhoodType neighborhoodType)
Sets the space type to discrete with the given dimensions and neighbourhood type. A cell in such environment will have a size of (width/columns) by (height/rows).
This method should only be called when the environment is empty.
Parameters:
width - the width of the space
height - the height of the space
rows - the number of rows in the space
columns - the number of columns in the space
neighborhoodType - the type of neighbourhood (Euclidean, Moore)

spaceRows

public int spaceRows()
Returns the number of rows in the space.
Returns:
the number of rows in the space

spaceColumns

public int spaceColumns()
Returns the number of columns in the space.
Returns:
the number of columns in the space

randomEmptyCell

public CellPosition randomEmptyCell()
Tries to find a pseudo-randomly located empty cell and return its row and column in the array with two elements.
The current implementation is 100% fairly random.
Returns:
the cell position (row and column) of the empty cell, or null

getAgentAtCell

public Agent getAgentAtCell(int r,
 int c)
Returns the agent located in the cell with a given row and column, or null.
Parameters:
r - the row of the cell
c - the column of the cell
Returns:
the agent at (r,c) or null

setupSpace

public void setupSpace(AbstractShapeGISMap gisMap)
Sets the environment to have GIS space to be based on given gisMap. This method should only be called when the environment is empty.
Throws error if environment has space type different from GIS.
Parameters:
gisMap - the GIS map to use in this environment, should not be null

getGISMap

public AbstractShapeGISMap getGISMap()
Returns AbstractShapeGISMap object used in this GIS environment.
Throws error if environment has space type different from GIS.
Returns:
GIS map object used in this environment
Note, that returned object has the base GIS map type and for additional services it needs to be casted to ShapeGISMap

onBeforeStep

@AnyLogicInternalCodegenAPI
public void onBeforeStep()
A callback that is called at the beginning of every step in discrete time before onStep() of any agent is called. Can be used as a preparatory action if two-phase steps. Should be defined in a subclass if an action is needed.

onStep

@AnyLogicInternalCodegenAPI
public void onStep()
A callback that is called at every step in discrete time after onStep() of any agent is called. Should be defined in a subclass if an action is needed.

onReceive

@AnyLogicInternalCodegenAPI
public void onReceive(Object msg,
 Agent sender)
A callback that is called when the agent receives a message from another agent. Should be defined in a subclass if reaction is needed.

onArrival

@AnyLogicInternalCodegenAPI
public void onArrival()
A callback that is called when the agent arrives to the target location after movement initiated by moveTo() in continuous 2D space. Should be defined in a subclass if reaction is needed.

setEnvironment

public void setEnvironment(Agent env)
Sets up time, space, etc. type for the agent. Must be called during the startup of the agent and provide the environment where the agent belongs to as a parameter.
Parameters:
env - the agent's environment

getEnvironment

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

getConnections

public <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

restoreConnections_xjal

@AnyLogicInternalAPI
@Deprecated
public void restoreConnections_xjal(List<?> connections)
Deprecated.
This method should not be called by user
This method restores connections of this agent
Parameters:
connections - list of connections, may be null

getConnectionsNumber

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

getConnectedAgent

public 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

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

connectTo

public 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

isConnectedTo

public 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

disconnectFrom

public 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

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

send

public 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

sendToAll

public void sendToAll(Object msg)
Sends a message to all agents in the same environment this agent lives in. 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
Since:
7.0

sendToRandom

public void sendToRandom(Object msg)
Sends a message to a randomly chosen agent in the same environment this agent lives in. 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
Since:
7.0

sendToAllConnected

public void sendToAllConnected(Object msg)
Sends a message to all connected agents. 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
Since:
7.0

sendToRandomConnected

public void sendToRandomConnected(Object msg)
Sends a message to a randomly chosen connected 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
Since:
7.0

sendToAllNeighbors

public void sendToAllNeighbors(Object msg)
Sends a message to all neighbors. Available only if this agent lives in discrete space environment. 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
Since:
7.0

sendToRandomNeighbor

public void sendToRandomNeighbor(Object msg)
Sends a message to a randomly chosen neighbor. Available only if this agent lives in discrete space environment. 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
Since:
7.0

send

public 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

public 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

deliverToAllConnected

public void deliverToAllConnected(Object msg)
Delivers a message to all connected agents. If you wish this to happen in a separate event, use sendToAllConnected(Object) method.
Parameters:
msg - the message
Since:
7.0

deliverToRandomConnected

public void deliverToRandomConnected(Object msg)
Delivers a message to a randomly chosen connected agent. If you wish this to happen in a separate event, use sendToRandomConnected(Object) method.
Parameters:
msg - a message
Since:
7.0

deliverToAllNeighbors

public void deliverToAllNeighbors(Object msg)
Delivers a message to all neighbors. If you wish this to happen in a separate event, use sendToAllNeighbors(Object) method.
Parameters:
msg - the message
Since:
7.0

deliverToRandomNeighbor

public void deliverToRandomNeighbor(Object msg)
Delivers a message to a randomly chosen neighbor. If you wish this to happen in a separate event, use sendToRandomNeighbor(Object) method.
Parameters:
msg - a message
Since:
7.0

deliver

public 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

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

agentInfo

public String agentInfo()

setSpace

public void setSpace(Agent space)
Sets the space for agent. Shouldn't be called for moving agents. Coordinates and rotations are left "as is"
Parameters:
space - the agent representing space this agent will live in

getSpace

public Agent getSpace()
Returns the agent representing space this agent lives in
Returns:
the agent representing space this agent lives in

getPresentationScaleOnOwnerSpace

@AnyLogicInternalCodegenAPI
public double getPresentationScaleOnOwnerSpace()
Returns the scale of the agent presentation animation on its space or 1.0 if space isn't defined
Returns:
the scale of presentation animation on owner space

getX

public double getX()
Returns the current (up-to-date) x coordinate of the agent in continuous space.
Returns:
the x coordinate in continuous space
In case of GIS environment this is the latitude of the current location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

getY

public double getY()
Returns the current (up-to-date) y coordinate of the agent in continuous space.
Returns:
the y coordinate in continuous space
In case of GIS environment this is the longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

getXYZ

public Point getXYZ()
Returns the current (up-to-date) x, y (and z in case of 3D space) coordinate of the agent in continuous space.
Returns:
the Point object containing coordinates in continuous space
In case of GIS environment the returned point.x is the latitude of the current location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90), point.y is the longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180), and point.z is set to 0

getXYZ

public Point getXYZ(Point out)
Returns the current (up-to-date) x, y (and z in case of 3D space) coordinate of the agent in continuous space.
Parameters:
out - the point object which will be used to write coordinates to (may be null)
Returns:
the Point object containing coordinates in continuous space
In case of GIS environment the returned point.x is the latitude of the current location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90), point.y is the longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180), and point.z is set to 0

getPosition

public Position getPosition()
Returns the current (up-to-date) x, y (and z in case of 3D space) coordinate of the agent in continuous space and its orientation as well.
Returns:
the Position object containing coordinates and orientation in continuous space
In case of GIS environment the returned point.x is the latitude of the current location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90), point.y is the longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180), and point.z is set to 0

getPosition

public Position getPosition(Position out)
Returns the current (up-to-date) x, y (and z in case of 3D space) coordinate of the agent in continuous space and its orientation as well.
Parameters:
out - the Position object for the output, may be null
Returns:
the Position object containing coordinates and orientation in continuous space
In case of GIS environment the returned point.x is the latitude of the current location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90), point.y is the longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180), and point.z is set to 0

getRotation

public double getRotation()
Returns the current rotation angle (in radians) of the agent in continuous 3D space or GIS space. If rotation is not frozen (see isAutomaticHorizontalRotation(), setAutomaticHorizontalRotation(boolean)), the rotation changes each time the agent starts moving and also changes multiple times during movement in GIS space.
Returns:
the current rotation of the agent in radians (measured from animation point (1, 0), CW around (0, 0) point)

setRotation

public void setRotation(double rotation)
Sets the rotation angle (in radians) of the agent animation in continuous 3D space or GIS space. Depending on automatic rotation setting, this rotation value may be overridden during the next call of moveTo() or during current movement (if any exists).
Parameters:
rotation - the rotation angle of the agent in radians (measured from animation point (1, 0), CW around (0, 0) point)
See Also:

setAutomaticHorizontalRotation

public void setAutomaticHorizontalRotation(boolean yes)
Tells agent to rotate automatically during movements.
Parameters:
yes - true - agent will be rotated during movement, false - rotation will not be changed
See Also:
setRotation(double)

isAutomaticHorizontalRotation

public boolean isAutomaticHorizontalRotation()
Returns true if agent is set to be rotated during movement, false otherwise
Returns:
true if agent is set to be rotated during movement
See Also:

getNearestAgent

public final <T extends Agent> T getNearestAgent(Iterable<T> agents)
Returns the nearest agent from the given collection
Parameters:
agents - the collection of agents
Returns:
the nearest agent (never this one) or null if the collection is empty

getNearestAgentByRoute

public final <T extends Agent> T getNearestAgentByRoute(Iterable<T> agents)
Returns the nearest agent from the given collection. Distance between agents is calculated by route provider. Only for agents in GIS environment.
Parameters:
agents - the collection of agents
Returns:
the nearest agent (never this one) or null if the collection is empty

moveToNearestAgent

public void moveToNearestAgent(Iterable<? extends Agent> agents)
Starts movement to the nearest agent from the given collection. Stops any current movement.
Parameters:
agents - the collection of agents

moveToNearestAgent

public void moveToNearestAgent(Iterable<? extends Agent> agents,
 double tripTime)
Starts movement to the nearest agent from the given collection. Stops any current movement.
Changes the speed of the agent in order to reach target in tripTime model time units.
Parameters:
agents - the collection of agents
tripTime - the time of the movement trip

agentsInRange

public final <T extends Agent> List<T> agentsInRange(Iterable<T> agents,
 double distance)
Returns the unsorted list of agents from the given collection which are within the given distance from this agent
Parameters:
agents - the collection of agents
distance - the distance to search within
Returns:
the list of agents within the given distance, unsorted

agentsInRange

public final <T extends Agent> List<T> agentsInRange(Iterable<T> agents,
 double distanceInUnits,
 LengthUnits units)
Returns the unsorted list of agents from the given collection which are within the given distance from this agent
Parameters:
agents - the collection of agents
distanceInUnits - the distance to search within
units - the units of length
Returns:
the list of agents within the given distance, unsorted

agentsInRange

public List<? extends Agent> agentsInRange(double distance)
Returns the unsorted list of agents (from the population this agent lives in), which are within the given distance from this agent
Parameters:
distance - the distance to search within
Returns:
the list of agents within the given distance, unsorted

agentsInRange

public List<? extends Agent> agentsInRange(double distanceInUnits,
 LengthUnits units)
Returns the unsorted list of agents (from the population this agent lives in), which are within the given distance from this agent
Parameters:
distanceInUnits - the distance to search within
units - the units of length
Returns:
the list of agents within the given distance, unsorted

setXY

public void setXY(double x,
 double y)
Sets the coordinates of the agent location. Should only be used to initialize the agent location. Assumes the agent is not moving.
Parameters:
x - the x coordinate of the location
In case of GIS environment this is the latitude of the location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
y - the y coordinate of the location
In case of GIS environment this is the longitude of the location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

setLatLon

public void setLatLon(double latitude,
 double longitude)
Sets the coordinates of the agent location. Should only be used to initialize the agent location. Assumes the agent is not moving.
Parameters:
latitude - the latitude coordinate of the location measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
longitude - the longitude coordinate of the location measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

isSpacePositionSet_xjal

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

getTargetX

public double getTargetX()
Returns the x of the target location if moving, otherwise current x in continuous 3D space or GIS space.
In case of GIS environment this is the latitude, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
Returns:
the x of the target location if moving, otherwise current x

getTargetY

public double getTargetY()
Returns the y of the target location if moving, otherwise current y in continuous 3D space or GIS space.
In case of GIS environment this is the longitude, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
Returns:
the y of the target location if moving, otherwise current y

distanceTo

public double distanceTo(Agent other)
Calculates the distance from this agent to another one in continuous 3D space or GIS space.
In case of GIS environment returns distance measured in meters
Parameters:
other - another agent
Returns:
the distance to the other agent

distanceTo

public double distanceTo(Agent other,
 LengthUnits units)
Calculates the distance from this agent to another one in continuous 3D space or GIS space.
In case of GIS environment returns distance measured in meters
Parameters:
other - another agent
units - the units of length
Returns:
the distance to the other agent

distanceByRoute

public double distanceByRoute(Agent other)
Calculates the distance from this agent to another one by route.
Only for agents in GIS environment.
Parameters:
other - another agent
Returns:
the distance to the other agent

distanceTo

public double distanceTo(double x,
 double y)
Calculates the distance from this agent to a given point in continuous 3D or GIS space.
Parameters:
x - the x coordinate of the point.
In case of GIS environment this is the latitude of the point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
y - the y coordinate of the point.
In case of GIS environment this is the longitude of the point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
Returns:
the distance to the point (x,y)

distanceTo

public double distanceTo(double x,
 double y,
 LengthUnits units)
Calculates the distance from this agent to a given point in continuous 3D or GIS space.
Parameters:
x - the x coordinate of the point.
In case of GIS environment this is the latitude of the point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
y - the y coordinate of the point.
In case of GIS environment this is the longitude of the point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
Returns:
the distance to the point (x,y)

jumpTo

public void jumpTo(double x,
 double y)
Instantly moves the agent to a given location in continuous 3D or GIS space. Terminates any movement.
Doesn't call "on arrival" code
Parameters:
x - the x coordinate of the new location.
In case of GIS environment this is the latitude of the new location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
y - the y coordinate of the new location
In case of GIS environment this is the longitude of the new location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

moveToStraight

public void moveToStraight(double x,
 double y)
Starts straight movement (ignoring network/routes) in the direction of the given target location.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the point.
In case of GIS environment this is the latitude of the point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
y - the y coordinate of the point.
In case of GIS environment this is the longitude of the point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
Since:
7.1.1

moveToStraight

public void moveToStraight(Point location)
Starts straight movement (ignoring network/routes) in the direction of the given target location.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location
Since:
7.1

moveToStraight

public void moveToStraight(Agent agent)
Starts straight movement (ignoring network/routes) in the direction of the given agent.
"On arrival" code is executed when movement is finished.
Parameters:
agent -
Since:
7.1.1

moveToStraightInTime

public void moveToStraightInTime(Point location,
 double tripTime)
Starts straight movement (ignoring network/routes) in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location
tripTime - the time of the movement trip
Since:
7.1

moveToStraightInTime

public void moveToStraightInTime(Point location,
 double tripTime,
 TimeUnits units)
Starts straight movement (ignoring network/routes) in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveTo

public void moveTo(double x,
 double y)
Starts movement in the direction of the given target location in continuous 3D or GIS space.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location.
In case of GIS environment this is the latitude of the target location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
y - the y coordinate of the target location
In case of GIS environment this is the longitude of the target location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

moveToInTime

public void moveToInTime(double x,
 double y,
 double tripTime)
Starts movement in the direction of the given target location in continuous 3D or GIS space.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location.
In case of GIS environment this is the longitude of the target location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
tripTime - the time of the movement trip In case of GIS environment this is the latitude of the target location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
y - the y coordinate of the target location

moveToInTime

public void moveToInTime(double x,
 double y,
 double tripTime,
 TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D or GIS space.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location.
In case of GIS environment this is the latitude of the target location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
y - the y coordinate of the target location
In case of GIS environment this is the longitude of the target location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
tripTime - the time of the movement trip
units - the time units
Since:
7.1

isMoving

public boolean isMoving()
Tests if the agent is currently moving in continuous 3D space or GIS space.
Returns:
true if the agent is moving, false otherwise

stop

public void stop()
Stops movement in continuous 3D or GIS space.

setVelocity

@AnyLogicLegacyAPI
@Deprecated
public void setVelocity(double v)
Deprecated.
this function is deprecated since AnyLogic 7.1. Please use setSpeed(double, SpeedUnits) instead
Changes speed of the agent in continuous space (measured in pixels per model-time-unit, and in GIS-based environments - in m/s).
If the agent is moving, it continues moving with the new speed. Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo() is called.
Parameters:
v - the new speed

getVelocity

@AnyLogicLegacyAPI
@Deprecated
public double getVelocity()
Deprecated.
this function is deprecated since AnyLogic 7.1. Please use getSpeed(SpeedUnits) instead
Returns the current value of the agent speed in continuous space. (measured in pixels per model-time-unit, and in GIS-based environments - in m/s).
Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo is called.
Returns:
the current value of agent speed

setSpeed

public void setSpeed(double speedInMPS)
Changes speed of the agent in continuous/GIS space (measured in meters per second).
If the agent is moving, it continues moving with the new speed. Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo() is called.
Parameters:
speedInMPS - the new speed, meters per second
Since:
7.1

setSpeed

public void setSpeed(double speedInUnits,
 SpeedUnits units)
Changes speed of the agent in continuous/GIS space (measured in the given units).
If the agent is moving, it continues moving with the new speed. Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo() is called.
Parameters:
v - the new speed
units - the units of speed
Since:
7.1

getSpeed

public double getSpeed(SpeedUnits units)
Returns the current value of the agent speed in continuous/GIS space. (measured in the given units).
Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo is called.
Parameters:
units - the units of speed
Returns:
the current value of agent speed
Since:
7.1

getSpeed

public double getSpeed()
Returns the current value of the agent speed in continuous/GIS space. (measured in meters per second).
Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo is called.
Returns:
the current value of agent speed, meters per second
Since:
7.1

timeToArrival

public final double timeToArrival()
Returns the time to arrival to the target location in continuous 2D space or GIS space, in model-time units.
If the agent is not moving, returns 0.
Returns:
the time to arrival to the target location, or 0

timeToArrival

public final double timeToArrival(TimeUnits units)
Returns the time to arrival to the target location in continuous 2D space or GIS space, in model-time units.
If the agent is not moving, returns 0.
Returns:
the time to arrival to the target location, or 0
Since:
7.1

getLevel

public Level getLevel()
Returns the level this agent lives in, actual for agents in continuous space.
Returns:
the level this agent lives in

setLevel

public void setLevel(Level level)
Sets this agent to live in the level, actual for agents in continuous space.
Parameters:
level - the level this agent will live in

getNetwork

public INetwork getNetwork()
Returns the network this agent lives in, actual for agents in continuous space.
Returns:
the network this agent lives in

setNetwork

public void setNetwork(INetwork network)
Sets this agent to live in the network, actual for agents in continuous and GIS space.
Parameters:
network - implementation of com.anylogic.engine.markup.INetwork interface

getNetworkNode

public INode getNetworkNode()
Returns the network node this agent currently is located in, actual for agents in continuous space.
Returns:
the network node this agent currently is located in

setNetworkNode

@Deprecated
@AnyLogicInternalAPI
public void setNetworkNode(INode node,
 Point position)
Deprecated.
Sets the current network location for the agent
Parameters:
node - the network node
position - (optional) location within node, may be null

setNetworkNode

@AnyLogicLegacyAPI
public void setNetworkNode(INode node)
Sets the current network location for the agent
Parameters:
node - the network node

setNetworkNode

@AnyLogicLegacyAPI
public void setNetworkNode(Attractor attractor)
Sets the current network location for the agent
Parameters:
attractor - the attractor

getZ

public double getZ()
Returns the current (up-to-date) z coordinate of the agent in continuous space.
Returns:
the z coordinate in continuous space

getTargetZ

public double getTargetZ()
Returns the z of the target location if moving, otherwise current z in continuous space.
Returns:
the z of the target location if moving, otherwise current z

setVerticalRotation

public void setVerticalRotation(double rotation)
Sets the vertical rotation (angle in radians), along Z-axis of the agent animation in 3D space. Depending on automatic vertical rotation setting, this rotation value may be overridden during the next call of moveTo() or during current movement (if any exists) along path/polyline.
Parameters:
rotation - the vertical rotation angle of the agent in radians
See Also:

getVerticalRotation

public double getVerticalRotation()
Returns the current vertical rotation angle of the agent in 3D space. If automatic vertical rotation mode is set, the rotation changes each time the agent starts moving and also changes multiple times during movement along polyline.
Returns:
the current rotation of the agent in radians around Y axis (CW from +Z to +X)

setAutomaticVerticalRotation

public void setAutomaticVerticalRotation(boolean yes)
Tells agent to rotate automatically (in vertical direction, along Z-axis) during movements in 3D.
Has no effect if isAutomaticHorizontalRotation() is false
Parameters:
yes - true - agent will be rotated during movement (e.g. box travelling on conveyor slope), false - rotation will not be changed (e.g. passenger going upstairs)
See Also:
setVerticalRotation(double)

isAutomaticVerticalRotation

public boolean isAutomaticVerticalRotation()
Returns true if agent is set to be rotated (in vertical direction, along Z-axis) during movement in 3D, false otherwise.
The returned value has no effect if isAutomaticHorizontalRotation() is false
Returns:
true if agent is set to be rotated during movement (e.g. box travelling on conveyor slope), false - rotation will not be changed (e.g. passenger going upstairs)
See Also:

setXYZ

public void setXYZ(Point location)
This method is used for initialization only, for dynamic assignment, please use jumpTo(double, double).
Sets the coordinates of the agent location in continuous 3D space.
Should only be used to initialize the agent location. Assumes the agent is not moving. If the agent is not in continuous 3D space, does nothing.
Parameters:
location - the location

setPosition

public void setPosition(Position position)
This method is used for initialization only, for dynamic assignment, please use jumpTo(double, double).
Sets the coordinates and orientation of the agent location.
Should only be used to initialize the agent location. Assumes the agent is not moving.
Parameters:
position - the location and orientation

setLocation

public void setLocation(Point point)
This method is used for initialization only, for dynamic assignment, please use jumpTo(Point).
Sets the coordinates of the agent location.
Should only be used to initialize the agent location. Assumes the agent is not moving.
Parameters:
point - the location

setLocation

public void setLocation(INode node)
This method is used for initialization only, for dynamic assignment, please use jumpTo(INode).
Sets the coordinates of the agent location and puts it into network node (if network is defined).
Should only be used to initialize the agent location. Assumes the agent is not moving.
Parameters:
node - the location

setLocationRandomInside

@AnyLogicInternalCodegenAPI
public void setLocationRandomInside(INode node)
This method is used for initialization only, for dynamic assignment, please use jumpTo(INode).
Sets the coordinates of the agent location to the randomly chosen point inside the given node and puts it into network node (if network is defined).
Should only be used to initialize the agent location. Assumes the agent is not moving.
Parameters:
node - the location
Since:
8.6.0

setLocation

public void setLocation(Attractor attractor)
Sets the current network location for the agent
Parameters:
attractor - the attractor

setXYZ

public void setXYZ(double x,
 double y,
 double z)
This method is used for initialization only, for dynamic assignment, please use jumpTo(double, double).
Sets the coordinates of the agent location in continuous 3D space.
Should only be used to initialize the agent location. Assumes the agent is not moving. If the agent is not in continuous 3D space, does nothing.
Parameters:
x - the x coordinate of the location
y - the y coordinate of the location
z - the z coordinate of the location

setLocation

public void setLocation(Agent agent)
Takes position of given agent and sets it to this agent.
Parameters:
agent - the agent

jumpTo

public void jumpTo(Point location)
Instantly moves the agent to a given location without. Terminates any movement.
Doesn't call "on arrival" code
Parameters:
location - the new location

jumpTo

public void jumpTo(INode node)
Instantly moves the agent to a given network location. Terminates any movement.
Doesn't call "on arrival" code
Parameters:
node - the network node.

jumpTo

public void jumpTo(INode node,
 Point location)
Instantly moves the agent to a given network location. Terminates any movement.
Doesn't call "on arrival" code
Parameters:
node - the network node.
location - (optional) location within node, may be null

jumpTo

public void jumpTo(double x,
 double y,
 double z)
Instantly moves the agent to a given location. Terminates any movement.
Doesn't call "on arrival" code
Parameters:
x - the x coordinate of the new location
y - the y coordinate of the new location
z - the z coordinate of the new location

jumpTo

public void jumpTo(String geographicPlace)
Finds first geographic point on the Earth and calls method jumpTo(latitude, longitude) with coordinates of the found point
Parameters:
geographicPlace - the name of place

moveTo

public void moveTo(Point location)
Starts movement in the direction of the given target location in continuous 3D.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location

moveTo

public void moveTo(Agent agent)
Starts movement in the direction of the given agent.
"On arrival" code is executed when movement is finished.
Parameters:
agent -

moveToInTime

public void moveToInTime(Agent agent,
 double tripTime)
Starts movement in the direction of the given agent.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
agent - the agent
tripTime - the time of the movement trip

moveToInTime

public void moveToInTime(Agent agent,
 double tripTime,
 TimeUnits units)
Starts movement in the direction of the given agent.
Changes the speed of the agent in order to reach target in tripTime.
"On arrival" code is executed when movement is finished.
Parameters:
agent - the agent
tripTime - the time of the movement trip
units - the units of time

moveTo

public void moveTo(String geographicPlace)
Finds first geographic point on the Earth and calls method moveTo(latitude, longitude) with coordinates of the found point
Parameters:
geographicPlace - the name of place

moveToInTime

public void moveToInTime(Point location,
 double tripTime)
Starts movement in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location
tripTime - the time of the movement trip

moveToInTime

public void moveToInTime(Point location,
 double tripTime,
 TimeUnits units)
Starts movement in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveTo

public void moveTo(INode node)
Starts movement to the given network node.
"On arrival" code is executed when movement is finished.
Parameters:
node - the network node.

moveTo

public void moveTo(INode node,
 Point location)
Starts movement to the given network node.
"On arrival" code is executed when movement is finished.
Parameters:
node - the network node.
location - (optional) location within node, may be null

moveToInTime

public void moveToInTime(INode node,
 double tripTime)
Starts movement to the given network node.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
node - the network node.
tripTime - the time of the movement trip

moveToInTime

public void moveToInTime(INode node,
 double tripTime,
 TimeUnits units)
Starts movement to the given network node.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
node - the network node.
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveToInTime

public void moveToInTime(INode node,
 Point location,
 double tripTime)
Starts movement to the given network node.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
node - the network node.
location - (optional) location within node, may be null
tripTime - the time of the movement trip

moveToInTime

public void moveToInTime(INode node,
 Point location,
 double tripTime,
 TimeUnits units)
Starts movement to the given network node.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
node - the network node.
location - (optional) location within node, may be null
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveTo

public void moveTo(Attractor attractor)
Starts movement to the given attractor.
"On arrival" code is executed when movement is finished.
Parameters:
attractor - the attractor.

moveToInTime

public void moveToInTime(Attractor attractor,
 double tripTime)
Starts movement to the given attractor.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
attractor - the attractor.
tripTime - the time of the movement trip

moveToInTime

public void moveToInTime(Attractor attractor,
 double tripTime,
 TimeUnits units)
Starts movement to the given attractor.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
attractor - the attractor.
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveToStraight

public void moveToStraight(double x,
 double y,
 double z)
Starts straight movement (ignoring network) in the direction of the given target location.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location

moveToStraightInTime

public void moveToStraightInTime(double x,
 double y,
 double z,
 double tripTime)
Starts straight movement (ignoring network) in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location
tripTime - the time of the movement trip
Since:
7.1

moveToStraightInTime

public void moveToStraightInTime(double x,
 double y,
 double z,
 double tripTime,
 TimeUnits units)
Starts straight movement (ignoring network) in the direction of the given target location.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveTo

public void moveTo(double x,
 double y,
 double z)
Starts movement in the direction of the given target location in continuous 3D.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location

moveToInTime

public void moveToInTime(double x,
 double y,
 double z,
 double tripTime)
Starts movement in the direction of the given target location in continuous 3D.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location
tripTime - the time of the movement trip

moveToInTime

public void moveToInTime(double x,
 double y,
 double z,
 double tripTime,
 TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveTo

@AnyLogicLegacyAPI
public void moveTo(double x,
 double y,
 Path2D path)
Starts movement in the direction of the given target location in continuous 3D space along a given path. Z coordinate of target (and path points) is the same as the current agent's Z coordinate. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
path - the polyline along which the agent will move

moveToInTime

@AnyLogicLegacyAPI
public void moveToInTime(double x,
 double y,
 Path2D path,
 double tripTime)
Starts movement in the direction of the given target location in continuous 3D space along a given path. Z coordinate of target (and path points) is the same as the current agent's Z coordinate. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
path - the polyline along which the agent will move
tripTime - the time of the movement trip

moveToInTime

@AnyLogicLegacyAPI
public void moveToInTime(double x,
 double y,
 Path2D path,
 double tripTime,
 TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D space along a given path. Z coordinate of target (and path points) is the same as the current agent's Z coordinate. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
path - the polyline along which the agent will move
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveTo

@AnyLogicLegacyAPI
public void moveTo(Point location,
 Path3D path)
Starts movement in the direction of the given target location in continuous 3D space along a given path. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location
path - the polyline along which the agent will move

moveToInTime

@AnyLogicLegacyAPI
public void moveToInTime(Point location,
 Path3D path,
 double tripTime)
Starts movement in the direction of the given target location in continuous 3D space along a given path. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location
path - the polyline along which the agent will move
tripTime - the time of the movement trip

moveToInTime

@AnyLogicLegacyAPI
public void moveToInTime(Point location,
 Path3D path,
 double tripTime,
 TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D space along a given path. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
location - the target location
path - the polyline along which the agent will move
tripTime - the time of the movement trip
units - the time units
Since:
7.1

moveTo

@AnyLogicLegacyAPI
public void moveTo(double x,
 double y,
 double z,
 Path3D path)
Starts movement in the direction of the given target location in continuous 3D space along a given path. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location
path - the polyline along which the agent will move

moveToInTime

@AnyLogicLegacyAPI
public void moveToInTime(double x,
 double y,
 double z,
 Path3D path,
 double tripTime)
Starts movement in the direction of the given target location in continuous 3D space along a given path. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location
path - the polyline along which the agent will move
tripTime - the time of the movement trip

moveToInTime

@AnyLogicLegacyAPI
public void moveToInTime(double x,
 double y,
 double z,
 Path3D path,
 double tripTime,
 TimeUnits units)
Starts movement in the direction of the given target location in continuous 3D space along a given path. If the agent is currently not on the path, it will first move to the closest point on the path. If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
Changes the speed of the agent in order to reach target in tripTime model time units.
"On arrival" code is executed when movement is finished.
Parameters:
x - the x coordinate of the target location
y - the y coordinate of the target location
z - the z coordinate of the target location
path - the polyline along which the agent will move
tripTime - the time of the movement trip
units - the time units
Since:
7.1

getRouteProvider

public IRouteProvider getRouteProvider()
Returns the provider of routes for agent movement
Returns:
the route provider
See Also:
IRouteProvider

setRouteProvider

public void setRouteProvider(IRouteProvider routeProvider)
Stops agent if it is moving. Sets the route provider for agent movement.
Parameters:
routeProvider - the route provider
See Also:
IRouteProvider

distanceTo

public double distanceTo(double x,
 double y,
 double z)
Calculates the distance from this agent to a given point in continuous space.
Parameters:
x - the x coordinate of the point
y - the y coordinate of the point
z - the z coordinate of the point
Returns:
the distance to the point (x,y,z)

distanceTo

public double distanceTo(double x,
 double y,
 double z,
 LengthUnits units)
Calculates the distance from this agent to a given point in continuous space.
Parameters:
x - the x coordinate of the point
y - the y coordinate of the point
z - the z coordinate of the point
units - the units of length
Returns:
the distance to the point (x,y,z)

distanceTo

public double distanceTo(Point p)
Calculates the distance from this agent to a given point.
Parameters:
p - the point
Returns:
the distance to the point

distanceTo

public double distanceTo(Point p,
 LengthUnits units)
Calculates the distance from this agent to a given point.
Parameters:
p - the point
units - the units of length
Returns:
the distance to the point

getLat

@Deprecated
public double getLat()
Deprecated.
use getLatitude()
Returns the current (up-to-date) latitude of the agent in continuous GIS space.
Returns:
the latitude of the current location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

getLon

@Deprecated
public double getLon()
Deprecated.
use getLongitude()
Returns the current (up-to-date) longitude of the agent in continuous GIS space.
Returns:
the longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

getLatitude

public double getLatitude()
Returns the current (up-to-date) latitude of the agent in continuous GIS space.
Returns:
the latitude of the current location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

getLongitude

public double getLongitude()
Returns the current (up-to-date) longitude of the agent in continuous GIS space.
Returns:
the longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

getTargetLon

public double getTargetLon()
Returns the longitude of the target location if moving, otherwise current longitude in GIS space, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
Returns:
the longitude of the target location if moving, otherwise current longitude

getTargetLat

public double getTargetLat()
Returns the latitude of the target location if moving, otherwise current latitude in GIS space, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
Returns:
the latitude of the target location if moving, otherwise current latitude

getGISHeading

public double getGISHeading()
Returns current heading angle (measured in radians CW, starting from North direction) of agent moving in GIS space.
Returns:
the current GIS heading angle (measured in radians CW, starting from North direction)

getR

public int getR()
Returns the row of the agent's cell.
Returns:
the row of the agent's cell

getC

public int getC()
Returns the column of the agent's cell.
Returns:
the column of the agent's cell

setCell

public void setCell(int r,
 int c)
Puts the agent into a given cell. Should only be used to initialize the agent location. Agent is put into the given cell of discrete 2D environment (it is assumed the cell is empty, and the agent has not yet been assigned a cell).
Parameters:
r - the row of the cell
c - the column of the cell

jumpToCell

public void jumpToCell(int r,
 int c)
Moves the agent into a cell with the given row and column. Raises error if that cell is nonempty.
Parameters:
r - the row of the new cell
c - the column of the new cell

moveToNextCell

public void moveToNextCell(CellDirection dir)
Moves the agent to an adjacent cell in a given direction.
Parameters:
dir - the direction (NORTH, SOUTH, ..., NORTHEAST, ...)

isNextCellInsideSpace

public boolean isNextCellInsideSpace(CellDirection dir)
Returns true if there is an adjacent cell in a given direction. Note that the cell may be occupied by some agent.
Returns false if going in a given direction will push agent outside the discrete space grid (e.g. moveToNextCell(CellDirection) will throw error in such case)
Parameters:
dir - the direction (NORTH, SOUTH, ..., NORTHEAST, ...)
Returns:
whether the adjacent cell in the given direction exists (true) in the discrete space grid, or not (false)

swapWithCell

public void swapWithCell(int r,
 int c)
Swaps this agent with an agent at the cell with the given row and column. That cell may be empty - is this case simply moves the agent there.
Parameters:
r - the row of the new cell
c - the column of the new cell

swapWithNextCell

public void swapWithNextCell(CellDirection dir)
Swaps the agent with an agent at the adjacent cell in a given direction.
Parameters:
dir - the direction (NORTH, SOUTH, ..., NORTHEAST, ...)

swapWithAgent

public void swapWithAgent(Agent anotherAgent)
Swaps the cell location of this agent with another agent.
Parameters:
anotherAgent - agent to swap cell location with. Should be located on the same environment

jumpToRandomEmptyCell

public boolean jumpToRandomEmptyCell()
Finds a random empty cell and places the agent there. If there is no empty cell, does nothing.
Returns:
true if empty cell was found and agent was moved there, otherwise false

getAgentNextToMe

public Agent getAgentNextToMe(CellDirection dir)
Returns the agent next to this agent in a given direction, if any.
Parameters:
dir - the direction (NORTH, SOUTH, ..., NORTHEAST, ...)
Returns:
the agent next to this agent in a given direction, or null

getNeighbors

public Agent[] getNeighbors()
Returns the array of neighbor agents, subject to the current neighborhood type (Euclidean - {N,S,E,W}, Moore - also {..,NW,NW,SE,SW})
Returns:
the array of neighbor agents, or null if there are none

onEnterFlowchartBlock

@AnyLogicInternalCodegenAPI
public void onEnterFlowchartBlock(Agent oldBlock,
 Agent block)
A callback that is called when the agent enters flowchart block (being an 'entity')

onExitFlowchartBlock

@AnyLogicInternalCodegenAPI
public void onExitFlowchartBlock(Agent block)
A callback that is called when the agent exits flowchart block (being an 'entity')

onSeizeResource

@AnyLogicInternalCodegenAPI
public void onSeizeResource(Agent unit)
A callback that is called when the agent seizes resource

onReleaseResource

@AnyLogicInternalCodegenAPI
public void onReleaseResource(Agent unit)
A callback that is called when the agent releases resource

highlight

public void highlight(boolean yes)
Turns on/off highlighting of this agent animation. The behavior of the function is specific and usually depends on the library which drives this agent
Parameters:
yes - true for highlighted status, false for regular

getFlowchartEntryTime

public double getFlowchartEntryTime()
Returns the time the entity has entered the first block in the flowchart, or Double.NaN if this agent hasn't yet visited any flowchart
Returns:
time or Double.NaN

addAgentToContents

public void addAgentToContents(Agent agent)
Adds a given agent to the contents of this agent.
Parameters:
agent - the agent to add

addEntityToContents

@Deprecated
public void addEntityToContents(Agent agent)
Deprecated.

removeAgentFromContents

public boolean removeAgentFromContents(Agent agent)
Removes the given agent from the contents of this agent.
Parameters:
agent - the agent to remove
Returns:
returns true if agent was removed, false if this agent didn't contain the specified agent

removeEntityFromContents

@Deprecated
public boolean removeEntityFromContents(Agent agent)
Deprecated.

getLength

public double getLength()
Returns the length of the agent (measured in meters) - used by conveyors and other blocks which require it during processing.
Returns:
the length of the agent

getLength

public double getLength(LengthUnits units)
Returns the length of the agent (measured in the given units) - used by conveyors and other blocks which require it during processing.
Parameters:
units - the units of length
Returns:
the length of the agent
Since:
7.1

setLength

public void setLength(double lengthInMeters)
Sets the length of the agent. This function only affects agents driven by Material Handling and Process Modeling libraries (e.g. on conveyors). For pedestrians, cars, and other specific agents, please use custom setter of the agent extension, e.g., setDiameter.
Parameters:
lengthInMeters - the length, measured in the meters

setLength

public void setLength(double lengthInUnits,
 LengthUnits units)
Sets the length of the agent. This function only affects agents driven by Material Handling and Process Modeling libraries (e.g. on conveyors). For pedestrians, cars, and other specific agents, please use custom setter of the agent extension, e.g., setDiameter.
Parameters:
length - the length, measured in the given units
units - the units of length
Since:
7.1

getWidth

public double getWidth()
Returns the width of the agent (measured in meters) - used by conveyors and other blocks which require it during processing.
Returns:
the width of the agent
Since:
8.2

getWidth

public double getWidth(LengthUnits units)
Returns the width of the agent (measured in the given units) - used by conveyors and other blocks which require it during processing.
Parameters:
units - the units of length
Returns:
the width of the agent
Since:
8.2

setWidth

public void setWidth(double widthInMeters)
Sets the width of the agent
Parameters:
widthInMeters - the width, measured in the meters
Since:
8.2

setWidth

public void setWidth(double widthInUnits,
 LengthUnits units)
Sets the width of the agent
Parameters:
widthInUnits - the width, measured in the given units
units - the units of length
Since:
8.2

getHeight

public double getHeight()
Returns the height of the agent (measured in meters) - used by conveyors and other blocks which require it during processing.
Returns:
the height of the agent
Since:
8.2

getHeight

public double getHeight(LengthUnits units)
Returns the height of the agent (measured in the given units) - used by conveyors and other blocks which require it during processing.
Parameters:
units - the units of length
Returns:
the height of the agent
Since:
8.2

setHeight

public void setHeight(double heightInMeters)
Sets the height of the agent
Parameters:
heightInMeters - the height, measured in the meters
Since:
8.2

setHeight

public void setHeight(double heightInUnits,
 LengthUnits units)
Sets the height of the agent
Parameters:
heightInUnits - the height, measured in the given units
units - the units of length
Since:
8.2

setDimensions

public void setDimensions(double lengthInMeters,
 double widthInMeters,
 double heightInMeters)
Sets the length, width, height of the agent
Parameters:
lengthInMeters - the length, measured in the meters
widthInMeters - the width, measured in the meters
heightInMeters - the height, measured in the meters
Since:
8.3

setDimensions

public void setDimensions(double lengthInUnits,
 double widthInUnits,
 double heightInUnits,
 LengthUnits units)
Sets the length, width, height of the agent
Parameters:
lengthInUnits - the length, measured in the given units
widthInUnits - the width, measured in the given units
heightInUnits - the height, measured in the given units
units - the units of length
Since:
8.3

contents

public <T extends Agent> List<T> contents()

resourceUnits

public <T extends Agent> List<T> resourceUnits()
Returns the list of resource units seized by the entity, or empty list if there are none.
Returns:
the list of resource units seized by the entity, never returns null

resourceUnitsOfSeize

public <T extends Agent> List<T> resourceUnitsOfSeize(Agent seize)
Return resource units currently seized by this entity in the given Seize block
Parameters:
seize - Seize block
Returns:
resource units currently seized by this entity

resourceUnitsOfPool

public <T extends Agent> List<T> resourceUnitsOfPool(Agent pool)
Returns resource units currently seized by this entity from the given ResourcePool block
Parameters:
pool - ResourcePool block
Returns:
resource units currently seized by this entity

resourceUnitOfPool

public Agent resourceUnitOfPool(Agent pool)
Returns the first occurrence of resource unit of a given pool among the seized resource units, or null if not found.
Parameters:
pool - the pool of the unit (ResourcePool block)
Returns:
the seized resource unit from the given pool, if found

currentBlock

public FlowchartBlock currentBlock()
Returns the current flowchart block this agent is being processed in. This method is designed for agents which act as 'entities' in process flowchart diagrams.
Returns:
the current flowchart block containing this agent or null if the agent isn't in flowchart

getBlockEnterTime

public double getBlockEnterTime()
Returns the time this agent entered its current flowchart block.
Returns:
the time this agent entered its current flowchart block or Double.NaN if this agent isn't in the flowchart

setColor

public void setColor(Color color)
Sets the color of the item's default animation shape.
For custom agent type animation shapes, please use setFillColor and other setters.
Parameters:
color - the new color of the default shape

getColor

public Color getColor()
Returns the color of the item's default animation shape. The color may be set by using setColor(Color) or otherwise it will be chosen randomly.
Returns:
the color of the item default shape

getPresentationShape

@AnyLogicInternalCodegenAPI
public ShapeTopLevelPresentationGroup getPresentationShape()
Overrides:
getPresentationShape in class Presentable

getLinkToAgentStandard_xjal

@AnyLogicInternalAPI
public LinkToAgentCollection<? extends Agent,? extends Agent> getLinkToAgentStandard_xjal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.