solve_traveling_salesman_problem
Calculate the shortest route for visiting all given locations with the Traveling Salesman Problem solver. Input locations, optional distance matrix, and time limits to optimize route planning efficiently.
Instructions
Solve Traveling Salesman Problem (TSP) to find the shortest route visiting all locations.
Args:
locations: List of location dictionaries with name and coordinates
distance_matrix: Optional pre-calculated distance matrix
start_location: Index of starting location (default: 0)
return_to_start: Whether to return to starting location (default: True)
time_limit_seconds: Maximum solving time in seconds (default: 30.0)
Returns:
Optimization result with route and total distance
Input Schema
Name | Required | Description | Default |
---|---|---|---|
distance_matrix | No | ||
locations | Yes | ||
return_to_start | No | ||
start_location | No | ||
time_limit_seconds | No |
Input Schema (JSON Schema)
{
"properties": {
"distance_matrix": {
"anyOf": [
{
"items": {
"items": {
"type": "number"
},
"type": "array"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Distance Matrix"
},
"locations": {
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Locations",
"type": "array"
},
"return_to_start": {
"default": true,
"title": "Return To Start",
"type": "boolean"
},
"start_location": {
"default": 0,
"title": "Start Location",
"type": "integer"
},
"time_limit_seconds": {
"default": 30,
"title": "Time Limit Seconds",
"type": "number"
}
},
"required": [
"locations"
],
"type": "object"
}