public class PolygonChromosome extends AbstractListChromosome<Polygon>
Constructor and Description |
---|
PolygonChromosome(List<Polygon> representation) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkValidity(List<Polygon> chromosomeRepresentation)
Asserts that
representation can represent a valid chromosome. |
void |
draw(Graphics2D g,
int width,
int height) |
double |
fitness()
Calculate the fitness function for this chromosome.
|
List<Polygon> |
getPolygonRepresentation()
Return the internal representation, which is needed for our custom mutation policy.
|
AbstractListChromosome<Polygon> |
newFixedLengthChromosome(List<Polygon> chromosomeRepresentation)
Creates a new instance of the same class as
this is, with a given arrayRepresentation . |
static Chromosome |
randomChromosome(int polygonLength,
int polygonCount) |
static void |
setRefImage(BufferedImage ref) |
static void |
setTestImage(BufferedImage image) |
String |
toString() |
getLength, getRepresentation
compareTo, findSameChromosome, getFitness, isSame, searchForFitnessUpdate
public static void setRefImage(BufferedImage ref)
public static void setTestImage(BufferedImage image)
protected void checkValidity(List<Polygon> chromosomeRepresentation) throws MathIllegalArgumentException
AbstractListChromosome
representation
can represent a valid chromosome.checkValidity
in class AbstractListChromosome<Polygon>
chromosomeRepresentation
- representation of the chromosomeMathIllegalArgumentException
- iff the representation
can not represent a valid chromosomepublic AbstractListChromosome<Polygon> newFixedLengthChromosome(List<Polygon> chromosomeRepresentation)
AbstractListChromosome
this
is, with a given arrayRepresentation
.
This is needed in crossover and mutation operators, where we need a new instance of the same class, but with
different array representation.
Usually, this method just calls a constructor of the class.
newFixedLengthChromosome
in class AbstractListChromosome<Polygon>
chromosomeRepresentation
- the inner array representation of the new chromosome.public List<Polygon> getPolygonRepresentation()
public double fitness()
For this purpose, we first draw the polygons on the test buffer, and then compare the resulting image pixel by pixel with the reference image.
public void draw(Graphics2D g, int width, int height)
public String toString()
AbstractListChromosome
toString
in class AbstractListChromosome<Polygon>
public static Chromosome randomChromosome(int polygonLength, int polygonCount)
Copyright © 2016 Hipparchus.org. All rights reserved.