AnyLogic 9
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 location where agents can reside.

Nodes can be connected to paths. Together they form a network. AnyLogic also automatically creates a separate network for each individual path element that is not connected to a node.

In the network, a node defines a place where agents can stay, while paths connecting nodes define the routes that agents can 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 can have individual speeds, and these speeds may change dynamically. For example, you can set a different speed for the loaded and the unloaded forklift truck. Segments are assumed to have unlimited capacity, so agents moving along a segment will not interfere.

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

Drawing a path

A path can contain any number of linear and curved segments.

To draw a path

  1. Click the  Path element in the  Space Markup palette. This activates the drawing mode and you can now draw the path point by point in the graphical editor.
  2. Click in the graphical editor to draw the first point of the path. Click again to add more points.
  3. To draw a curved segment, click and hold the left mouse button at the next turn point of the path and move the mouse until you get the segment of the desired shape. Release the mouse button when you have finished adjusting the shape of the path segment.

  4. Double-click to set the final point of the path.

You can continue drawing the path after you have finished it with the double-click and edit the path by making the 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 block properties.

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

Lock — If selected, the path is locked. Locked elements do not respond to mouse clicks, and they cannot be selected in the graphical editor until you unlock them. This is often needed when you want to prevent the element from being edited while other elements are placed over it.

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

Limit speed 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.

Bidirectional — Allows movement on the path in both directions.

Appearance

Type — The type of the path. Choose from 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 only use such paths in the models with a high abstraction level.
For road traffic simulation, use the Road Traffic Library and road traffic markup shapes (road, intersection, and so on).
For low-level railway simulation (considering each individual track of the simulated rail yard), use the Rail Library and rail markup shapes.
For bulk transportation simulation, use the Fluid Library and the 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.

Position

Level — The level on which this path is located.

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

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

Z — The Z-coordinate of the path’s start point.

Points

The table located in the Points property section allows you to view and set the coordinates of the path’s turning points.

The coordinates are relative, not absolute. 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. The coordinates of each point are actually offsets of the corresponding point from the start point along the X, Y (and optionally Z) axes correspondingly.

Visibility and presentation

Visible — If selected, the path is visible during animation at model runtime.

Show in — Select whether the shape is displayed in both 2D and 3D animation, 2D only, or 3D only.

Agent presentation — If selected, the path is also visible on the upper-level agent that hosts the agent containing this path.

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 have 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

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

When a path animates any block of the Process Modeling Library (for example, Queue), where you place the starting point of the path is important:

  • The Queue block places agents in its queue from the end to the start point of a path (the end point corresponds to the head of the queue).

To find out the direction of a path, click it in the graphical diagram. The direction of the path is indicated by the arrow displayed on the path shape. The arrow is always displayed on the shapes of unidirectional paths.

To change the direction of the path

  1. Right-click the path in the graphical diagram and select Change Direction from the context menu. You will see that the arrows have changed direction.

Editing path shape

To add a segment to the path

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

    AnyLogic: Adding a segment to a pathHold down the left mouse button and drag while adding a point to create a curved segment.

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

To convert a line segment to a curve segment

  1. Right-click the segment of the path (the line between two points of the path).
  2. From the context menu, select Make segment curve.

    AnyLogic: Making a curved segment

AnyLogic will draw the curve instead of the line segment. To remove the curved segment, right-click it and select Make segment line from the context menu.

You can modify the curvature of the segments using guiding lines.

To adjust the segments using guiding lines

  1. Right-click the path and select Show guiding lines from the context menu to enable guiding lines.
    On line segments, the guiding line points may appear above the path. To identify them, look for the diamond-like shapes, not circles.
  2. Drag the guiding line points to adjust the segment, making it curved or straight as needed.

    AnyLogic: Adjusting the curvature of the segment with guiding linesHold down the left mouse button and drag the guiding line point to change the curvature of a segment.

  3. To exit this mode, right-click the path and select Hide guiding lines from the context menu.

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

To connect two or more paths into a single path

  1. Consider the following example, which contains two paths: path and path1.

    AnyLogic: Two paths in the graphical editor

  2. Right-click path to open the context menu, then select Append.
  3. Click the endpoint of path to start drawing, then click the endpoint of path1 to draw a new segment. When finished, double-click to exit the drawing mode.

    AnyLogic: Connecting two paths

  4. When you connect two paths at their endpoints, they become one path. Two shapes have now become one element, path. The former segments of path1 have inherited the name and the direction. As long as you connect the paths at their endpoints, they merge into one path.

    AnyLogic: The merged paths

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 to the path anywhere but its end point. In the example below, the path element is connected to path1 inside a segment. Multiple paths can be connected with each other in this way.

    AnyLogic: Connecting paths inside a segment

  2. The point node appears in the place of connection. You have now created a network with multiple paths. In the example below, the point node splits the path into path1 and path2, while path1 does not merge with path, but remains a separate path. You can connect as many paths to a point node as you need.

    AnyLogic: Paths connected by a point node

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

To disconnect the paths or segments

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