tour_cost¶ tour_cost(tour, cost_matrix)[source]¶ Compute the total travel cost of a tour. Parameters: tour (list[int]) – Ordered list of city indices (first and last should match for a round trip). cost_matrix (ndarray[tuple[Any, ...], dtype[floating]]) – Distance/cost matrix. Return type: float Returns: Total tour cost.