neatns

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package neatns contains Novelty Search implementation for NEAT method of ANN's evolving

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoNovelItems   = errors.New("no novel items to print")
	ErrNoFittestItems = errors.New("no fittest items to print")
)

Functions

This section is empty.

Types

type ItemsDistance

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

ItemsDistance the structure to hold distance between two items

type ItemsDistances

type ItemsDistances []ItemsDistance

ItemsDistances the sortable list of distances between two items

func (ItemsDistances) Len

func (f ItemsDistances) Len() int

func (ItemsDistances) Less

func (f ItemsDistances) Less(i, j int) bool

func (ItemsDistances) Swap

func (f ItemsDistances) Swap(i, j int)

type NoveltyArchive

type NoveltyArchive struct {
	// NovelItems all the novel items we have found so far
	NovelItems []*NoveltyItem
	// FittestItems all novel items from the fittest organisms found so far
	FittestItems NoveltyItemsByFitness

	// Generation the current generation
	Generation int
	// contains filtered or unexported fields
}

NoveltyArchive The novelty archive contains all the novel items we have encountered thus far. Using a novelty metric we can determine how novel a new item is compared to everything currently in the novelty set

func NewNoveltyArchive

func NewNoveltyArchive(threshold float64, metric NoveltyMetric, options NoveltyArchiveOptions) *NoveltyArchive

NewNoveltyArchive creates new instance of novelty archive

func (*NoveltyArchive) DumpFittest

func (a *NoveltyArchive) DumpFittest(w io.Writer) error

DumpFittest dumps collected novelty points of individuals with maximal fitness found during evolution

func (*NoveltyArchive) DumpNoveltyPoints

func (a *NoveltyArchive) DumpNoveltyPoints(w io.Writer) error

DumpNoveltyPoints dumps collected novelty points to the provided writer as JSON

func (*NoveltyArchive) EndOfGeneration

func (a *NoveltyArchive) EndOfGeneration()

EndOfGeneration the steady-state end of generation call

func (*NoveltyArchive) EvaluateIndividualNovelty

func (a *NoveltyArchive) EvaluateIndividualNovelty(org *genetics.Organism, pop *genetics.Population, onlyFitness bool)

EvaluateIndividualNovelty evaluates the novelty of a single individual organism within population and update its fitness (onlyFitness = true) or store individual's novelty item into archive

func (*NoveltyArchive) EvaluatePopulationNovelty

func (a *NoveltyArchive) EvaluatePopulationNovelty(pop *genetics.Population, onlyFitness bool)

EvaluatePopulationNovelty evaluates the novelty of the whole population and update organisms fitness (onlyFitness = true) or store each population individual's novelty items into archive

func (*NoveltyArchive) UpdateFittestWithOrganism

func (a *NoveltyArchive) UpdateFittestWithOrganism(org *genetics.Organism) error

UpdateFittestWithOrganism to maintain list of the fittest organisms so far

type NoveltyArchiveOptions

type NoveltyArchiveOptions struct {
	// KNNNoveltyScore how many nearest neighbors to consider for calculating novelty score, i.e., for how many
	// neighbors to look at for N-nearest neighbor distance novelty
	KNNNoveltyScore int
	// FittestAllowedSize the maximal allowed size for fittest items list
	FittestAllowedSize int
	// ArchiveSeedAmount is the minimal number of seed novelty items to start from
	ArchiveSeedAmount int
}

NoveltyArchiveOptions defines options to be used by NoveltyArchive

func DefaultNoveltyArchiveOptions

func DefaultNoveltyArchiveOptions() NoveltyArchiveOptions

DefaultNoveltyArchiveOptions is to create default NoveltyArchiveOptions

type NoveltyItem

type NoveltyItem struct {

	// The generation when item was added to archive
	Generation int `json:"generation"`

	// The ID of associated individual organism */
	IndividualID int `json:"individual_id"`

	// The fitness of the associated organism
	Fitness float64 `json:"fitness"`
	// The novelty of this item
	Novelty float64 `json:"novelty"`
	// The item's age
	Age float64 `json:"age"`

	// The data associated with item
	Data []float64 `json:"data"`
	// contains filtered or unexported fields
}

NoveltyItem is the data holder for novel item's genome and phenotype

func NewNoveltyItem

func NewNoveltyItem() *NoveltyItem

NewNoveltyItem creates new novelty item

func (NoveltyItem) String

func (ni NoveltyItem) String() string

Stringer

type NoveltyItemsByFitness

type NoveltyItemsByFitness []*NoveltyItem

NoveltyItemsByFitness the sortable list of novelty items by fitness

func (NoveltyItemsByFitness) Len

func (f NoveltyItemsByFitness) Len() int

func (NoveltyItemsByFitness) Less

func (f NoveltyItemsByFitness) Less(i, j int) bool

func (NoveltyItemsByFitness) Swap

func (f NoveltyItemsByFitness) Swap(i, j int)

type NoveltyMetric

type NoveltyMetric func(x, y *NoveltyItem) float64

NoveltyMetric The novelty metric function type. The function to compare two novelty items and return distance/difference between them

Jump to

Keyboard shortcuts

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