platypus.distance module
- class DistanceMatrix(solutions, distance_fun=<function euclidean_dist>)
Bases:
objectMaintains pairwise distances between solutions.
The distance matrix, used by SPEA2, maintains the pairwise distances between solutions. It also provides convenient routines to lookup the distance between any two solutions, find the most crowded solution, and remove a solution.
- find_most_crowded()
Finds the most crowded solution.
Returns the index of the most crowded solution, which is the solution with the smallest distance to the nearest neighbor. Any ties are broken by looking at the next distant neighbor.
- distance_to_nearest(solution, set)
Finds the minimum distance from the solution to the set of solutions.
Note that this uses
normalized_euclidean_dist(), and hence the solutions must be normalized before calling.Parameters
- xSolution
The first solution.
- ySolution
The second solution.
- euclidean_dist(x, y)
Computes the Euclidean distance between two solutions.
Parameters
- xSolution
The first solution.
- ySolution
The second solution.