AnyLogic
Expand
Font size

Service

Service element is an integral part of the  Service with Lines and  Service with Area markup elements. The queue choice policy that you define for the Service with Lines or Service with Area elements is applied uniformly to all Service elements contained in them. Each individual Service element, however, allows you to select a different queue choice policy, which will override the policy set for the parent element.

There are two types of services:

  •  Linear service defines a line, along which pedestrians should move. Pedestrian services at starting point of the line and then moves to the ending point before leaving the service. When pedestrian directs himself to the service, the service becomes assigned and treated by other pedestrians as occupied. Pedestrian goes to the starting point of the line and starts waiting there for the specified delay. Then pedestrian moves to ending point of line. Recovery phase begins when pedestrian either finishes service (Wait for exit is off) or passes ending point of line (Wait for exit is on). Duration of the recovery phase is defined by recovery delay. After recovery, the service becomes idle and ready to accept new pedestrians.
  •  Point service defines a point, where pedestrians should stay on for service delay time. When pedestrian directs himself to the service, the service becomes assigned and treated by other pedestrians as occupied. Pedestrian goes to a random point of the line and waits there for the specified delay. Recovery phase begins when pedestrian finishes service. The duration of the recovery phase is defined by the recovery delay. After recovery, the service becomes idle and ready to accept new pedestrians.

To change the type of service for the markup element

  1. Select the Service with Lines or Service with Area markup element with a single click.
  2. Choose the necessary Type of service option (Point or Linear) in the markup element properties.

Properties

General

Name — The name of the service. The name is used to identify and access the service from code.

Show name — If selected, the service name is displayed in the graphical editor.

Visible on upper agent — If selected, the service is also visible on the upper agent where this agent lives.

Override queue choice policy — The selection overrides the policy defined for the Service with Lines or Service with Area markup element. It defines the queue from which the service will serve pedestrians. When the service becomes vacant, it chooses the queue anew according to the selected option. The following alternative options define the queue to be selected:

  • Longest queue — the queue containing the maximum number of pedestrians
  • Closest queue (strict) — the queue that is closest to the service, no matter whether it is empty or not
  • Closest not empty queue — the non-empty queue that is closest to the service
  • Next queue (round robin) — the queues are selected sequentially in circular order
  • Priority queue — the queue with the highest priority is selected (according to the expression provided in the Queue priority field below)
  • Other queue — the queue is returned by the expression specified in the Queue field below

Queue priority — [Visible if Serve pedestrians from is set to Priority queue] Here you can enter Java expression that returns the queue priority. The greater value corresponds to the higher priority. The expression is dynamically reevaluated for each non-empty queue. Based on the results of recalculations the queue with the highest priority will be chosen. You can refer to the service’s queues in the expression using the local variable queue.

Queue — [Visible if Serve pedestrians from is set to Other] Here you can enter Java expression that returns the selected queue. Typically you place the call of your custom Java function here.

Position and size

X — X-coordinate of the service point (if service type is Point) or the service line’s starting point (if service type is Linear).

Y — Y-coordinate of the service point (if service type is Point) or the service line’s starting point (if service type is Linear).

Pedestrian orientation — [Visible if service type is Point]. The option defines the rotation angle set for the 2D / 3D model of the pedestrian and allows to make the agent face the certain direction at the service point.

dX — [Visible if service type is Linear] X-coordinate of the service line’s ending point.

dY — [Visible if service type is Linear] Y-coordinate of the service line’s ending point.

Functions

Service
Function Description
getLongestQueue() Returns the queue containing the maximum number of pedestrians.
getClosestQueue() Returns the queue that is closest to the service, no matter whether it is empty or not.
getClosestQueueNotEmpty() Returns the non-empty queue that is closest to the service element.
int queuePriority(queue) This function should be overridden to return the queue priority in Priority queue choice policy.

queue — the local variable available for the service element
customSelectQueue() This function should be overridden to return a queue in Custom queue choice policy.
boolean isSuspended() Returns true if the service element is in suspended state; returns false otherwise. A suspended element is inactive and does not accept pedestrians.
setSuspended(boolean suspended) Sets the service element to suspended state if the suspended value is true; sets the service element to active state otherwise.
Color getColor() Returns the color of the service element.
setColor(Color color) Sets the color of the service element.

color — the color of the service element. It is defined with a color constant, or using the new Color(<red>, <green>, <blue>) constructor.
Service Line
Function Description
double getStartX()
double getStartY()
double getStartZ()
Returns the X (Y, Z) coordinate of the service line’s starting point.
double getEndX()
double getEndY()
double getEndZ()
Returns the X (Y, Z) coordinate of the service line’s ending point.
double length() Returns the length of the service line in 2D space, measured in pixels.
Position getForwardStartPosition(Position out)
Position getReverseStartPosition(Position out)
Returns the position associated with the service line’s starting (ending) point, which comprises the x, y, and z coordinates, horizontal and vertical rotation angles.

Position out — the object to write the position data to
Position getForwardPositionByOffset(double offset, Position out)
Position getReversePositionByOffset(double offset, Position out)
Returns the position of the point that is offset from the service line’s starting (ending) point by the provided offset value (in pixels). The position data comprises the x, y, and z coordinates, horizontal and vertical rotation angles (in radians).

double offset — the offset (in pixels) from the service line’s starting (ending) point
Position out — the object to write the position data to
double getForwardOrientation()
double getReverseOrientation()
Returns the service line’s horizontal rotation angle (in radians) around the starting (ending) point.
Service Point
Function Description
double getX()
double getY()
double getZ()
Returns the X (Y, Z) coordinate of the service point.
Position getPosition(Position out) Returns the position associated with the service point, which comprises the x, y, and z coordinates, horizontal and vertical rotation angles.

Position out — the object to write the position data to
double getOrientation() Returns the service’s orientation angle (in radians), i.e. the rotation angle set for the 2D / 3D model of the pedestrian being serviced.
How can we improve this article?