experiments

package
v0.0.0-...-bb33bbf Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

The experiments package holds various experiments with NEAT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OutDirForTrial

func OutDirForTrial(outDir string, trialID int) string

To provide standard output directory syntax based on current trial Method checks if directory should be created

Types

type ActionType

type ActionType byte

The type of action to be applied to environment

const (
	// The continuous action type meaning continuous values to be applied to environment
	ContinuousAction ActionType = iota
	// The discrete action assumes that there are only discrete values of action (e.g. 0, 1)
	DiscreteAction
)

The supported action types

type Experiment

type Experiment struct {
	Id   int
	Name string
	Trials
}

An Experiment is a collection of trials for one experiment. It's useful for statistical analysis of a series of experiments

func (*Experiment) AvgEpochDuration

func (e *Experiment) AvgEpochDuration() time.Duration

Calculates average duration of evaluations among all generations of organism populations in this experiment

func (*Experiment) AvgGenerationsPerTrial

func (e *Experiment) AvgGenerationsPerTrial() int

Calculates average number of generations evaluated per trial during this experiment. This can be helpful when estimating algorithm efficiency, because when winner organism is found the trial is terminated, i.e. less evaluations - more fast convergence.

func (*Experiment) AvgTrialDuration

func (e *Experiment) AvgTrialDuration() time.Duration

Calculates average duration of experiment's trial Note, that most trials finish after solution solved, so this metric can be used to represent how efficient the solvers was generated

func (*Experiment) AvgWinner

func (e *Experiment) AvgWinner() (avg_nodes, avg_genes, avg_evals, avg_diversity float64)

Returns average number of nodes, genes, organisms evaluations, and species diversity of winner genomes among all trials, i.e. for all trials where winning solution was found

func (*Experiment) BestAge

func (e *Experiment) BestAge() Floats

The age values of the organisms for each trial

func (*Experiment) BestComplexity

func (e *Experiment) BestComplexity() Floats

The complexity values of the best organisms for each trial

func (*Experiment) BestFitness

func (e *Experiment) BestFitness() Floats

The fitness values of the best organisms for each trial

func (*Experiment) BestOrganism

func (e *Experiment) BestOrganism(onlySolvers bool) (*genetics.Organism, int, bool)

Finds the most fit organism among all epochs in this trial. It's also possible to get the best organism only among the ones which was able to solve the experiment's problem. Returns the best fit organism in this experiment among with ID of trial where it was found and boolean value to indicate if search was successful.

func (*Experiment) Decode

func (ex *Experiment) Decode(dec *gob.Decoder) error

Decodes experiment data

func (*Experiment) Diversity

func (e *Experiment) Diversity() Floats

Diversity returns the average number of species in each trial

func (*Experiment) Encode

func (ex *Experiment) Encode(enc *gob.Encoder) error

Encodes experiment with GOB encoding

func (*Experiment) Epochs

func (e *Experiment) Epochs() Floats

Trials returns the number of epochs in each trial

func (*Experiment) Execute

func (ex *Experiment) Execute(context *neat.NeatContext, start_genome *genetics.Genome, executor interface{}) (err error)

The Experiment execution entry point

func (*Experiment) LastExecuted

func (e *Experiment) LastExecuted() time.Time

Returns time of last trial's execution

func (*Experiment) PrintStatistics

func (ex *Experiment) PrintStatistics()

Prints experiment statistics

func (*Experiment) Read

func (ex *Experiment) Read(r io.Reader) error

Reads experiment data from provided reader and decodes it

func (*Experiment) Solved

func (e *Experiment) Solved() bool

func (*Experiment) TrialsSolved

func (e *Experiment) TrialsSolved() int

The number of trials solved

func (*Experiment) Write

func (ex *Experiment) Write(w io.Writer) error

Encodes experiment and writes to provided writer

type Experiments

type Experiments []Experiment

Experiments is a sortable list of experiments by execution time and Id

func (Experiments) Len

func (es Experiments) Len() int

func (Experiments) Less

func (es Experiments) Less(i, j int) bool

func (Experiments) Swap

func (es Experiments) Swap(i, j int)

type Floats

type Floats []float64

Floats provides descriptive statistics on a slice of float64 values

func (Floats) Max

func (x Floats) Max() float64

Max returns the greatest value in the slice

func (Floats) Mean

func (x Floats) Mean() float64

Mean returns the average of the values in the slice

func (Floats) Median

func (x Floats) Median() float64

Median returns the middle value in the slice

func (Floats) Min

func (x Floats) Min() float64

Min returns the smallest value in the slice

func (Floats) Q25

func (x Floats) Q25() float64

func (Floats) Q75

func (x Floats) Q75() float64

func (Floats) Stdev

func (x Floats) Stdev() float64

Stdev returns the standard deviation of the values in the slice

func (Floats) Sum

func (x Floats) Sum() float64

Sum returns the total of the values in the slice

func (Floats) Variance

func (x Floats) Variance() float64

Variance returns the variance of the values in the slice

type Generation

type Generation struct {
	// The generation ID for this epoch
	Id int
	// The time when epoch was evaluated
	Executed time.Time
	// The elapsed time between generation execution start and finish
	Duration time.Duration
	// The best organism of best species
	Best *genetics.Organism
	// The flag to indicate whether experiment was solved in this epoch
	Solved bool

	// The list of organisms fitness values per species in population
	Fitness Floats
	// The age of organisms per species in population
	Age Floats
	// The list of organisms complexities per species in population
	Compexity Floats

	// The number of species in population at the end of this epoch
	Diversity int

	// The number of evaluations done before winner found
	WinnerEvals int
	// The number of nodes in winner genome or zero if not solved
	WinnerNodes int
	// The numbers of genes (links) in winner genome or zero if not solved
	WinnerGenes int

	// The ID of Trial this Generation was evaluated in
	TrialId int
}

The structure to represent execution results of one generation

func (*Generation) Average

func (epoch *Generation) Average() (fitness, age, complexity float64)

Returns average fitness, age, and complexity among all organisms from population at the end of this epoch

func (*Generation) Decode

func (epoch *Generation) Decode(dec *gob.Decoder) error

func (*Generation) Encode

func (epoch *Generation) Encode(enc *gob.Encoder) error

Encodes generation with provided GOB encoder

func (*Generation) FillPopulationStatistics

func (epoch *Generation) FillPopulationStatistics(pop *genetics.Population)

Collects statistics about given population

type GenerationEvaluator

type GenerationEvaluator interface {
	// Invoked to evaluate one generation of population of organisms within given
	// execution context.
	GenerationEvaluate(pop *genetics.Population, epoch *Generation, context *neat.NeatContext) (err error)
}

The interface describing evaluator for one generation of evolution.

type Generations

type Generations []Generation

Generations is a sortable collection of generations by execution time and Id

func (Generations) Len

func (is Generations) Len() int

func (Generations) Less

func (is Generations) Less(i, j int) bool

func (Generations) Swap

func (is Generations) Swap(i, j int)

type Trial

type Trial struct {
	// The trial number
	Id int
	// The results per generation in this trial
	Generations Generations
	// The winner generation
	WinnerGeneration *Generation

	// The elapsed time between trial start and finish
	Duration time.Duration
}

The structure to hold statistics about one experiment run (trial)

func (*Trial) Average

func (t *Trial) Average() (fitness, age, complexity Floats)

Returns average fitness, age, and complexity of population of organisms for each epoch in this trial

func (*Trial) AvgEpochDuration

func (t *Trial) AvgEpochDuration() time.Duration

Calculates average duration of evaluations among all generations of organism populations in this trial

func (*Trial) BestAge

func (t *Trial) BestAge() Floats

Age returns the age of the best species for each epoch in this trial

func (*Trial) BestComplexity

func (t *Trial) BestComplexity() Floats

Complexity returns the complexity of the best species for each epoch in this trial

func (*Trial) BestFitness

func (t *Trial) BestFitness() Floats

Fitness returns the fitnesses of the best organisms for each epoch in this trial

func (*Trial) BestOrganism

func (t *Trial) BestOrganism(onlySolvers bool) (*genetics.Organism, bool)

Finds the most fit organism among all epochs in this trial. It's also possible to get the best organism only among the ones which was able to solve the experiment's problem.

func (*Trial) Decode

func (t *Trial) Decode(dec *gob.Decoder) error

Decodes trial data

func (*Trial) Diversity

func (t *Trial) Diversity() Floats

Diversity returns number of species for each epoch

func (*Trial) Encode

func (t *Trial) Encode(enc *gob.Encoder) error

Encodes this trial

func (*Trial) LastExecuted

func (t *Trial) LastExecuted() time.Time

func (*Trial) Solved

func (t *Trial) Solved() bool

func (*Trial) Winner

func (t *Trial) Winner() (nodes, genes, evals, diversity int)

Returns number of nodes, genes, organism evaluations and species diversity in the winner genome

type TrialRunObserver

type TrialRunObserver interface {
	// Invoked to notify that new trial run just started before any epoch evaluation in that trial run
	TrialRunStarted(trial *Trial)
}

The interface to describe trial lifecycle observer interested to receive lifecycle notifications

type Trials

type Trials []Trial

Trials is a sortable collection of experiment runs (trials) by execution time and id

func (Trials) Len

func (ts Trials) Len() int

func (Trials) Less

func (ts Trials) Less(i, j int) bool

func (Trials) Swap

func (ts Trials) Swap(i, j int)

Directories

Path Synopsis
The pole balancing experiments is classic Reinforced Learning task proposed by Richard Sutton and Charles Anderson.
The pole balancing experiments is classic Reinforced Learning task proposed by Richard Sutton and Charles Anderson.
The XOR experiment serves to actually check that network topology actually evolves and everything works as expected.
The XOR experiment serves to actually check that network topology actually evolves and everything works as expected.

Jump to

Keyboard shortcuts

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