def _compute_sparseness(self): # Compute distance among the OOB and take the avg of their maximum distance max_distances_starting_from = {} for (oob1, oob2) in combinations(self.oobs, 2): # Compute distance between cells distance = iterative_levenshtein(oob1['interesting segment'], oob2['interesting segment']) self.logger.debug("Distance of OOB %s from OOB %s is %.3f", oob1["test id"], oob2["test id"], distance) # Update the max values if oob1['test id'] in max_distances_starting_from.keys(): max_distances_starting_from[oob1['test id']] = max( max_distances_starting_from[oob1['test id']], distance) else: max_distances_starting_from[oob1['test id']] = distance mean_distance = np.mean([ list(max_distances_starting_from.values()) ]) if len(max_distances_starting_from) > 0 else np.NaN std_dev = np.std([ list(max_distances_starting_from.values()) ]) if len(max_distances_starting_from) > 0 else np.NaN self.logger.debug("Sparseness: Mean: %.3f, StdDev: %3f", mean_distance, std_dev) return mean_distance, std_dev
def get_min_distance_from_set(ind, solution): distances = list() ind_spine = get_spine(ind) for road in solution: road_spine = get_spine(road) distances.append(iterative_levenshtein(ind_spine, road_spine)) distances.sort() return distances[0]
def distance(self, other: 'BeamNGMember'): #TODO #return frechet_dist(self.sample_nodes, other.sample_nodes) return iterative_levenshtein(self.sample_nodes, other.sample_nodes)
def distance(self, other: 'BeamNGMember'): return iterative_levenshtein(self.sample_nodes, other.sample_nodes)