Package evo.search.ga
Class AnalysisUtils
- java.lang.Object
-
- evo.search.ga.AnalysisUtils
-
public class AnalysisUtils extends Object
This class provides several analysis metrics to evaluate individuals upon
-
-
Constructor Summary
Constructors Constructor Description AnalysisUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
areaCovered(List<DiscreteGene> points)
Calculates the maximised area covered by the points.static double
areaInSector(double distanceA, double distanceB, int rayCount)
Calculates the triangle area in a sector between two rays given the two distances of the outer edges and the amount of all rays.static List<DiscreteGene>
fill(List<DiscreteGene> chromosome)
Returns a filled list of points visited on each sector by the chromosome.static boolean
finds(DiscreteGene point, DiscreteGene treasure)
static List<DiscreteGene>
inBetween(DiscreteGene a, DiscreteGene b)
Returns a list of intersections between the line through points a and b and the rays between these points.static double
newAreaCovered(List<DiscreteGene> points)
Computes the sum of newly covered area per step of the chromosome.static double
spiralLikeness(List<DiscreteGene> chromosome)
The spiral-likeness measures the similarity between the individuals structure and a spiral.static double
spiralLikenessInvariant(List<DiscreteGene> chromosome)
Measure for the spiral-likeness of the chromosome with rotation invariance.static double
traceLength(List<DiscreteGene> points)
Calculates the trace length of a path consisting of the list of points.static double
traceLength(List<DiscreteGene> chromosome, DiscreteGene treasure)
Computes the trace length necessary for theDiscreteGene
chromosome to find the given treasureDiscreteGene
.static double
worstCase(List<DiscreteGene> points, float minDistance)
Calculates the worst case trace length of a trace barely missing a treasure.static double
worstCaseMean(List<DiscreteGene> points, float epsilon)
Compute the mean worst case over all points in the strategy.static double
worstCaseSpiralStrategy(List<DiscreteGene> chromosome)
Calculate the optimal worst case factor for the strategy.
-
-
-
Method Detail
-
spiralLikeness
public static double spiralLikeness(List<DiscreteGene> chromosome)
The spiral-likeness measures the similarity between the individuals structure and a spiral. This likeness is expressed as the summed up distances between where a point should sit in a spiral and the actual placed point. Therefore, it starts at the first position, that the individual visits. Then, it spirals out both clock-wise and counter-clockwise counting the individual distances. Finally, the minimum of the clockwise and counter-clockwise likenesses is returned.- Parameters:
chromosome
- the individual measured- Returns:
- Spiral likeness between 0.0 and infinity 0.0 means spiral
-
spiralLikenessInvariant
public static double spiralLikenessInvariant(List<DiscreteGene> chromosome)
Measure for the spiral-likeness of the chromosome with rotation invariance. Analyses the likeness pairwise.- Parameters:
chromosome
- chromosome to measure- Returns:
- rotation independent spiral likeness
-
worstCaseSpiralStrategy
public static double worstCaseSpiralStrategy(List<DiscreteGene> chromosome)
Calculate the optimal worst case factor for the strategy. This fitness is the worst case factor of the strategy's spiral counterpart.- Parameters:
chromosome
- individual to analyze- Returns:
- optimal worst case factor
-
traceLength
public static double traceLength(List<DiscreteGene> chromosome, DiscreteGene treasure)
Computes the trace length necessary for theDiscreteGene
chromosome to find the given treasureDiscreteGene
.- Parameters:
chromosome
- chromosome to evaluate the trace length ontreasure
- treasure point to be found- Returns:
- trace length necessary for the individual to find the treasure
-
traceLength
public static double traceLength(List<DiscreteGene> points)
Calculates the trace length of a path consisting of the list of points.- Parameters:
points
- points forming a trace- Returns:
- trace length of the path of points
-
finds
public static boolean finds(DiscreteGene point, DiscreteGene treasure)
Compute for twoDiscreteGene
s, whether the first pointpoint
finds the second pointtreasure
.That equals the following statement:
point.position == treasure.position && point.distance >= treasure.distance
- Parameters:
point
- Point to check, if it finds the second point.treasure
- point to be found- Returns:
- whether the first point finds the second point
-
fill
public static List<DiscreteGene> fill(List<DiscreteGene> chromosome)
Returns a filled list of points visited on each sector by the chromosome. The chromosome may jump above multiple sectors. To resolve this behaviour for the fitness evaluation using area coverage, the list of points need consecutive position indices.- Parameters:
chromosome
- chromosome with jumping genes- Returns:
- list of visited points with consecutive position indices
-
inBetween
public static List<DiscreteGene> inBetween(DiscreteGene a, DiscreteGene b)
Returns a list of intersections between the line through points a and b and the rays between these points.- Parameters:
a
- point a for the lineb
- point b for the line- Returns:
- list of intersections between the line ab and the rays between a and b
-
areaInSector
public static double areaInSector(double distanceA, double distanceB, int rayCount)
Calculates the triangle area in a sector between two rays given the two distances of the outer edges and the amount of all rays. The points have to lay on consecutive rays hence the need for a fix throughinBetween(DiscreteGene, DiscreteGene)
before invoking this method.- Parameters:
distanceA
- first outer edge distancedistanceB
- second outer edge distancerayCount
- amount of rays, gives the inner degree of the triangle- Returns:
- triangle area in a sector given two point distances
-
areaCovered
public static double areaCovered(List<DiscreteGene> points)
Calculates the maximised area covered by the points. A covered area in a sector is the area of the triangle formed between two points on the rays limiting the sector and the origin. This fitness maximises a area already covered and every time a sector is explored again, the area already covered is subtracted to induce larger areas being visited the next time in a same sector.- Parameters:
points
- list of points distributed on consecutive rays- Returns:
- maximised area covered by the points
-
newAreaCovered
public static double newAreaCovered(List<DiscreteGene> points)
Computes the sum of newly covered area per step of the chromosome.- Parameters:
points
- path of the chromosome- Returns:
- sum of the newly covered area per step
-
worstCase
public static double worstCase(List<DiscreteGene> points, float minDistance)
Calculates the worst case trace length of a trace barely missing a treasure.- Parameters:
points
- list of points forming a pathminDistance
- minimum distance a worst case is placed away from the origin- Returns:
- worst case scenario fitness
-
worstCaseMean
public static double worstCaseMean(List<DiscreteGene> points, float epsilon)
Compute the mean worst case over all points in the strategy.- Parameters:
points
- list of points of the strategyepsilon
- distance the worst case is missed by- Returns:
- mean worst case fitness
-
-