com.xj.anylogic.engine
Class AgentDiscrete2D
java.lang.Object
com.xj.anylogic.engine.Presentable
com.xj.anylogic.engine.Utilities
com.xj.anylogic.engine.ActiveObject
com.xj.anylogic.engine.Agent
com.xj.anylogic.engine.AgentDiscrete2D
- All Implemented Interfaces:
- com.xj.anylogic.engine.internal.Child, java.io.Serializable
public class AgentDiscrete2D
- extends Agent
A subclass of ActiveObject designed to support agent based modeling in
discrete 2D space, in particular:
- time (continuous or discrete)
- 2D discrete space
- connections between agents, networks (e.g. social) and their visualization
- communication - message passing and broadcasting
A user-defined agent class should be a subclass of this class
in order to use those features.
If your model is agent based, but none of the above features are required,
it is recommended to use regular ActiveObject as a base class for your agents,
and not this class: Agent classes require 36+ bytes more memory than ActiveObject.
- Author:
- XJ Technologies Company Ltd. www.anylogic.com
- See Also:
- Serialized Form
| 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 |
void |
connectTo(AgentDiscrete2D a)
Creates a bi-directional connection between this agent and a given
other agent. |
void |
deliver(java.lang.Object msg,
AgentDiscrete2D dest)
Delivers a message to a given agent immediately during this method call. |
void |
deliver(java.lang.Object msg,
int mode)
Delivers a message to an agent or a group of agents, as specified by the
mode parameter immediately during this method call. |
int[] |
findRandomEmptyCell()
Finds a pseudo-randomly located empty cell and returns its row and column in
the array with two elements. |
Agent |
getAgentAtCell(int r,
int c)
Returns the agent located in the cell with a given row and column, or null. |
Agent |
getAgentNextToMe(int dir)
Returns the agent next to this agent in a given direction, if any. |
int |
getC()
Returns the column of the agent's cell. |
AgentDiscrete2D |
getConnectedAgent(int index)
Returns the connected agent with a given index. |
java.util.LinkedList<AgentDiscrete2D> |
getConnections()
Returns a collection of agents connected to this agent (bi-directionally),
or null if there have not been any connections yet. |
EnvironmentDiscrete2D |
getEnvironment()
Returns the environment where this agent belongs to. |
AgentDiscrete2D[] |
getNeighbors()
Returns the array of neighbor agents, subject to the current
neighborhood type (Euclidean - {N,S,E,W}, Moore - also {.. |
int |
getR()
Returns the row of the agent's cell. |
void |
jumpToCell(int r,
int c)
Moves the agent into a cell with the given row and column. |
boolean |
jumpToRandomEmptyCell()
Finds a random empty cell and places the agent there. |
void |
moveToNextCell(int dir)
Moves the agent to an adjacent cell in a given direction. |
void |
onReceive(java.lang.Object msg,
AgentDiscrete2D sender)
A callback that is called when the agent receives a message
from another agent. |
void |
send(java.lang.Object msg,
AgentDiscrete2D dest)
Sends a message to a given agent. |
void |
setCell(int r,
int c)
Puts the agent into a given cell. |
void |
swapWithAgent(AgentDiscrete2D anotherAgent)
Swaps the cell location of this agent with another agent. |
void |
swapWithCell(int r,
int c)
Swaps this agent with an agent at the cell with the given row and column. |
void |
swapWithNextCell(int dir)
Swaps the agent with an agent at the adjacent cell in a given direction. |
| Methods inherited from class com.xj.anylogic.engine.Agent |
agentInfo, disconnectFrom, disconnectFromAll, getConnectionsNumber, getShapeX, getShapeY, isConnectedTo, onBeforeStep, onDestroy, 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, 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 |
AgentDiscrete2D
public AgentDiscrete2D(Engine engine,
ActiveObject owner,
ActiveObjectCollection<?> collection)
getEnvironment
public EnvironmentDiscrete2D 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
connectTo
public void connectTo(AgentDiscrete2D 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 if agents are already connected.
- Parameters:
a - another agent
getConnectedAgent
public AgentDiscrete2D 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<AgentDiscrete2D> 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
deliver
public void deliver(java.lang.Object msg,
AgentDiscrete2D 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 messagedest - the destination agent
send
public void send(java.lang.Object msg,
AgentDiscrete2D 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 messagedest - the destination agent
onReceive
public void onReceive(java.lang.Object msg,
AgentDiscrete2D 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.
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 cellc - 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 cellc - the column of the new cell
moveToNextCell
public void moveToNextCell(int dir)
- Moves the agent to an adjacent cell in a given direction.
- Parameters:
dir - the direction (NORTH, SOUTH, ..., NORTHEAST, ...)
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 cellc - the column of the new cell
swapWithNextCell
public void swapWithNextCell(int 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(AgentDiscrete2D 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
findRandomEmptyCell
public int[] findRandomEmptyCell()
- Finds a pseudo-randomly located empty cell and returns its row and column in
the array with two elements.
- Returns:
- the array with two elements (row and column) of the empty cell, or null
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
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 cellc - the column of the cell
- Returns:
- the agent at (r,c) or null
getAgentNextToMe
public Agent getAgentNextToMe(int 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 AgentDiscrete2D[] 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
deliver
public void deliver(java.lang.Object msg,
int mode)
- Description copied from class:
Agent
- 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.
- Overrides:
deliver in class Agent
- Parameters:
msg - the messagemode - specifies the message sending mode (ALL, RANDOM, ...)
Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.