ShortestPathFinder
Computes the shortest path of a line or lines containing a source and destination node in a network based on the length of the input or the cost (specified in an attribute) of each of the edges.
Usage Notes
-
If ShortestPathFinder produces unexpected results, consider using AnchoredSnapper instead. Input the From-To Line through the Candidate input port and use the same value for Snapping Tolerance. Specify Snapping Type = End Point Snapping and Add Additional Vertex = NEVER.
-
Only linear features with non-negative cost attribute values are allowed if the Cost Type is set to By One Attribute or By Two Attributes. If a feature does not have the attribute specified in the Forward Cost Attribute or the Reverse Cost Attribute, a zero cost is used for the line. Any features with a negative cost will be output through the <Rejected> port.
Configuration
Input Ports
Lines defining the network in which to find a path or paths. Input line features must be a topologically noded network with features connecting at line ends only. That is, all features must be split at junctions.
The From-To line contains vertices that define the source and destination nodes in the network. It can contain intermediate stops before the final destination. For example, a From-To line may be used to find the path from A to B to C to D. This can also be read as “the path from A to D that also passes through B and C.” From-To lines can be created by connecting points together to form a line, using the LineBuilder or VertexCreator transformers.
Output Ports
For each From-To line, if a path is found it will be output as a single feature through the Path port. This output feature contains the attributes and coordinate system of the original From-To line. The geometry of the output feature is made up of all the parts of network that form the shortest path. Note that if Cost Type is set to By One Attribute or By Two Attributes then the “shortest path” is the one where the sum of the values of the applicable Cost Attribute values is the least.
The total cost of the found path is given by the _total_cost attribute.
If a path is not found for a given From-To line, then this From-To line will be output through the NoPath port.
All network features that are not used as part of the shortest path are output through the Unused port.
Input From-To lines are output through this port. If Reorder From-To Line is Intermediate Points Only or All Points, a _reordered attribute is added indicating whether the From-To line was reordered.
All non-linear features from either input port are output through the <Rejected> port, as are any From-To lines that have a negative cost (when Cost Type is set to By One Attribute or By Two Attributes).
Rejected features will have an fme_rejection_code attribute with one of the following values:
INVALID_DESTINATION_GEOMETRY_TYPE
INVALID_LINE_GEOMETRY_TYPE
INVALID_PARAMETER_WEIGHT
Parameters
Group By |
The default behavior is to use the entire set of input features as the group. This option allows you to select attributes that define which groups to form. You can select attributes from both Network and From-To input features. |
||||
Complete Groups |
Select the point in processing at which groups are processed:
Considerations for Using Group By
There are two typical reasons for using When Group Changes (Advanced) . The first is incoming data that is intended to be processed in groups (and is already so ordered). In this case, the structure dictates Group By usage - not performance considerations. The second possible reason is potential performance gains. Performance gains are most likely when the data is already sorted (or read using a SQL ORDER BY statement) since less work is required of FME. If the data needs ordering, it can be sorted in the workspace (though the added processing overhead may negate any gains). Sorting becomes more difficult according to the number of data streams. Multiple streams of data could be almost impossible to sort into the correct order, since all features matching a Group By value need to arrive before any features (of any feature type or dataset) belonging to the next group. In this case, using Group By with When All Features Received may be the equivalent and simpler approach. Note Multiple feature types and features from multiple datasets will not generally naturally occur in the correct order.
As with many scenarios, testing different approaches in your workspace with your data is the only definitive way to identify performance gains. |
Dimension |
Select the type of coordinates to use when identifying topological connections:
|
||||||||||
Cost Type |
The values that result from Cost Type are summed for all input lines as they relate to the From-To line, and the shortest sum becomes the shortest-found path. Select a type:
|
||||||||||
Forward Cost Attribute |
This parameter is used when Cost Type is set to By One Attribute or By Two Attributes. |
||||||||||
Reverse Cost Attribute |
This parameter is used when Cost Type is set to By Two Attributes. |
||||||||||
Allow U-Turns |
Whether to allow the reverse of a line in the network to be used immediately following that line. If No, paths that reverse on each other are not considered when finding a shortest path. |
||||||||||
Segment Attribute List |
When specified, this attribute list that will hold the attributes for each input Network feature that make up Path output features. This list also contains a _direction attribute that stores the direction of the segment of the shortest path as compared to its original Network feature. It will either be “same” or “opposite”, depending if the original Network feature had to be reversed or not. |
Generate List
When enabled, adds a list attribute to the output features.
Segment Attribute List |
Enter a name for the list attribute. Note List attributes are not accessible from the output schema in FME Workbench unless they are first processed using a transformer that operates on them, such as ListExploder or ListConcatenator. Alternatively, AttributeExposer can be used.
|
Add To List |
All Attributes: All attributes will be added to the output features. Selected Attributes: Enables the Selected Attributes parameter, where specific attributes may be chosen for inclusion. |
Selected Attributes |
Enabled when Add To List is set to Selected Attributes. Specify the attributes you wish to be included. |
From-To and Network Snapping |
Select Yes to snap the points of the From-To line to the closest end points of the Network lines. The points are only snapped to the network lines if they are within the tolerance specified in Snapping Tolerance. Note The shortest distance is calculated based on the specified From-To line and is not affected by snapping.
|
Snapping Tolerance |
The tolerance used when From-To and Network Snapping is set to Yes. Points of the From-To line will be snapped to the Network lines if they are within this tolerance. |
Reorder From-To Line |
Specifies whether the points of the input From-To line should be reordered to find a shorter path. This option is useful when the order of points of the From-To line is not important, such as in traveling salesman problems. A metaheuristic is used to find a low-cost ordering of points. No: The input From-To line is used as-is. No optimization occurs. Automatic: The input From-To line is reordered automatically, without the need to adjust parameters per dataset. This mode attempts to produce a good result in a short amount of time, but may not work well for all datasets. For datasets with cost values that differ by less than one unit, use Advanced mode. Advanced: The input From-To line is reordered according to the Number of Iterations and Completion Conditions parameters. This mode is useful when a specific cost is desired, or for datasets where Automatic mode does not provide a good result. |
Reorder Points |
Intermediate Points Only: The start and end points of the input From-To line are untouched. Intermediate points are reordered. All Points Except First: All points except the start point of the input From-To line are reordered. All Points Except Last: All points except the end point of the input From-To line are reordered. All Points (Advanced Mode Only): All points of the input From-To line are reordered. |
Number of Iterations |
The number of times to run each step of the optimization algorithm. The greater the number of iterations, the closer the result will be to the optimal solution. Increasing this parameter increases translation time. This parameter must be set to a positive integer. The default value is 10000. |
Completion Conditions
Finish Optimization |
This parameter specifies what criteria should be used when determining whether to finish the optimization or run another round of iterations. Completion conditions are evaluated at the end of each round of iterations. After a single round of iterations: The optimization algorithm will complete the number of steps specified in the Number of Iterations parameter. When all conditions pass: The optimization algorithm will finish when all of the specified completion conditions have passed. When any condition passes: The optimization algorithm will finish when any of the specified completion conditions have passed, regardless of the status of the other conditions. |
Number of Verifications |
The number of times the optimization algorithm needs to return the same potential result before it is accepted. Setting this parameter to a high value may result in very long translation time or cause the translation to never complete. This parameter must be set to a non-negative integer. A value of 0 specifies that no verifications are required. The default value is 1. Note that if this condition is required, setting a very low value for Optimization Options > Number of Iterations may result in a translation that will not complete, as it decreases the likelihood of repeatedly finding the same potential result |
Desired Cost |
The greatest cost that will be accepted as valid. Setting this parameter to a low value may cause the translation to never complete. This parameter must be set to a non-negative value. A value of 0 specifies that there is no restriction on the cost that will be accepted. The default value is 0. |
Iteration Rounds |
The minimum number of times to run the overall optimization algorithm. |
Time (minutes) |
The minimum number of minutes to run the optimization. |
Preserve Feature Order |
This parameter controls the order in which features exit a transformer. When a transformer has more than one output port, features usually exit one port at a time. At times, it may be useful to keep the order that features arrived in, switching from port to port as necessary. This allows feature order to be preserved, though at a potential cost in processing efficiency. Select a method for feature ordering.
|
Editing Transformer Parameters
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
Defining Values
There are several ways to define a value for use in a Transformer. The simplest is to simply type in a value or string, which can include functions of various types such as attribute references, math and string functions, and workspace parameters. There are a number of tools and shortcuts that can assist in constructing values, generally available from the drop-down context menu adjacent to the value field.
Using the Text Editor
The Text Editor provides a convenient way to construct text strings (including regular expressions) from various data sources, such as attributes, parameters, and constants, where the result is used directly inside a parameter.
Using the Arithmetic Editor
The Arithmetic Editor provides a convenient way to construct math expressions from various data sources, such as attributes, parameters, and feature functions, where the result is used directly inside a parameter.
Conditional Values
Set values depending on one or more test conditions that either pass or fail.
Parameter Condition Definition Dialog
Content
Expressions and strings can include a number of functions, characters, parameters, and more.
When setting values - whether entered directly in a parameter or constructed using one of the editors - strings and expressions containing String, Math, Date/Time or FME Feature Functions will have those functions evaluated. Therefore, the names of these functions (in the form @<function_name>) should not be used as literal string values.
These functions manipulate and format strings. | |
Special Characters |
A set of control characters is available in the Text Editor. |
Math functions are available in both editors. | |
Date/Time Functions | Date and time functions are available in the Text Editor. |
These operators are available in the Arithmetic Editor. | |
These return primarily feature-specific values. | |
FME and workspace-specific parameters may be used. | |
Creating and Modifying User Parameters | Create your own editable parameters. |
Dialog Options - Tables
Transformers with table-style parameters have additional tools for populating and manipulating values.
Row Reordering
|
Enabled once you have clicked on a row item. Choices include:
|
Cut, Copy, and Paste
|
Enabled once you have clicked on a row item. Choices include:
Cut, copy, and paste may be used within a transformer, or between transformers. |
Filter
|
Start typing a string, and the matrix will only display rows matching those characters. Searches all columns. This only affects the display of attributes within the transformer - it does not alter which attributes are output. |
Import
|
Import populates the table with a set of new attributes read from a dataset. Specific application varies between transformers. |
Reset/Refresh
|
Generally resets the table to its initial state, and may provide additional options to remove invalid entries. Behavior varies between transformers. |
Note: Not all tools are available in all transformers.
FME Community
The FME Community is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
Search for all results about the ShortestPathFinder on the FME Community.