env

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env interface {
	Copy() Env
	Diff([]float64) Env
	MatchDiff([]float64) Env
	New([]float64) Env
}

An Env represents a slice of values which can be modified by a slice of float64s or return a patterned difference between a slice of float64s and the Env

type F

type F []*float64

F returns a float-valued environment

func AverageF

func AverageF(envs ...*F) *F

AverageF returns an F that holds the average of the input Fs

func NewF

func NewF(size int, baseVal float64) *F

NewF creates an environment

func (*F) Add

func (env *F) Add(s float64) *F

func (*F) AddF

func (env *F) AddF(envs ...*F) *F

func (*F) Copy

func (env *F) Copy() *F

Copy returns a copy of F.

func (*F) Diff

func (env *F) Diff(envDiff []float64) int

Diff returns the absolute difference between the given environment and the passed in expectations. 0 in envDiff is treated as insignificant.

func (*F) DiffSingle

func (env *F) DiffSingle(f float64) int

DiffSingle returns the sum of the difference between f and each element in the environment

func (*F) Divide

func (env *F) Divide(s float64) *F

func (*F) DivideF

func (env *F) DivideF(envs ...*F) *F

func (*F) Get

func (env *F) Get(i int) float64

func (*F) GetBinary

func (env *F) GetBinary(i int) float64

func (*F) GetP

func (env *F) GetP(i int) *float64

func (*F) Len

func (env *F) Len() int

func (*F) Mult

func (env *F) Mult(s float64) *F

func (*F) MultF

func (env *F) MultF(envs ...*F) *F

func (*F) Mutate

func (env *F) Mutate(chance float64, mutator mut.FloatMutator) *F

func (*F) New

func (env *F) New(envDiff []float64) *F

New creates a combined environment by the given envDiff inputs and returns a new environment pointer

func (*F) Randomize

func (env *F) Randomize(min *F, max *F)

Randomize sets env[i] to a unfiorm sample between min[i] and max[i] for all i

func (*F) RandomizeSingle

func (env *F) RandomizeSingle(mn float64, mx float64)

RandomizeSingle sets env[i] to a uniform sample between mn and max for all i

func (*F) Reinforce

func (env *F) Reinforce(learningRate float64, envs ...*F) *F

Reinforce updates each value in env to be learningRate closer to env2.

func (*F) Set

func (env *F) Set(i int, f float64)

func (*F) SetAll

func (env *F) SetAll(f float64)

SetAll sets each value behind the environment to f

func (*F) SetMap

func (env *F) SetMap(m map[int]float64)

SetMap sets values behind the environment according to index:value pairs

func (*F) SetP

func (env *F) SetP(i int, f *float64)

func (*F) String

func (env *F) String() string

func (*F) Sub

func (env *F) Sub(s float64) *F

func (*F) SubF

func (env *F) SubF(envs ...*F) *F

func (*F) ToEnv

func (env *F) ToEnv() *F

ToEnv is an assistant function for structs composed with F for interfaces to obtain their F

func (*F) ToIntRandom

func (env *F) ToIntRandom() *I

ToIntRandom treats the environment as a set of probabilities, and creates an env.I where each element has a env[i] percent chance of being 1, else 0.

type I

type I []*int

I represents an integer-valued environment

func NewI

func NewI(size int, baseVal int) *I

NewI constructs an I with a baseValue at each space

func (*I) Copy

func (env *I) Copy() *I

Copy copies an integer environment

func (*I) Diff

func (env *I) Diff(envDiff []float64) (diff int)

Diff returns the absolute difference between the given environment and the passed in expectations. 0 in envDiff is treated as insignificant.

func (*I) MatchDiff

func (env *I) MatchDiff(envDiff []float64) (diff int)

MatchDiff compares each element in envDiff and env and returns the number of elements which are not the same.

func (*I) New

func (env *I) New(envDiff []float64) *I

New Creates a combined environment by the given envDiff inputs and returns a new environment pointer

func (*I) String

func (env *I) String() string

Jump to

Keyboard shortcuts

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