Documentation ¶
Index ¶
- func And(opts ...Option) func(Model)
- func AttemptsAfterBest(i int) func(Model)
- func BaseValue(bv float64) func(Model)
- func BitStringBivariate(samples []*env.F, a, b int) (float64, float64)
- func ConditionedBSEnv(senv, tenv, fenv *env.F, a int) *env.F
- func DefContinue(m Model) bool
- func DefReport(m Model)
- func FMutator(mtr mut.FloatMutator) func(Model)
- func FitnessFunc(f Fitness) func(Model)
- func GetSample(e *env.F) *env.F
- func GoalFitness(gf int) func(Model)
- func LMutator(mtr mut.FloatMutator) func(Model)
- func LearningRate(lr float64) func(Model)
- func LearningSamples(l int) func(Model)
- func Length(l int) func(Model)
- func MaxIterations(j int) func(Model)
- func MemberEnvs(mem []pop.Individual) []*env.F
- func MutationRate(mr float64) func(Model)
- func NSamples(n int, senv *env.F) []*env.F
- func Name(s string) func(Model)
- func PopEnvs(p *pop.Population) []*env.F
- func Randomize(r bool) func(Model)
- func ReportFunc(r func(Model)) func(Model)
- func SampleFitnesses(m Model, samples []*env.F) ([]int, []*env.F)
- func Samples(s int) func(Model)
- func SelectionMethod(sm selection.Method) func(Model)
- func StopCondition(c func(m Model) bool) func(Model)
- func TrackBest(m Model)
- func TrackFitnessRuns(b bool) func(Model)
- func TrackTime(m Model)
- func UnivariateFromSamples(samples []*env.F, a int) float64
- type BMDA
- func (bmda *BMDA) Adjust() Model
- func (bmda *BMDA) BMDAPop(roots []int, children [][]int) []*env.F
- func (bmda *BMDA) ChiSquared(a, b int) float64
- func (bmda *BMDA) GetSample(tenv, fenv *env.F, roots []int, children [][]int) *env.F
- func (bmda *BMDA) NSamples(n int, tenv, fenv *env.F, roots []int, children [][]int) []*env.F
- func (bmda *BMDA) SetChildSample(senv, tenv, fenv *env.F, children [][]int, parent int)
- func (bmda *BMDA) SetChildren(samples []*env.F, tenv, fenv *env.F, children [][]int, parent int)
- func (bmda *BMDA) UpdateFromPop()
- type BOA
- type Base
- func (b *Base) Adjust() Model
- func (b *Base) BaseModel() *Base
- func (b *Base) Continue() bool
- func (b *Base) Fitness() int
- func (b *Base) GenIndices() []int
- func (b *Base) Mutate()
- func (b *Base) Pop() *pop.Population
- func (b *Base) ReplaceLowFitnesses(p *pop.Population, newMembers []*env.F)
- func (b *Base) SelectLearning(p *pop.Population) []pop.Individual
- type BayesNet
- func (bn *BayesNet) Prob(i int, curSample *env.F, samples []*env.F) float64
- func (bn *BayesNet) Sample(curSamples []*env.F, n int) []*env.F
- func (bn *BayesNet) SampleOrdered(samples []*env.F, ordered []int) *env.F
- func (bn *BayesNet) Topographical() []int
- func (bn *BayesNet) TryConnect(samples []*env.F, index int) (float64, int)
- func (bn *BayesNet) ViableParents(index int) []int
- type BestCandidates
- type BivariateEnv
- type CGA
- type Candidate
- type ComplexDiff
- type ComplexHeap
- type ECGA
- func (ecga *ECGA) Adjust() Model
- func (ecga *ECGA) BlockComplexity(envs []*env.F, b []int) float64
- func (ecga *ECGA) CombinedComplexity(envs []*env.F, b []int) float64
- func (ecga *ECGA) ECGAPop() *pop.Population
- func (ecga *ECGA) MDMModel(selected []pop.Individual)
- func (ecga *ECGA) ModelComplexity(b []int) float64
- func (ecga *ECGA) Mutate()
- func (ecga *ECGA) UpdateMDM()
- type EDA
- type EnvInd
- type FitSample
- type Fitness
- type FullBivariateEnv
- type MIMIC
- type Model
- func BMDAModel(opts ...Option) (Model, error)
- func BOAModel(opts ...Option) (Model, error)
- func CGAModel(opts ...Option) (Model, error)
- func ECGAModel(opts ...Option) (Model, error)
- func Loop(eda EDA, opts ...Option) (Model, error)
- func MIMICModel(opts ...Option) (Model, error)
- func PBILModel(opts ...Option) (Model, error)
- func SHCLVNDModel(opts ...Option) (Model, error)
- func UMDAModel(opts ...Option) (Model, error)
- type Option
- type PBIL
- type SHCLVND
- type UMDA
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
And can be used to chain together multiple settings in order to prepackage common settings among several algorithms. Consider: should this be called Cons?
func AttemptsAfterBest ¶
AttemptsAfterBest terminates an EDA if it fails to improve on its best model after i iterations
func BitStringBivariate ¶
BitStringBivariate returns the probabilities p(a|b=t) and p(a|b=f)
func ConditionedBSEnv ¶
ConditionedBSEnv returns either tenv or fenv depending on the value at senv[a]
func FMutator ¶
func FMutator(mtr mut.FloatMutator) func(Model)
FMutator sets a model's float mutator
func FitnessFunc ¶
FitnessFunc is an option which sets the fitness function
func GetSample ¶
GetSample returns an environment candidate where each input element is treated as a percent from 0 to 1 inclusive, and each output is each input randomized to either 1 or 0.
func GoalFitness ¶
GoalFitness is an option which sets the goal fitness
func LMutator ¶
func LMutator(mtr mut.FloatMutator) func(Model)
LMutator sets a model's learning rate mutator
func LearningRate ¶
LearningRate is an option which sets the learning rate
func LearningSamples ¶
LearningSamples sets the number of learning samples the algorithm will use. learning samples should be less than samples.
func MaxIterations ¶
MaxIterations sets the maximum number of iterations the algorithm will evolve before preemptively stopping
func MemberEnvs ¶
func MemberEnvs(mem []pop.Individual) []*env.F
MemberEnvs converts a set of EnvInd members to a smaple array
func MutationRate ¶
MutationRate is an option which sets the mutation rate
func PopEnvs ¶
func PopEnvs(p *pop.Population) []*env.F
PopEnvs converts a population of EnvInd members to a sample array
func ReportFunc ¶
func SampleFitnesses ¶
SampleFitnesses returns a sorted list of fitnesses for the given samples in model m, and sorts samples so that the fitness of samples[i] is in fitnesses[i]
func SelectionMethod ¶
SelectionMethod sets the algorithm's population selection method for algorithms that use selection
func StopCondition ¶
StopCondition replaces the default stop condition (goal fitness reached or maximum iteration reached)
func TrackBest ¶
func TrackBest(m Model)
TrackBest sets whether or not the algorithm should keep track of the best model it has found so far
func TrackFitnessRuns ¶
TrackFitnessRuns tells the model to track how many times it calls its fitness function.
Types ¶
type BMDA ¶
type BMDA struct { Base BF FullBivariateEnv LastPop *pop.Population }
BMDA represents the Bivariate Marginal Distribution Algorithm
func (*BMDA) BMDAPop ¶
BMDAPop creates a population from the forest generated by a BMDA So we pick random (all) roots and go down through all of their children using their parents as the elements they are dependant on
func (*BMDA) ChiSquared ¶
ChiSquared on a bmda calculates a chi^2 value where the observed values are the unconditional bivariate probabilities and the expected values are the univariate probabilities multiplied together.
func (*BMDA) SetChildSample ¶
SetChildSample is used by GetSample to chain through all children in a tree
func (*BMDA) SetChildren ¶
SetChildren is used by BMDAPop to chain through all children in a tree
func (*BMDA) UpdateFromPop ¶
func (bmda *BMDA) UpdateFromPop()
UpdateFromPop regenerates bmda.F and bmda.BF using bmda.LastPop
type BOA ¶
type BOA struct { Base P *pop.Population }
BOA represents the Bayesian Optimization Algorithm
type Base ¶
Base is a struct which all EDA models should be composed of so that they can use generic option functions. Future work: create several kinds of bases, where each base satisfies a Base interface, where all options will call a Set function on the interface, so that models that do not want as many fields as Base provides do not need to have wasted memory in their structs.
func DefaultBase ¶
DefaultBase initializes some base fields to non-automatic zero values
func (*Base) BaseModel ¶
BaseModel is a function which is used by all Options to obtain the base from any given model. All models must implement BaseModel.
func (*Base) GenIndices ¶
GenIndices is a utility function to generate a list of ints 0 ... b.length
func (*Base) Pop ¶
func (b *Base) Pop() *pop.Population
Pop generates a population of EnvInds from sampling base.F
func (*Base) ReplaceLowFitnesses ¶
func (b *Base) ReplaceLowFitnesses(p *pop.Population, newMembers []*env.F)
ReplaceLowFitnesses sorts the given population members by fitness and replaces the lowest members of those with the newMembers.
func (*Base) SelectLearning ¶
func (b *Base) SelectLearning(p *pop.Population) []pop.Individual
SelectLearning selects b.learningSamples members from the given population
type BayesNet ¶
type BayesNet struct {
// contains filtered or unexported fields
}
This bayes net construction code is based on http://www.cleveralgorithms.com/nature-inspired/probabilistic/boa.html
func NewBayesNet ¶
func (*BayesNet) SampleOrdered ¶
func (*BayesNet) Topographical ¶
func (*BayesNet) TryConnect ¶
func (*BayesNet) ViableParents ¶
type BestCandidates ¶
BestCandidates represents the top N candidates sampled from an EDA. Todo: This should be a heap, not a linked list, for sufficiently large sizes
func NewBestCandidates ¶
func NewBestCandidates(m Model, bcsLimit int, sFunc func() *env.F) *BestCandidates
NewBestCandidates creates a default BestCandidates with model.samples samples added to the candidate list. if sFunc is not supplied, GetSample on a copy of the model's initial environment will be used.
func (*BestCandidates) Add ¶
func (bc *BestCandidates) Add(f int, c *env.F)
Add appends a new candidate to the best candidates, if it is better than any existing candidate
func (*BestCandidates) Slice ¶
func (bc *BestCandidates) Slice() []*env.F
Slice converts BestCandidates from a linked list to a slice
type BivariateEnv ¶
type BivariateEnv struct {
// contains filtered or unexported fields
}
BivariateEnv represents the relationship (a|b) for all b in some sample set
func NewBSBivariateEnv ¶
func NewBSBivariateEnv(samples []*env.F, a int) *BivariateEnv
NewBSBivariateEnv returns a bivariate environment from samples and a index a for (a|b)
type CGA ¶
type CGA struct {
Base
}
CGA is an EDA that implements the Compact Genetic Algorithm adjustment function
type ComplexDiff ¶
type ComplexDiff struct {
// contains filtered or unexported fields
}
ComplexDiff is a pair of indices and some value representing how valuable the pair is
type ComplexHeap ¶
type ComplexHeap []ComplexDiff
ComplexHeap is a heap of ComplexDiffs, heaped on their gain value
func (ComplexHeap) Len ¶
func (ch ComplexHeap) Len() int
func (ComplexHeap) Less ¶
func (ch ComplexHeap) Less(i, j int) bool
func (*ComplexHeap) Pop ¶
func (ch *ComplexHeap) Pop() interface{}
Pop is boilerplate for popping a heap
func (*ComplexHeap) Push ¶
func (ch *ComplexHeap) Push(x interface{})
Push is boilerplate for pushing to a heap
func (ComplexHeap) Swap ¶
func (ch ComplexHeap) Swap(i, j int)
type ECGA ¶
type ECGA struct { Base P *pop.Population Blocks [][]int }
ECGA represents the Extended Compact Genetic Algorithm
func (*ECGA) Adjust ¶
Adjust for an ecga creates an ecga population based on the ecga's understanding of its building blocks and then refreshes those building blocks
func (*ECGA) BlockComplexity ¶
BlockComplexity returns the complexity of a given block definition
func (*ECGA) CombinedComplexity ¶
CombinedComplexity returns the sum marginal complexity of the block's indices in the sample set
func (*ECGA) ECGAPop ¶
func (ecga *ECGA) ECGAPop() *pop.Population
ECGAPop returns a population where some members are from ecga.P and some are sampled from ecga.Blocks and ecga.P at random. The proportion of new to old members is based on learningRate.
func (*ECGA) MDMModel ¶
func (ecga *ECGA) MDMModel(selected []pop.Individual)
MDMModel refreshes the ecga's building blocks
func (*ECGA) ModelComplexity ¶
ModelComplexity punishes blocks exponentially for being long in effect, this means ecgas can't develop building blocks longer than maybe four or five indices.
type EnvInd ¶
EnvInd is a wrapper around an environment and serves as the basis for the UMDA population
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
Crossover is NOP on a EnvInd
type FitSample ¶
type FitSample struct {
// contains filtered or unexported fields
}
FitSample is a tuple of a sample and its fitness
type FullBivariateEnv ¶
type FullBivariateEnv []*BivariateEnv
A FullBivariateEnv represents a 2d array of Bivariate environments where each potential pairing of (a|b) is represented at index [a][b]
func NewFullBSBivariateEnv ¶
func NewFullBSBivariateEnv(samples []*env.F) FullBivariateEnv
NewFullBSBivariateEnv returns a FullBivariateEnv under the assumption that the input samples are bitstrings.
type MIMIC ¶
MIMIC is an EDA of the Mutual information maximizing input clustering algorithm
func (*MIMIC) Adjust ¶
Adjust on a MIMIC generates samples from MIMIC's chain model, filters them with a straight greed selection algorithm to get the top-percentile samples and retrains its chain on the top-percentile samples. Todo: would mimic perform way better if it wasn't using a straight greed selection? (the paper doesn't refer to this selection algorithm as a selection algorithm but it totally is)
func (*MIMIC) GetSample ¶
GetSample on a MIMIC iterates through the marked indices of the model where the first index uses a univariate sampling and each following index is a bivariate sampling based on the result of the previous sampled index.
func (*MIMIC) UpdateFromSamples ¶
UpdateFromSamples updates the two floating point vectors that a MIMIC stores, the former for the probability that an element is true given the former in the index list is true, and the latter given the former in the index list is false.
type Model ¶
A Model is an iteratively adjusting EDA model
func MIMICModel ¶
MIMICModel returns an initialized MIMIC EDA
func SHCLVNDModel ¶
SHCLVNDModel initializes a SHCLVND EDA
type Option ¶
type Option func(Model)
Option is a functional option type to be passed in variadically to model creation functions. All options will take the base behind a model and set some values on that base or otherwise manipulate the base. Options should be able to be called on a model in any order without the order changing the output model.
type PBIL ¶
type PBIL struct {
Base
}
PBIL is an EDA built on the Population based incremental learning algorithm
type SHCLVND ¶
SHCLVND represents the Stochastic Hill Climbing with Learning by Vectors of Normal Distributions algorithm.
func (*SHCLVND) Adjust ¶
Adjust on a SHCLVND polls learningSamples best samples and creates an average candidate from the collected samples. Then the distribution of the SHCLVND is reinforced closer to the average candidate, and the standard deviation used to generate the samples is reduced.
func (*SHCLVND) SigmaSample ¶
SigmaSample is a way to sample an environment based on a standard deviation spread from an average