com.xj.anylogic.engine
Class AgentContinuous

java.lang.Object
  extended by com.xj.anylogic.engine.Presentable
      extended by com.xj.anylogic.engine.Utilities
          extended by com.xj.anylogic.engine.ActiveObject
              extended by com.xj.anylogic.engine.Agent
                  extended by com.xj.anylogic.engine.AgentContinuous
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, java.io.Serializable
Direct Known Subclasses:
AgentContinuous2D, AgentContinuous3D, AgentContinuousGIS

public abstract class AgentContinuous
extends Agent

Base class for agents with continuous space. Use one of subclasses:

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.xj.anylogic.engine.Agent
ALL, ALL_CONNECTED, ALL_NEIGHBORS, EAST, NORTH, NORTHEAST, NORTHWEST, RANDOM, RANDOM_CONNECTED, RANDOM_NEIGHBOR, SOUTH, SOUTHEAST, SOUTHWEST, WEST
 
Fields inherited from class com.xj.anylogic.engine.ActiveObject
DRAW_PARAMETER_DYNAMIC, DRAW_SD_ARRAY, DRAW_SD_CONSTANT, DRAW_SD_EXTERNAL, DRAW_SD_LINK_DELAY, DRAW_SD_LINK_INITIAL, DRAW_SD_NEGATIVE, DRAW_SD_NO_SOURCE, DRAW_SD_NO_TARGET, DRAW_SD_PUBLIC_ONLY, DRAW_SD_SHADOW, DRAW_SD_ZERO, EVENT_TIMEOUT_MODE_CYCLIC, EVENT_TIMEOUT_MODE_ONCE, EVENT_TIMEOUT_MODE_USER
 
Fields inherited from class com.xj.anylogic.engine.Utilities
AM, APRIL, AUGUST, DAY, DECEMBER, FEBRUARY, FRIDAY, HOUR, infinity, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK, YEAR
 
Fields inherited from class com.xj.anylogic.engine.Presentable
ALIGNMENT_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, CAD_ANTIALIASING, CAD_INVERTED, LINE_STYLE_DASHED, LINE_STYLE_DOTTED, LINE_STYLE_SOLID, NAVIGATION_FULL, NAVIGATION_LIMITED_TO_Z_ABOVE_ZERO, NAVIGATION_NONE, NAVIGATION_ROTATION_ONLY, SHAPE_ARC, SHAPE_BUTTON, SHAPE_CAD, SHAPE_CHART_BAR, SHAPE_CHART_HISTOGRAM, SHAPE_CHART_HISTOGRAM2D, SHAPE_CHART_PIE, SHAPE_CHART_PLOT, SHAPE_CHART_STACK, SHAPE_CHART_TIME_COLOR, SHAPE_CHART_TIME_PLOT, SHAPE_CHART_TIME_STACK, SHAPE_CHECKBOX, SHAPE_COMBOBOX, SHAPE_CURVE, SHAPE_EMBEDDED_OBJECT, SHAPE_FILECHOOSER, SHAPE_GROUP, SHAPE_IMAGE, SHAPE_LINE, SHAPE_LISTBOX, SHAPE_OVAL, SHAPE_PIXEL, SHAPE_POLYLINE, SHAPE_PROGRESSBAR, SHAPE_RADIOBUTTONS, SHAPE_RECTANGLE, SHAPE_ROUNDED_RECTANGLE, SHAPE_SLIDER, SHAPE_TEXT, SHAPE_TEXTFIELD
 
Method Summary
abstract  double distanceTo(Agent other)
          Calculates the distance from this agent to another one in continuous 2D space or GIS space.
 AgentContinuous getConnectedAgent(int index)
          Returns the connected agent with a given index.
 java.util.LinkedList<? extends AgentContinuous> getConnections()
          Returns a collection of agents connected to this agent (bi-directionally), or null if there have not been any connections yet.
 EnvironmentContinuous<?> getEnvironment()
          Returns the environment where this agent belongs to.
 AgentContinuous getNearestAgent(java.lang.Iterable<? extends AgentContinuous> agents)
          Returns the nearest agent from the given collection
 double getRotation()
          Returns the current rotation angle (in radians) of the agent in continuous 2D space or GIS space.
 double getShapeRotation(int id, int index)
          Should be overridden to return the rotation angle of a non-persistent shape in radians.
 double getTargetX()
          Returns the x of the target location if moving, otherwise current x in continuous 2D space or GIS space.
 double getTargetY()
          Returns the y of the target location if moving, otherwise current y in continuous 2D space or GIS space.
 double getVelocity()
          Returns the current value of the agent velocity in continuous space.
 double getX()
          Returns the current (up-to-date) x coordinate of the agent in continuous space.
 double getY()
          Returns the current (up-to-date) y coordinate of the agent in continuous space.
 boolean isMoving()
          Tests if the agent is currently moving in continuous 2D space or GIS space.
 boolean isRotationFrozen()
          Returns true if rotation angle(s) of this Agent in continuous space is frozen, i.e.
 void moveToNearestAgent(java.lang.Iterable<? extends AgentContinuous> agents)
          Starts movement to the nearest agent from the given collection.
 void onArrival()
          A callback that is called when the agent arrives to the target location after movement initiated by moveTo() in continuous 2D space.
 void onDestroy()
          This method must be called when the agent is destroyed.
 void setVelocity(double v)
          Changes velocity of the agent in continuous space (measured in pixels per model-time-unit, and in GIS-based environments - in m/s).
 void stop()
          Stops movement in continuous 2D, 3D or GIS space, if any.
 double timeToArrival()
          Returns the time to arrival to the target location in continuous 2D space or GIS space, in model-time units.
 
Methods inherited from class com.xj.anylogic.engine.Agent
agentInfo, deliver, disconnectFrom, disconnectFromAll, getConnectionsNumber, getShapeX, getShapeY, isConnectedTo, onBeforeStep, onStep, receive, restoreConnections_xjal, send, setEnvironment
 
Methods inherited from class com.xj.anylogic.engine.ActiveObject
assignInitialConditions_xjal, create, drawActionChart, drawActionChartLink, drawAuxiliaryVariable, drawAuxiliaryVariable, drawBranchExit, drawBranchState, drawBreakBlock, drawCausalLoop, drawCodeBlock, drawConnector, drawDecisionBlock, drawDynamicEvent, drawEmbeddedObjectModel, drawEmbeddedObjectModel, drawEmbeddedObjectModelDefault, drawEmbeddedObjectModelDefault, drawEnvironment, drawEvent, drawFinalState, drawFlow, drawFlow, drawFlowStockDependencyLine, drawHistoryState, drawInitialStatePointer, drawLink, drawLink, drawLocalVariable, drawLoopArea, drawLoopBlock, drawParameter, drawParameter, drawPlainDependencyArc, drawPlainDependencyLine, drawPort, drawReturnBlock, drawSchedule, drawState, drawStatechartEntryPoint, drawStock, drawStock, drawTransition, enterState, error, evaluateRateOf, evaluateRateOf, evaluateTimeoutOf, evaluateTimeoutOf, executeActionOf, executeActionOf, executeActionOf, executeActionOf, executeActionOf, executeActionOf, executeActionOf, executeActionOf, executeActionOf, executeOnReceiveActionOf, executeOnSendActionOf, exitInnerStates, exitState, finishSimulation, formulasExecute_xjal, getCameras3D, getContainerStateOf, getDynamicEvents, getEmbeddedObjects, getEngine, getFirstOccurrenceTime, getFullName, getIndex, getIntegrationManager_xjal, getModeOf, getName, getNameOf, getNameOf, getNameOf, getNameOf, getNameOf, getNameOf, getNameOf, getNameOf, getNameOf, getNameOf, getNameOf, getNameOfState, getOwner, getOwnerShape, getPresentation, getReplicatedCollection, getReplicatedList, getScalarPhaseVector_xjal, getScalarPhaseVectorForInitialConditions_xjal, getScalarRightPart_xjal, getScalarRightPartForInitialConditions_xjal, getStatechartOf, getStatechartOf, getStatechartOf, getStatechartOf, isReplicated, nothingChanged, onChange, onCreate, onStartup, pauseSimulation, putScalarPhaseVector_xjal, putScalarPhaseVectorForInitialConditions_xjal, restoreOwner, runSimulation, setDestroyed, setEngine, setOwnerShape_xjal, setParametersToDefaultValues, setupPlainDependencyArc, start, stateContainsState, stopSimulation, testConditionOf, testConditionOf, testGuardOf, testGuardOf, testGuardOf, testGuardOf, testMessageOf, toString
 
Methods inherited from class com.xj.anylogic.engine.Utilities
bernoulli, bernoulli, beta, beta, beta, beta, beta, binomial, binomial, binomial, binomial, binomial, briefInfoOn, cauchy, cauchy, cauchy, chi2, chi2, chi2, copyToClipboard, createURL_xjal, date, dateToTime, day, difference, difference, differenceInDateUnits, differenceInDateUnits, dropTime, erlang, erlang, erlang, error, exponential, exponential, exponential, exponential, exponential, exponential, format, format, format, format, format, format, formatDayOfWeek, formatGeoHeading, formatLatitude, formatLongitude, formatMonth, formatTimeInterval, gamma_frac, gamma, gamma, gamma, gamma, gamma, gammaLog, geometric, geometric, getAmPm, getAmPm, getDayOfMonth, getDayOfMonth, getDayOfWeek, getDayOfWeek, getDayOfYear, getDefaultRandomGenerator, getDistance, getDistance, getDistanceFromPointToLine, getDistanceFromPointToLineSq, getDistanceFromPointToSegment, getDistanceFromPointToSegmentSq, getDistanceSq, getDistanceSq, getHour, getHour, getHourOfDay, getHourOfDay, getLength, getLength, getMillisecond, getMillisecond, getMinute, getMinute, getMonth, getMonth, getRandom, getRandom, getSecond, getSecond, getTime, getYear, getYear, gumbel1, gumbel1, gumbel2, gumbel2, hour, hypergeometric, hypergeometric, inspectOf, isLineIntersectingLine, isLineIntersectingRectangle, isPointInsideRectangle, isPointOnTheSameLine, laplace, laplace, limit, limitMax, limitMin, logarithmic, logarithmic, logistic, logistic, lognormal, lognormal, millisecond, minute, negativeBinomial, negativeBinomial, negativeBinomial, negativeBinomial, normal, normal, normal, normal, normal, normal, pareto, pareto, pareto, pert, pert, poisson, poisson, poisson, poisson, prepareBeforeExperimentStart_xjal, pulse, pulseTrain, quantum, ramp, randomFalse, randomFalse, randomTrue, randomTrue, rayleigh, rayleigh, rayleigh, second, setDefaultRandomGenerator, sqr, step, time, timeToDate, toDate, toDateInMillis, toLatitude, toLongitude, toTimeout, trace, traceln, traceln, traceln, triangular, triangular, triangular, triangular, triangular, uniform_discr, uniform_discr, uniform_discr, uniform_pos, uniform_pos, uniform, uniform, uniform, uniform, uniform, week, weibull, weibull, weibull, weibull, weibull, xidz, zidz
 
Methods inherited from class com.xj.anylogic.engine.Presentable
contains, drawCollection, drawDatabase, drawDataset, drawExcelFile, drawFunction, drawHistogram2DData, drawHistogramData, drawInsert, drawKeyValueTable, drawModel, drawModelElements, drawPlainVariable, drawPresentation, drawQuery, drawShape, drawStatistics, drawTableFunction, drawTextFile, drawUpdate, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, finishReadObject_xjal, getExperiment, getNameOfShape, getPersistentShape, getShapeArcAngle, getShapeArcAngle, getShapeArcStartAngle, getShapeArcStartAngle, getShapeCADCustomLayerColors, getShapeCADDrawingAttributes, getShapeCADDrawingAttributes, getShapeCADFileName, getShapeCADFileName, getShapeCADVisibleLayerNames, getShapeChartColorFromDouble, getShapeChartDataColors, getShapeChartDataItems, getShapeChartDataPlotOptions, getShapeChartDataSets, getShapeChartDataTitles, getShapeChartHistogram2DOptions, getShapeChartHistogramOptions, getShapeChartHistograms, getShapeChartHistograms2D, getShapeChartProperties, getShapeControl, getShapeControl, getShapeControlDefaultValueBoolean, getShapeControlDefaultValueBoolean, getShapeControlDefaultValueDouble, getShapeControlDefaultValueDouble, getShapeControlDefaultValueInt, getShapeControlDefaultValueInt, getShapeControlDefaultValueString, getShapeControlDefaultValueString, getShapeControlManager, getShapeControlMaximum, getShapeControlMaximum, getShapeControlMinimum, getShapeControlMinimum, getShapeControlMultipleSelectionMode, getShapeControlMultipleSelectionMode, getShapeControlProgressString, getShapeControlProgressString, getShapeControlTexts, getShapeControlTexts, getShapeControlTexts2D, getShapeControlTexts2D, getShapeControlType, getShapeControlType, getShapeControlValueType, getShapeControlValueType, getShapeEmbeddedObject, getShapeEmbeddedObject, getShapeFillColor, getShapeFillColor, getShapeFont, getShapeFont, getShapeGroupContent, getShapeHeight, getShapeHeight, getShapeImageFileNames, getShapeImageFileNames, getShapeImageNumber, getShapeImageNumber, getShapeLineColor, getShapeLineColor, getShapeLineDx, getShapeLineDx, getShapeLineDy, getShapeLineDy, getShapeLineStyle, getShapeLineStyle, getShapeLineWidth, getShapeLineWidth, getShapeNPoints, getShapeNPoints, getShapePackagePrefix, getShapePointsDx, getShapePointsDx, getShapePointsDy, getShapePointsDy, getShapeRadiusX, getShapeRadiusX, getShapeRadiusY, getShapeRadiusY, getShapeReplication, getShapeRotation, getShapeScaleX, getShapeScaleX, getShapeScaleY, getShapeScaleY, getShapeText, getShapeText, getShapeTextAlignment, getShapeTextAlignment, getShapeType, getShapeWidth, getShapeWidth, getShapeX, getShapeY, getViewAreas, iconContains, isShapeCADNegative, isShapeCADNegative, isShapeClosed, isShapeClosed, isShapeControlEnabled, isShapeControlEnabled, isShapeControlVertical, isShapeControlVertical, isShapePublic, isShapeVisible, isShapeWithManualControlPoints, isShapeWithManualControlPoints, modelElementContains, modelElementContains, onClickIconAt, onClickModelAt, onClickPresentationAt, onItemRemoved, onSelectionChanged, onShapeClick, onShapeClickAt, onShapeGroupDraw, presentationContains, readCustomData, setControlValueToDefault, setControlValueToDefault, writeCustomData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

onDestroy

public void onDestroy()
This method must be called when the agent is destroyed.

Overrides:
onDestroy in class Agent

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 longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

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 latitude of the current location, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

distanceTo

public abstract double distanceTo(Agent other)
Calculates the distance from this agent to another one in continuous 2D 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

stop

public void stop()
Stops movement in continuous 2D, 3D or GIS space, if any.


moveToNearestAgent

public void moveToNearestAgent(java.lang.Iterable<? extends AgentContinuous> agents)
Starts movement to the nearest agent from the given collection. Stops any current movement.

Parameters:
agents - the collection of agents

getNearestAgent

public final AgentContinuous getNearestAgent(java.lang.Iterable<? extends AgentContinuous> 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

isMoving

public boolean isMoving()
Tests if the agent is currently moving in continuous 2D space or GIS space.

Returns:
true if the agent is moving, false otherwise

setVelocity

public void setVelocity(double v)
Changes velocity 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 velocity. Note that nonzero velocity does not mean the agent is moving - it starts moving only after moveTo() is called.

Parameters:
v - the new velocity

getVelocity

public double getVelocity()
Returns the current value of the agent velocity in continuous space. (measured in pixels per model-time-unit, and in GIS-based environments - in m/s).
Note that nonzero velocity does not mean the agent is moving - it starts moving only after moveTo is called.

Returns:
the current value of agent velocity

getRotation

public double getRotation()
Returns the current rotation angle (in radians) of the agent in continuous 2D space or GIS space. If rotation is not frozen (see isRotationFrozen(), setRotation(double, 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)

isRotationFrozen

public boolean isRotationFrozen()
Returns true if rotation angle(s) of this Agent in continuous space is frozen, i.e. moveTo(double, double) calls cannot change rotation, which is currently set
By default, rotation is not frozen

Returns:
true if rotation angle(s) of this Agent is frozen, i.e. moveTo(double, double) calls cannot change rotation, which is currently set
See Also:
setRotation(double, boolean)

getTargetX

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

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 2D space or GIS space.
In case of GIS environment this is the latitude, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

Returns:
the y of the target location if moving, otherwise current y

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

onArrival

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.


getEnvironment

public EnvironmentContinuous<?> getEnvironment()
Description copied from class: Agent
Returns the environment where this agent belongs to.

Overrides:
getEnvironment in class Agent
Returns:
the environment where this agent belongs to

getConnectedAgent

public AgentContinuous getConnectedAgent(int index)
Description copied from class: Agent
Returns the connected agent with a given index.

Overrides:
getConnectedAgent in class Agent
Parameters:
index - the index of connection
Returns:
the connected agent with a given index

getConnections

public java.util.LinkedList<? extends AgentContinuous> getConnections()
Returns a collection of agents connected to this agent (bi-directionally), or null if there have not been any connections yet. You should not modify this collection.

Overrides:
getConnections in class Agent
Returns:
collection of connected agents, or null

getShapeRotation

public double getShapeRotation(int id,
                               int index)
Description copied from class: Presentable
Should be overridden to return the rotation angle of a non-persistent shape in radians.

Overrides:
getShapeRotation in class Presentable
Parameters:
id - the shape id
index - index of the shape (for replicated shapes)
Returns:
the rotation angle of the shape in radians, 0 by default


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.