def calculate_route_cost(route_locations, route, jobs, cost_matrix):
    """
    Calculates cost of each route.

    :param route_locations: Job locations indexes in route.
    :param route: Job ids in route.
    :param jobs: Jobs information, which includes job ids, location indexes and delivery.
    :param cost_matrix: Array of location to location travel cost.
    :return: Route cost including traveling cost and service cost
    """
    route_cost = 0
    for node in range(len(route_locations) - 1):
        traveling_cost = cost_matrix[route_locations[node]][route_locations[node + 1]]
        service_cost = jobs[route[node]][2]
        route_cost = route_cost + traveling_cost + service_cost
    return route_cost