unique

package
v0.0.0-...-b9e61c6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefGraph is the starting point for
	// all NewGraph calls prior to options
	// being applied.
	DefGraph = &Graph{
		nodes:       []Node{},
		MinDistance: 1,
	}
)

Functions

This section is empty.

Types

type EnvInd

type EnvInd struct {
	*env.F

	*Graph
	// contains filtered or unexported fields
}

EnvInd is a wrapper around a float env that can be a member of a population

func NewEnvInd

func NewEnvInd(size int, baseVal float64, g *Graph) *EnvInd

NewEnvInd initializes a EnvInd

func (*EnvInd) CanCrossover

func (ei *EnvInd) CanCrossover(other pop.Individual) bool

CanCrossover always returns false for a EnvInd

func (*EnvInd) Crossover

func (ei *EnvInd) Crossover(other pop.Individual) pop.Individual

func (*EnvInd) Fitness

func (ei *EnvInd) Fitness(input, expected [][]float64) int

func (*EnvInd) Mutate

func (ei *EnvInd) Mutate()

func (*EnvInd) Print

func (ei *EnvInd) Print()

Print prints a EnvInd

type Graph

type Graph struct {
	MinDistance float64
	// contains filtered or unexported fields
}

A Graph represents a set of nodes which are sufficiently unique from one-another.

func NewGraph

func NewGraph(opts ...Option) *Graph

NewGraph returns a graph starting with default options (see DefGraph) and modified by the input options.

func (*Graph) Add

func (g *Graph) Add(n Node) (ok bool)

Add may add the given node to the graph. if the node is too close to an existing graph node, it will not be added. ok reports whether the node was added.

func (*Graph) CanAdd

func (g *Graph) CanAdd(n Node) bool

func (*Graph) Copy

func (g *Graph) Copy() *Graph

Copy returns a copy of the receiver graph

func (*Graph) Distance

func (g *Graph) Distance(n Node) float64

Distance reports the minimum distance from the node n to the nodes present in the graph g.

type Node

type Node interface {
	// Distance reports the distance from this
	// node to another, along with whether the
	// comparison is a valid comparison-- if not,
	// the distance is meaningless.
	Distance(Node) (float64, bool)
}

A Node can determine how closely related other nodes are to itself

type Option

type Option func(*Graph)

func MinDistance

func MinDistance(i float64) Option

type Render

type Render struct {
	*Graph
	*render.CompositeR
}

func (*Render) SetGraph

func (r *Render) SetGraph(g *Graph)

func (*Render) UnDraw

func (r *Render) UnDraw()

type RenderNode

type RenderNode interface {
	Node
	GetR() render.Renderable
}

A RenderNode can act as a Node and a screen Renderable

Jump to

Keyboard shortcuts

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