AnyLogic
Expand
Font size

Rectangular node

Nodes and paths are space markup elements that define the locations of agents in the space:

  • Node defines a place where agents can reside.
  • Path defines a movement path for agents.

Nodes can be connected with paths. Altogether they compose a network. In the network, node defines a place where agents may reside, while paths define the routes that agents may take when moving from one node to another.

Rectangular node defines a node of a rectangular form.

There are nodes of two other shapes available:

You can define particular waiting points inside the node using attractors.

Speed and access restriction

You can customize the access to the node and the speed of movement through the node for pedestrians, transporters with free-space navigation, and path-guided navigation. Speed restrictions and access restrictions do not depend on each other and can be specified separately. The nodes with different restrictions can overlap. Each node can have only one type of access restriction enabled.

Demo model: Areas with Limited Access for Transporters Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: Areas with Restrictions for Pedestrians Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

Nodes with enabled access restriction automatically change their color to red:

This change of color doesn’t occur if the node with restrictions is created from code.

At the start of model run, the nodes change coordinates very slightly for a negligible value. In cases where the ending or the starting point of a path is located at the border of a node, this might affect the simultaneous callback times for:
  • actions that must be executed on enter / exit path,
  • actions that must be executed on enter / exit node.
The order in which these actions are executed will remain unchanged.

Accessing agents in the node

When we talk about agents in the context of access restriction, it means pedestrians and transporters only!

By default, AnyLogic doesn't keep track of interactions between agents and nodes without access restrictions. If you call any function that is supposed to return a list of agents inside the node, such function will return an empty list. To obtain information about agents inside any particular node, you should first enable access restriction in this node. For information about pedestrians, use the functions from the Agents section of the node's API. Similar functions for transporters can be found in the Transporters section.

If you model has pedestrians and transporters moving through the same nodes, the functions from the Agents section will return both. For example, if there are 5 transporters and 3 pedestrians inside the node, getNumberOfAdmittedAgents() will return 8.

To add a rectangular node

  1. Drag the  Rectangular node element from the  Space Markup palette to the graphical diagram.
  2. You can resize the shape now and change its location or properties.

Properties

General

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

Ignore — If selected, the node is excluded from the model.

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

Lock — If selected, the node shape is locked. Locked shapes do not react to mouse clicks — it is impossible to select them in the graphical editor until you unlock them.

Visible — Here you specify whether the shape is visible on animation at model runtime, or not. Using the control, choose yes or no.

Locations layout — [Visible if there are no attractors inside the node] Here you can choose the layout inside the node: Random or Arranged.

Attractors... — Click this button to create attractors inside the area. Attractors are the places where the pedestrians will tend to get.

Speed and access restrictions

Restrictions apply to — Here you can specify the agent type whose speed and/or access will be restricted in this node.

Speed restriction — If selected, limits the speed of agents in this node.

Maximum speed — [Visible if the Speed restriction option is selected] Maximum permissible speed for agents in this node.

Access restriction — If selected, limits the access of agents to this node.

Access restricted by — [Visible if the Access restriction option is selected] Here you can select the access restriction policy for this node. The following options are available:

  • capacity — the number of agents inside the node. As long the number of agents is less than or equal to the value specified in the Capacity parameter, the access to the node is granted.
  • throughput — the number of agents that can enter the node per 1 model time unit. As long the number of agents is less than or equal to the value specified in the Throughput parameter, the access to the node is granted.
  • schedule — the access is controlled by the on/off Schedule. The node is closed when the schedule is “on” and open when the schedule is “off”.
  • condition — a Condition is evaluated for every agent that wants to enter the node. If the evaluation returns true, the access is denied. If the evaluation returns false, the access is granted.
  • call of close() function — the node is closed by the explicit call of the close() function. To open the node, you can call the open() function.

Capacity — [Visible if Access restricted by: capacity] Maximum permissible number of agents in the node. When the value specified here is exceeded, the access to the node is restricted.

Throughput — [Visible if Access restricted by: throughput] Maximum permissible number of agents in the node per 1 model time unit. When the value specified here is exceeded, the access to the node is restricted.

Schedule — [Visible if Access restricted by: schedule] A schedule that governs the access to the node. When “on”, the access to the node is restricted for the specified agent type. When “off”, any agent can enter the node.

Condition — [Visible if Access restricted by: condition] A boolean expression that must be evaluated for each agent to determine whether the access to the node can be granted. If the evaluation returns true, the access is restricted; otherwise, the node remains open.

Area is avoided if closed — [Visible if Access restricted by: schedule / condition / call of close() function] If this option is selected, the transporters will avoid the node when it is closed.

On enter — Here you can place the code that will be executed when the agent enters the node.

On enter denied — Here you can place the code that will be executed when the agent tried to enter the node, was prohibited and put in the queue. This code will be executed only on the agent’s first denial of entry. If the same agent tries to enter and is denied again, the code placed here won’t be executed.

On exit — Here you can place the code that will be executed when the agent exits the node.

On open — [Cannot be applied if Access restricted by: condition] Here you can place the code that can be executed when the node is opened.

On close — [Cannot be applied if Access restricted by: condition] Here you can place the code that can be executed when the node is closed.

Appearance

Fill color — Shape’s fill color. Choose No color, if you do not want shape to be filled.

Line color — Outline color. Choose No color, if you do not want outline to be drawn.

Line width — Outline width.

Line style — [Enabled only if the Show in: 3D only checkbox is not selected] Outline style. Choose from the drop-down list, whether you want solid, dashed, or dotted outline to be drawn.

Position and size

Level — Level to which this element belongs.

X — X-coordinate of the area’s start point.

Y — Y-coordinate of the area’s start point.

Z — [Enabled if Show in: 3D only option is selected] Z-coordinate of the area, in meters. The value is relative to the Z-coordinate of the area’s level.

Rotation — Rotation angle of the node in the XY plane.

Width — Width of the node (in pixels).

Height — Height of the node (in pixels).

Advanced

Show in — Here you can choose whether you want the shape to be shown both In 2D and 3D animation, or in 2D only, or in 3D only.

Show name — If selected, the shape’s name is displayed on the graphical diagram.

Functions

You can dynamically modify shape properties at model runtime using the following API.

Speed and access restriction
Function Description
void restrictAccessByCapacity(int number) Restricts access to the node by the specified capacity.
This function can be used to change the number of agents dynamically, but cannot be used after initialization to change the type of restriction in the already existing node.
number — the maximum number of agents that can be inside the node before the access to the node is restricted.
void restrictAccessByThroughput(double throughput, RateUnits units) Restricts access to the node by the specified throughput, i.e. the maximum permissible number of agents entering the node during 1 specified rate unit.
This function can be used to change the number of agents dynamically, but cannot be used after initialization to change the type of restriction in the already existing node.
throughput — maximum permissible number of agents entering the node during 1 specified rate unit.
units — a constant defining the rate units.
restrictAccessBySchedule(Schedule<Boolean> schedule) Restricts access to the node by the specified “on/off” schedule.
This function can be used to change the schedule dynamically, but cannot be used after initialization to change the type of restriction in the already existing node.
schedule — the “on/off” schedule that controls access to the node. During the “on” periods, agents can enter the node, while during the “off” periods, the access to the node is closed.
void restrictAccessManually(boolean initiallyClosed) Enables manual control over access to the node.
Don’t use this function to open or close the access to the node dynamically after initialization. Use open()close(), or setOpen() functions instead.
initiallyClosed — if true, the access to the node is closed initially, if false — the entrance to the node is open initially.
boolean isAccessRestricted() Returns true if the access to the node is restricted. Otherwise returns false.
void recalculateAccessibility() Recalculates the accessibility of the node. This function can only be used if Access restricted by: condition.
boolean isOpen() Returns true if the node is open. Otherwise returns false.
This function cannot be used if Access restricted by: condition. In this case the area does not have an open / closed state and the function always returns true.
void open() Lifts access restrictions from the node. This function can only be used if Access restricted by: call of close() function or if the access to this node is controlled by the call of the restrictAccessManually() function.
void close() Restricts access to the node. This function can only be used if Access restricted by: call of close() function or if the access to this node is controlled by the call of the restrictAccessManually() function.
void setOpen(boolean open) Controls the access to the node.
This function can only be used if Access restricted by: call of close() function or if the access to this node is controlled by the call of the restrictAccessManually() function.

open — if true, the node is open to all agents; if false, the access to the node is restricted.
AreaAccessRestrictionType getAccessRestrictionType() Returns the access restriction type of the node.

Valid values:
AREA_ACCESS_RESTRICTION_BY_CAPACITY — access is restricted by specified capacity.
AREA_ACCESS_RESTRICTION_BY_THROUGHPUT — access is restricted by specified throughput.
AREA_ACCESS_RESTRICTION_BY_SCHEDULE — access is restricted by specified schedule.
AREA_ACCESS_RESTRICTION_BY_CONDITION — access is restricted by specified condition.
AREA_ACCESS_RESTRICTION_MANUAL — access is restricted by the call of close() function.
boolean isAvoidedIfClosed() Returns true, if the state of the node is taken into account at transporter route calculation. Otherwise, returns false.
void setAvoidedIfClosed(boolean avoided) Determines whether the state of the node is taken into account at transporter route calculation.

avoided — if true, the transporters will avoid the closed node; if false — they won’t.
Agent getRestrictedAgentClass() Returns the type of agent whose speed and/or access is restricted for this node.
void setRestrictedAgentClass(Agent restrictedClass) Sets the type of agent whose speed and/or access is restricted for this node.

restrictedClass — agent type.
boolean isSpeedRestricted() Checks whether this node has speed restriction enabled. If the function returns true, the speed is restricted. Otherwise, the function returns false.
double getMaxSpeed(SpeedUnits units) Returns the maximum permissible speed in the node in specified speed units.

units — a constant defining the speed units.
void restrictSpeed(double maxSpeed, SpeedUnits units) Restricts the speed inside the node to the specified value maxSpeed in the specified speed units.

maxSpeed — maximum permissible speed value. units — a constant defining the speed units.
int getCapacity() Returns the maximum number of agents that can be inside the node before the access to the node is restricted.
double getThroughput(RateUnits units) Returns the maximum permissible number of agents that can enter the node during 1 specified rate unit.

units — a constant defining the rate units.
Schedule<Boolean> getSchedule() Returns the “on/off” schedule that controls access to the node.
boolean accessRestrictionCondition(T agent) Evaluates the access condition for the specified agent. If the evaluation returns true, access is restricted; otherwise, returns false.

agent — the agent for whom the access condition is evaluated.
Agents

In order to use the functions listed in this section, you should enable the access restrictions in the corresponding node. Otherwise, these functions will return nothing.

If you model has pedestrians and transporters moving through the same nodes, these functions will return both. For example, if there are 5 transporters and 3 pedestrians inside the node, getNumberOfAdmittedAgents() will return 8.

In the context of these functions "agents" means transporters and pedestrians only. You cannot use these functions to work with any other agent types.

Function Description
List<T> agents() Returns the list of agents (transporters and pedestrians only) currently present inside the node.
List<T> getAgentsWaitingToEnter() Returns the list of agents (transporters and pedestrians only) currently waiting at the border of the node with enabled restriction for permission to enter.
int getNumberOfAdmittedAgents() Returns the number of agents (transporters and pedestrians only) admitted to the node with enabled restriction.
boolean contains(Agent agent) Returns true if the node contains the given agent (transporter or pedestrian only). Otherwise returns false.

agent — the given agent
double density(AreaUnits units) Returns the average density of agents (transporters and pedestrians only) inside the node measured in agents per given area units.

units — a constant defining the area units.
Transporters

In order to use the functions listed in this section, you should enable the access restrictions in the corresponding node. Otherwise, these functions will return nothing.

These functions are applicable only to transporters.
Function Description
List<T> getAdmittedTransporters() Returns the list of transporters currently present inside the node. If the node doesn’t have restrictions enabled, returns an empty list.
int getNumberOfAdmittedTransporters() Returns the number of transporters currently present inside the node. If the node doesn’t have restrictions enabled, returns nothing.
int getNumberOfTransporters() Returns the number of transporters with path-guided navigation type currently present inside the node.
This function only works for nodes that are part of a network. It doesn't depend on the enabled restrictions.
Position
Function Description
double getX() Returns the X coordinate of the node (namely, the coordinate of its upper left corner).
double getY() Returns the Y coordinate of the node (namely, the coordinate of its upper left corner).
double getZ() Returns the Z coordinate of the node (namely, the coordinate of its upper left corner).
double getZ(double x, double y) Returns the Z coordinate of the given point.

x — the X coordinate of the point.
y — the Y coordinate of the point.
void setPos(double x, double y, double z) Sets new coordinates for the node.

x — the new value of the X coordinate.
y — the new value of the Y coordinate.
z — the new value of the Z coordinate.
Point getCenter() Returns the coordinates of the node center.
Level
Function Description
Level getLevel() Returns the level on which this node is located.
Size
Function Description
double getWidth() Returns the width of the node (in pixels).
double getHeight() Returns the height of the node (in pixels).
void setSize(double width, double height) Sets the width and height of the node.

width — the new width of the node (in pixels).
height — the new height of the node (in pixels)..
Rotation
Function Description
double getRotation() Returns the rotation of the node in radians (in the clockwise direction).
void setRotation(double rotation) Sets the rotation of the node.

rotation — the new value of rotation in radians (in the clockwise direction).
Visibility
Function Description
boolean isVisible() Returns true if the node is visible; returns false otherwise.
void setVisible(boolean v) Sets the visibility of the node.

v — visibility. If v is true — the node is set to be visible, if it is false — not visible.
Fill color
Function Description
Color getFillColor() Returns the fill color of the node, or null if the node has no fill color or has textured fill (in this case use getTexture() to get the node’s texture).
Texture getFillTexture() Returns the fill texture of the node or null if the node has no fill texture or has color fill (in this case use getFillColor() to get the node’s fill color).
void setFillColor (Color fillColor) Sets the fill color of the node.

fillColor — the new fill color, if null, the node is not filled.
void setFillColor (Paint fillColor) Sets the fill color (or Texture) of the node.

fillColor — the new fill color, if null, the node is not filled.
Outline
Function Description
Color getLineColor() Returns the line color of the node, or null if node has no line color or has textured line (in this case use getLineTexture() to get the line’s texture).
Texture getLineTexture() Returns the outline texture of the node or null if node has no outline texture or has colored line (in this case use getLineColor() to get the line’s color).
void setLineColor(Color lineColor) Sets the line color of the node.

lineColor — the new line color, if null, the node line is not drawn.
void setLineColor(Object lineColor) Sets the line color (or Texture) of the node.

lineColor — the new line color, if null, the node line is not drawn.
double getLineWidth() Returns the width of the node outline.
void setLineWidth (double width) Sets the width of the node outline; 0 means the thinnest possible outline.

width — the new width of the node outline.
int getLineStyle() Returns the style of the node outline.

Valid values:
LINE_STYLE_SOLID
LINE_STYLE_DOTTED
LINE_STYLE_DASHED
void setLineStyle (int style) Sets the style of the node outline.
Line style not applied in 3D animation; the only supported line style in 3D is solid.

style — the new style of the node outline.
Valid values:
LINE_STYLE_SOLID
LINE_STYLE_DOTTED
LINE_STYLE_DASHED
Attractors
Function Description
List<Attractor> getAttractors() Returns a collection of attractors inside the node.
void addAttractor (Attractor attractor) Adds an attractor to the node.

attractor — the attractor to be added inside the node.
Network
Function Description
Network getNetwork() Returns the network this markup element belongs to or null if this element is not a part of a network.
int getConnectionsCount() Returns the number of the node’s connections with other nodes.
Path getConnection(int index) Returns the connection between this node and another node by the provided index.

index — the index of required connection in range (0, this.getConnectionsCount() - 1).
Advanced
Function Description
boolean contains(double px, double py) Returns true if the node contains the point with the given coordinates; returns false otherwise.

px — the x coordinate of the point relative to this node’s container.
py — the y coordinate of the point relative to this node’s container.
double getNearestPoint(double px, double py, Point output) Calculates the point in this node nearest to the given (X, Y) point and writes the result into the output object.
Returns the square of distance to the point (in the XY-projection). All calculations are performed in the horizontal projection (z-coordinates are not used, as if all of the Z coordinates were zero).

px — the X coordinate of the point.
py — the Y coordinate of the point.
output — the output object to write result to. Note that output.z is left unchanged.
double getNearestPoint(double px, double py, double pz, Point output) Calculates the point in this node nearest to the given (X, Y, Z) point and writes the result into the output object.
Returns the square of distance to the point.

px — the X coordinate of the point.
py — the Y coordinate of the point.
pz — the Z coordinate of the point.
output — the output object to write result to. Note that output.z is left unchanged.
Removal
Function Description
void remove() Removes the node from the presentation. If the node is not a part of presentation, the function does nothing.
Removal from the presentation does not necessarily mean removing from the model logic, since logical networks and routes may have been created before the removal and survive it.
How can we improve this article?