fitness

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fitness provides an interface for a fitness function as well as an implementation of a fitness function that is used in the algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheData

type CacheData interface {
	Equals(data CacheData) bool
	Hash() uint64
	Data() float64
	CachedHash() uint32
	SetCachedHash(uint32 uint32)
}

type CacheFunction

type CacheFunction interface {
	Function

	SetBase(function CacheFunction)
	Cache() []CacheData
	SetCache([]CacheData)
}

A CacheFunction represents a fitness function that caches data for efficiency.

func NewTrianglesImageFunction

func NewTrianglesImageFunction(target image.Data, blockSize int) CacheFunction

NewTrianglesImageFunction returns a new fitness function.

func PolygonsImageFunctions

func PolygonsImageFunctions(target image.Data, blockSize, n int) []CacheFunction

func TrianglesImageFunctions

func TrianglesImageFunctions(target image.Data, blockSize, n int) []CacheFunction

TrianglesImageFunctions returns an array of fitness functions.

type Function

type Function interface {
	// Calculate evaluates a point group and returns a fitness.
	Calculate(data PointsData) float64
}

A Function represents a fitness function to evaluate a point group.

type PointsData

type PointsData struct {
	Points    normgeom.NormPointGroup
	Mutations []mutation.Mutation
}

PointsData stores data regarding a point group, and is used by the fitness function.

type PolygonCacheData

type PolygonCacheData struct {
	// contains filtered or unexported fields
}

func (PolygonCacheData) CachedHash

func (p PolygonCacheData) CachedHash() uint32

func (PolygonCacheData) Data

func (p PolygonCacheData) Data() float64

func (PolygonCacheData) Equals

func (p PolygonCacheData) Equals(other CacheData) bool

Equals returns if the TriangleCacheData is equal to another.

func (PolygonCacheData) Hash

func (p PolygonCacheData) Hash() uint64

Hash calculates the hash code of a TriangleCacheData.

func (*PolygonCacheData) SetCachedHash

func (p *PolygonCacheData) SetCachedHash(hash uint32)

type TriangleCacheData

type TriangleCacheData struct {
	// contains filtered or unexported fields
}

TriangleCacheData stores the triangles vertices and its fitness, and is used to cache calculations.

func (TriangleCacheData) CachedHash

func (t TriangleCacheData) CachedHash() uint32

func (TriangleCacheData) Data

func (t TriangleCacheData) Data() float64

func (TriangleCacheData) Equals

func (t TriangleCacheData) Equals(other CacheData) bool

Equals returns if the TriangleCacheData is equal to another.

func (TriangleCacheData) Hash

func (t TriangleCacheData) Hash() uint64

Hash calculates the hash code of a TriangleCacheData.

func (*TriangleCacheData) SetCachedHash

func (t *TriangleCacheData) SetCachedHash(hash uint32)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL