
Aptive Environmental wants to optimize a simplified technician schedule for a single day. Given travel times between stops, implement a function that returns the minimum total travel cost to start at the Aptive branch, visit every assigned stop exactly once, and return to the branch.
Write a function optimize_aptive_route(travel_times) where:
travel_times is an n x n matrix of non-negative integerstravel_times[i][j] is the cost to travel from stop i to stop j0 is the Aptive branch (start and end)If travel_times is empty, return 0. If the matrix is not square, contains negative values, or has inconsistent row lengths, raise ValueError.
Example 1
Input: travel_times = [[0,10,15,20],[10,0,35,25],[15,35,0,30],[20,25,30,0]]
Output: 80
Explanation: One optimal route is 0 -> 1 -> 3 -> 2 -> 0 with cost 10 + 25 + 30 + 15 = 80.
Example 2
Input: travel_times = [[0,5],[7,0]]
Output: 12
Explanation: The only valid route is 0 -> 1 -> 0.
0 <= n <= 12travel_times.length == ntravel_times[i].length == n0 <= travel_times[i][j] <= 10^60, but the algorithm should not rely on symmetry.travel_times = [[0,10,15,20],[10,0,35,25],[15,35,0,30],[20,25,30,0]]Output80WhyAn optimal cycle is `0 -> 1 -> 3 -> 2 -> 0`, which totals `80`.travel_times = [[0,5],[7,0]]Output12WhyThere is only one non-trivial route: go from the branch to stop `1` and return.travel_times = [[0,2,9],[1,0,6],[15,7,0]]Output17WhyThe best route is `0 -> 2 -> 1 -> 0` with cost `9 + 7 + 1 = 17`.`0 <= n <= 12``travel_times` is an `n x n` matrix`0 <= travel_times[i][j] <= 10^6` for valid inputsStop `0` is the Aptive branch and must be the start and endThe matrix may be asymmetricdef optimize_aptive_route(travel_times):