Documentation ¶
Overview ¶
Package maze provides the maze solving experiments based on NEAT methodology with Novelty Search and Fitness based optimization.
Index ¶
- Variables
- func NewMazeObjectiveEvaluator(out string, mazeEnv *Environment, numSpeciesTarget, compatAdjustFreq int) (experiment.GenerationEvaluator, experiment.TrialRunObserver)
- func NewNoveltySearchEvaluator(out string, mazeEnv *Environment, numSpeciesTarget, compatAdjustFreq int) (experiment.GenerationEvaluator, experiment.TrialRunObserver)
- func NewSafeNSEvaluator(out string, mazeEnv *Environment, objFuncGenome *genetics.Genome, ...) (experiment.GenerationEvaluator, experiment.TrialRunObserver)
- type Agent
- type AgentRecord
- type Environment
- type Line
- type Point
- type RecordStore
Constants ¶
This section is empty.
Variables ¶
var ErrOutputIsNaN = errors.New("OUTPUT is NAN")
ErrOutputIsNaN to be returned if one of the network output values is NaN
var NoveltyMetric neatns.NoveltyMetric = func(x, y *neatns.NoveltyItem) float64 {
diff := histDiff(x.Data, y.Data)
return diff
}
NoveltyMetric the novelty metric function for maze simulation
Functions ¶
func NewMazeObjectiveEvaluator ¶
func NewMazeObjectiveEvaluator(out string, mazeEnv *Environment, numSpeciesTarget, compatAdjustFreq int) (experiment.GenerationEvaluator, experiment.TrialRunObserver)
NewMazeObjectiveEvaluator allows creating maze solving agent based on Novelty Search optimization. It will use provided MazeEnv to run simulation of the maze environment. The numSpeciesTarget specifies the target number of species to maintain in the population. If the number of species differ from the numSpeciesTarget it will be automatically adjusted with compatAdjustFreq frequency, i.e., at each epoch % compatAdjustFreq == 0
func NewNoveltySearchEvaluator ¶
func NewNoveltySearchEvaluator(out string, mazeEnv *Environment, numSpeciesTarget, compatAdjustFreq int) (experiment.GenerationEvaluator, experiment.TrialRunObserver)
NewNoveltySearchEvaluator allows creating maze solving agent based on Novelty Search optimization. It will use provided MazeEnv to run simulation of the maze environment. The numSpeciesTarget specifies the target number of species to maintain in the population. If the number of species differ from the numSpeciesTarget it will be automatically adjusted with compatAdjustFreq frequency, i.e., at each epoch % compatAdjustFreq == 0
func NewSafeNSEvaluator ¶ added in v4.0.2
func NewSafeNSEvaluator(out string, mazeEnv *Environment, objFuncGenome *genetics.Genome, objFuncOpts *neat.Options, numSpeciesTarget, compatAdjustFreq int) (experiment.GenerationEvaluator, experiment.TrialRunObserver)
NewSafeNSEvaluator allows creating maze solving agent using SAFE commensalistic coevolution method. It will use provided MazeEnv to run simulation of the maze environment. The objFuncGenome provided defines the start genome to be used for evolution of population of candidates into objective functions. The numSpeciesTarget specifies the target number of species to maintain in the population. If the number of species differ from the numSpeciesTarget it will be automatically adjusted with compatAdjustFreq frequency, i.e., at each epoch % compatAdjustFreq == 0
Types ¶
type Agent ¶
type Agent struct { // The current location Location Point // The heading direction in degrees Heading float64 // The speed of agent Speed float64 // The angular velocity AngularVelocity float64 // The radius of agent body Radius float64 // The maximal range of range finder sensors RangeFinderRange float64 // The angles of range finder sensors RangeFinderAngles []float64 // The beginning angles for radar sensors RadarAngles1 []float64 // The ending angles for radar sensors RadarAngles2 []float64 // stores radar outputs Radar []float64 // stores rangefinder outputs RangeFinders []float64 }
Agent represents the maze navigator agent
type AgentRecord ¶
type AgentRecord struct { // The ID of agent AgentID int // The agent position at the end of simulation X, Y float64 // The agent fitness Fitness float64 // The flag to indicate whether agent reached maze exit GotExit bool // The population generation when agent data was collected Generation int // The novelty value associated Novelty float64 // The ID of species to whom individual belongs SpeciesID int // The age of species to whom individual belongs at time of recording SpeciesAge int }
AgentRecord is the record holding info about individual maze agent performance at the end of simulation
type Environment ¶
type Environment struct { // The maze navigating agent Hero Agent // The maze line segments Lines []Line // The maze exit - goal MazeExit Point // The flag to indicate if exit was found ExitFound bool // The number of time steps to be executed during maze solving simulation TimeSteps int // The sample step size to determine when to collect subsequent samples during simulation SampleSize int // The range around maze exit point to test if agent coordinates is within to be considered as solved successfully (5.0 is good enough) ExitFoundRange float64 // contains filtered or unexported fields }
Environment the maze environment definition
func ReadEnvironment ¶
func ReadEnvironment(ir io.Reader) (*Environment, error)
ReadEnvironment reads maze environment from the reader
func (*Environment) AgentDistanceToExit ¶
func (e *Environment) AgentDistanceToExit() float64
AgentDistanceToExit used for fitness calculations based on distance of maze Agent to the target maze exit
func (*Environment) ApplyOutputs ¶
func (e *Environment) ApplyOutputs(o1, o2 float64) error
ApplyOutputs transform neural net outputs into angular velocity and speed
func (*Environment) GetInputs ¶
func (e *Environment) GetInputs() ([]float64, error)
GetInputs create neural net inputs from maze agent sensors
func (*Environment) Update ¶
func (e *Environment) Update() error
Update does one time step of the simulation
type Line ¶
type Line struct {
A, B Point
}
Line the simple line segment class, used for maze walls
func (Line) Intersection ¶
Intersection calculates point of intersection between two line segments if it exists
type Point ¶
type Point struct {
X, Y float64
}
Point the simple point class
func (Point) Angle ¶
Angle is to determine angle in degrees of vector defined by (0,0)->This Point. The angle is from 0 to 360 degrees anti-clockwise.
type RecordStore ¶
type RecordStore struct { // The array of agent records Records []AgentRecord // The array of the solver agent path points SolverPathPoints []Point }
RecordStore the maze agent records storage