Route optimization is the task of choosing an order for visiting a set of stops. In NpSolv, the route optimization solver works from pairwise distances between stops and returns an ordered path or tour through the full set.
This is closely related to the traveling salesman problem. Instead of asking a user to draw a road network, NpSolv asks for the distance between each pair of stops. Those distances may come from travel-time estimates, mileage, shortest-path calculations, or another consistent distance source.
The result is not a turn-by-turn navigation plan. It is an optimized stop order based on the distance data you provide.
What is route optimization?
Route optimization finds a useful order for visiting locations. A stop could represent a customer, job site, warehouse, machine, waypoint, or any other place that needs to be visited exactly once.
NpSolv models this as a complete distance table: every stop has a distance to every other stop. The solver then builds a path or tour using those distances.
This format is flexible because the numbers do not have to be physical mileage. They can represent time, cost, weighted travel effort, or another nonnegative distance-like value.
What is the difference between a route and a tour?
A route has a start and an end. It visits every stop once and does not need to return to the beginning.
A tour returns to its starting stop. In NpSolv, choose the same start and stop node when you want tour mode. The returned path will begin and end at that selected node.
If you leave both endpoints as any, NpSolv returns an open path. If you choose only a start or only a stop, the returned path respects that endpoint.
What information do you need for a route plan?
1. Stops
Choose the number of stops in the route. Manual entry supports a compact number of stops, while larger instances can be imported from a CSV distance matrix.
2. Pairwise distances
Enter the distance between each pair of stops once. The distance from A to B is treated as the same value as B to A, so this solver is for symmetric route data.
3. Optional endpoints
Leave both endpoints blank for an open path. Choose a start node when the route must begin at a specific stop, choose a stop node when it must end at a specific stop, or choose the same node for both fields to request a closed tour.
4. Distance source
Use distances that represent the travel model you care about. If the numbers come from a road network, they should usually be shortest-path distances between stops rather than raw map coordinates.
Worked example: six stops with fixed endpoints
Suppose you have six stops labeled A through F. You want the route to start at C and end at B. The distance table might look like this:
| Pair | Distance | Pair | Distance |
|---|---|---|---|
| A-B | 4 | C-D | 2 |
| A-C | 3 | C-E | 3 |
| A-D | 4 | C-F | 4 |
| A-E | 5 | D-E | 2 |
| A-F | 6 | D-F | 3 |
| B-C | 2 | E-F | 2 |
| B-D | 3 | B-E | 4 |
| B-F | 5 |
Open route optimization, enter pairwise distances or import a matrix, select optional endpoints, and inspect the returned route order.
The output path should visit each stop exactly once. Because C and B are fixed endpoints, the first stop should be C and the final stop should be B.
How to prepare route optimization inputs
Step 1: Decide what a stop represents
Define whether stops are customer locations, pickup points, delivery points, service calls, inspection points, or another repeated task.
Step 2: Build consistent distance data
Use the same measurement logic for every pair. Do not mix miles for some pairs with travel time or cost for others unless that is intentionally part of the model.
Step 3: Choose endpoint rules
Leave endpoints flexible when any start and end are acceptable. Set endpoints when the route must begin or finish at specific stops. Use matching endpoints for a closed tour.
Step 4: Solve and inspect the path
Review the path length, raw path, directed visualization, error messages, and step-by-step leg table.
Step 5: Validate against real-world constraints
The result is based on the distances you entered. Review vehicle limits, time windows, traffic rules, service durations, driver constraints, and other operational requirements separately.
How should you read the result?
The summary reports the total route or tour length and elapsed runtime. The raw path lists the stop order in text form, such as A -> C -> D.
The visualization draws the returned stop order as directed edges. The details table breaks the route into individual legs with distance and cumulative distance values.
NpSolv uses approximation-oriented route construction methods to generate candidate stop orders for the endpoint rules you choose. Do not treat the result as a proof of global optimality.
Why can route optimization be hard?
Even when every pairwise distance is known, the number of possible stop orders grows quickly. Trying every order is manageable for a few stops, but becomes impractical as the stop count increases.
- Ordering choices: Each stop position affects the legs before and after it.
- Endpoint constraints: Fixed starts and stops can change which route order is attractive.
- Distance quality: The solver can only optimize the distances provided by the model.
Practical route solvers are useful because they produce candidate routes without requiring an exhaustive search over every possible stop order.
When should you use a route optimization solver?
Use a route optimization solver when you need an ordered visit plan for a set of stops and you can express travel between stops as symmetric pairwise distances.
NpSolv provides a route optimization tool where you can enter distances manually, import a CSV matrix for larger instances, choose optional endpoints, and export a PDF report of the result.
Try Route OptimizationFrequently asked questions
Is this the same as GPS navigation?
No. The solver chooses a stop order from the distances you provide. It does not generate turn-by-turn driving directions.
What does symmetric distance mean?
It means the distance from A to B is treated as the same as the distance from B to A.
How do I create a closed tour?
Choose the same node as both the start and stop. The result will begin and end at that node.
Can I import large distance matrices?
Yes. Manual entry is intended for smaller instances, while CSV import is the better workflow for larger route problems.
Does the solver guarantee the shortest possible route?
No. The solver returns a generated route or tour based on the distance data you provide. It should be reviewed before being used for important decisions.
What should I check before using the result?
Check that the distances represent your real objective, then review any time windows, vehicle limits, service times, access rules, or business constraints that are not modeled directly.
Further reading: J. A. Hoogeveen, Analysis of Christofides' heuristic: Some paths are more difficult than cycles, Operations Research Letters, 1991.

