AnyLogic
Expand
Font size

Path

Paths and nodes are space markup elements that define the locations of agents in the space:

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

Nodes can be connected with paths. Altogether they compose a network. AnyLogic also automatically creates a separate network for every single path element that is not connected to any nodes. In the network, a node defines a place where agents may stay, while paths connecting nodes define the routes that agents may take when moving from one node to another. Movement is always performed along the shortest path between the origin and the destination nodes. Agents and resource units may have individual speeds, moreover, those speeds may change dynamically. For example, you can set different speed for the loaded and the unloaded forklift truck. It is assumed that segments have unlimited capacity, so agents moving along a segment do not interfere.

You can select a path as Agent location in the following Process Modeling Library blocks’ properties: Delay, Queue, Match, Combine, Seize, Service, Conveyor, Batch, RackStore.

Drawing a path

Path may contain any number of linear and/or curved segments.

To draw a path

  1. Double-click the  Path element in the  Space Markup palette. The icon of the element should turn into . It means that the drawing mode is activated and now you can draw path in the graphical editor point by point.
  2. Click in the graphical editor to draw the first point of the path. Do more clicks to add more points.
  3. To draw a curved segment, press the left mouse button at the path’s next turning point, move the mouse with the left mouse button being pressed until you get the segment of the required shape. Release the mouse button when finished adjusting the form of the path segment.

  4. Put the final point of the path with the double-click.

You can continue drawing the path after you finished it with the double-click, and edit the path by making segments linear or curved.

Properties

General

Name — The name of the path. The name is used to identify and access the path from code and flowchart blocks properties.

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

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

Lock — If selected, the path 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.

Bidirectional — Here you can enable movement on the path in both directions.

Speed limit for transporters — If selected, limits the speed of transporters on this path to the specified level.

Limit number of transporters — If selected, limits the overall number of transporters on this path.

Appearance

Type — The type of the path. Choose between Dashed line, Line, Road, Railroad or Conveyor.

Road Railroad Conveyor
By setting Type to Road, Railroad or Conveyor you only change the visual appearance of the path. It does not add any specifics to the path logic. Typically you use such paths in the models with high abstraction level only.
For road traffic simulation, use Road Traffic Library and road traffic markup shapes (road, intersection, etc.).
For low-level railway simulation (considering every single railway track of the simulated rail yard), use Rail Library and rail markup shapes.
For bulk transportation simulation, use Fluid Library and Bulk conveyor belt markup shape.

Line color — The path color if the type is Dashed line or Line.

Line width — The width of the path if the type is Dashed line or Line.

Width — The width of the path when its type is set to Road, Railroad or Conveyor.

Position

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

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

Z — [Enabled if Show in: 2D and 3D or 3D only options are selected] Z-coordinate of the path’s start point.

Points

The table located in the Points property section enables users to view and adjust coordinates of the path turning points.

Here you define relative coordinates, not the absolute ones. The first point always has coordinates (0, 0, 0) that cannot be changed.

Other rows of the table define relative coordinates of the successive points. Coordinates of each point are actually offsets of the corresponding point from the start point along X, Y (and optionally Z) axes correspondingly.

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 path’s name is displayed on the graphical diagram.

Functions

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

Length
Function Description
double length() Returns the length of the path (in pixels) calculated in 3D space.
double length(LengthUnits units) Returns the length of the path calculated in 3D space.

units — one of the chosen length units.
Points
Function Description
Point getStartPoint() Returns the Point object with coordinates of the path’s starting point.
Point getStartPoint(Point out) Returns the Point object with coordinates of the path’s starting point.

out — the output point to write result to.
Point getEndPoint() Returns the Point object with coordinates of the path’s ending point.
Point getEndPoint(Point out) Returns the Point object with coordinates of the path’s ending point.

out — the output point to write result to.
Position getStartPosition() Returns the Position object with coordinates and orientation of the path’s starting point.
Position getStartPosition(Position out) Returns the Position object with coordinates and orientation of the path’s starting point.

out — the output position to write result to.
Position getEndPosition() Returns the Position object with coordinates and orientation of the path’s ending point.
Position getEndPosition(Position out) Returns the Position object with coordinates and orientation of the path’s ending point.

out — the output position to write result to.
boolean contains(double px, double py) Returns true if the path contains the point with the given coordinates; returns false otherwise.

px — the X-coordinate of the point.
py — the Y-coordinate of the point.
boolean contains(double px, double py, double distance) Returns true if the path contains the point with the given coordinates using the given distance tolerance; returns false otherwise.

px — the X-coordinate of the point.
py — the Y-coordinate of the point.
distance — the distance tolerance to determine whether the given point lies within the markup element line proximity.
boolean containsSq(double px, double py, double squareDistance) Returns true if the path contains the point with the given coordinates using the given square distance tolerance; returns false otherwise.

Returns true if the shape contains the point with the given coordinates. px — the X-coordinate of the point.
py — the Y-coordinate of the point.
squareDistance — the square of distance tolerance to determine whether the given point lies within the markup element line proximity.
double getNearestPoint(double x, double y, Point out) Calculates the point in this path nearest to the given (x, y) point and writes the result to the output Point object. Returns the square of the distance to the point. All calculations are performed in the horizontal XY-projection (i.e. z-coordinates are treated as zeros).

x — the x coordinate of the point.
y — the y coordinate of the point.
out — the output point to write result to.
double getNearestPoint(double x, double y, double z, Point out) Calculates the point in this path nearest to the given (x, y, z) point and writes the result to the output Point object. Returns the square of the distance to the point.

x — the x coordinate of the point.
y — the y coordinate of the point.
z — the z coordinate of the point.
out — the output point to write result to.
Position getPositionAtOffset(double offset, Position out) Returns the Position object with coordinates and orientation of the point that is located at the given offset distance (in pixels) from the path’s starting point.

offset — offset, non-negative value, should be less or equal to the full length.
out — output object to write to, may be null.
Position getPositionAtOffset(double offset, LengthUnits units, Position out) Returns the Position object with coordinates and orientation of the point that is located at the given offset distance from the path’s starting point.

offset — offset, non-negative value, should be less or equal to the full length.
units — one of the chosen length units.
out — output object to write to, may be null.
Network ports
Function Description
NetworkPort createPort(PathEndType endType) Creates a network port at the starting or the ending point of the path, depending on the argument value.

endType — Specifies whether the port should be created at the path’s starting or ending point. Possible values: PathEndType.BEGIN, PathEndType.END.
NetworkPort createPort(PathEndType endType, NetworkPort pairedPort) Creates a network port at the starting or the ending point of the path, depending on the argument value. The resulting port will be paired with the specified port in another network.

endType — Specifies whether the port should be created at the path’s starting or ending point. Possible values: PathEndType.BEGIN, PathEndType.END.
pairedPort — A network port that belongs to another network.
When a network port is created programmatically, it can only be paired with ports created the same way. To create a connection between ports you’ve created in the graphical editor, use their properties.

Segments
Function Description
int getSegmentCount() Returns the number of the path’s segments.
MarkupSegment getSegment(int index) Returns the segment by the provided index.

index — the segment index, starting from zero up until the number of segments -1.
Nodes
Function Description
Node getSource() Returns the path’s source node.
Node getTarget() Returns the path’s target node.
Visibility
Function Description
boolean isVisible() Returns true if the path is visible; returns false otherwise.
void setVisible(boolean v) Sets the visibility of the path.

v — visibility. If v is true — the path is set to be visible, if it is false — not visible.
Color and texture
Function Description
Color getLineColor() Returns the color of the path, or null if the path has no color or uses a texture (in this case use getLineTexture() to get the path’s texture).
Texture getLineTexture() Returns the texture of the path or null if the path has no texture but uses a color (in this case use getColor() to get the path’s color).
void setLineColor(Color color) Sets the color of the path.

color — the new color.
void setLineColor(Paint color) Sets the color (or texture) of the path.

color — the new texture.
Level
Function Description
Level getLevel() Returns the level, where this path is located.
Appearance
Function Description
double getLineWidth() Returns the width of the path outline (in pixels).
double getLineWidth(LengthUnits units) Returns the width of the path outline.

units — one of the chosen length units.
void setLineWidth(double width) Sets the width of the path outline; 0 means the thinnest possible outline.

width — the new width of the path outline (in pixels).
void setLineWidth(double width, LengthUnits units) Sets the width of the path outline; 0 means the thinnest possible outline.

width — the new width of the wall path (in pixels).
units — one of the chosen length units.
Removal
Function Description
void remove() Removes the path from the presentation. If the path 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.

Movement direction

Each path has a direction — the first point you draw is treated as the starting point of the path.

When a path animates some Process Modeling Library object (Queue, Conveyor, etc.), it is important where you place the starting point of the path as:

  • Conveyor block transports parts from the starting to the end point of a path.
  • Queue block places agents in its queue from the end to the start point of a path (end point corresponds to queue’s head).

To learn the direction of the path, select it in the graphical diagram by a mouse click. The path’s direction will be indicated by the arrow displayed on the path shape. The arrow is always displayed on the unidirectional paths’ shapes.

To change the direction of the path

  1. Right-click the path in the graphical diagram and choose Change Direction from the context menu. You will see that the arrows changed their directions.

Editing path shape

To add a segment to the path

  1. Right-click the path you have drawn and select Append line from the context menu. You can append a line to any end point of the path by clicking this point.

  2. You are now in the drawing mode. You can add as many new segments as you need, both linear and curved.
  3. Put the final point of the path with the double-click.

To make a curved segment linear

  1. Click a path in the graphical editor to select it.
  2. Press Ctrl button on your keyboard and hold it. At the same time drag end point of the curved segment.
  3. Release the buttons when the segment has the required shape.

To make a linear segment curved

  1. Right-click the path and select Edit Using Guiding Lines from the context menu. The guiding lines will appear for editing points. Left-click an editing line point and drag it around without releasing the left mouse button.

  2. Right-click the path and clear Edit Using Guiding Lines from the context menu to switch off this editing mode.

Several paths can be connected together, with or without the use of nodes. You can disconnect the paths too.

To connect two or more paths into one path

  1. When you connect two paths at their end points, they become one path. In the example below, the option Append Line was used to connect path to path1.

  2. The connecting point where the two paths merge is highlighted with the cyan color. Two shapes have now become one element, path. The former segments of path1 have inherited the name and the direction.

  3. As long as you connect the paths by their edge segments, they will merge into one path.

To connect two or more paths with a point node

  1. You can connect paths using a point node if you draw a segment that connects anywhere to the path and not to its end point. In the example below, the element path was connected to path1 in the middle. Multiple paths can be connected with each other this way.

  2. The point node will appear in the place of connection. It is highlighted in the cyan color. Now you have created network with several paths in it. In the example below, the point node breaks the path into parts, path and path2 while path1 does not merge with path, but remains a separate path.

    You can connect in one point node as many paths as you need.
  3. The first click selects all elements of this network, make one more click to select the point node. Right-click the point node in the graphical editor and select Create node from the context menu to create the Point node element in the point of connection.

You can split the paths that are connected at the point node or split one whole path into several paths by segments.

To disconnect the paths or segments

  1. Right-click the path in the graphical editor and select the option Split into Two Shapes from the context menu.
  2. When the editing points are highlighted, click an editing point where you want to break the path, either you want to disconnect the path from the point node or separate a segment. The path will be split to two separate paths. Moreover, the next click that point will allow you to edit the segment as it is the end point of the path now.
How can we improve this article?