Documentation ¶
Overview ¶
Package genome provides the basis for a single GEP genome. A genome consists of one or more genes.
Index ¶
- type Genome
- func (g *Genome) Dup() *Genome
- func (g *Genome) EvalBool(in []bool, fm functions.FuncMap) bool
- func (g *Genome) EvalMath(in []float64) float64
- func (g *Genome) Evaluate(sf ScoringFunc, c chan<- *Genome)
- func (g *Genome) Mutate(numMutations int)
- func (g Genome) String() string
- func (g *Genome) SymbolCount(sym string) int
- func (g *Genome) Write(w io.Writer, grammar *grammars.Grammar)
- type ScoringFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Genome ¶
type Genome struct { Genes []*gene.Gene LinkFunc string Score float64 SymbolMap map[string]int // do not use directly. Use SymbolCount() instead. }
Genome contains the genes that make up the genome. It also provides the linking function and the score that results from evaluating the genome against the fitness function.
func (*Genome) EvalBool ¶
EvalBool evaluates the genome as a boolean expression and returns the result. in represents the boolean inputs available to the genome. fm is the map of available boolean functions to the genome.
func (*Genome) EvalMath ¶
EvalMath evaluates the genome as a floating-point expression and returns the result. in represents the float64 inputs available to the genome.
func (*Genome) Evaluate ¶
func (g *Genome) Evaluate(sf ScoringFunc, c chan<- *Genome)
Evaluate scores a genome and sends the result to a channel.
func (*Genome) Mutate ¶
Mutate mutates a genome by performing numMutations random symbol exchanges within the genome.
func (*Genome) SymbolCount ¶
SymbolCount returns the count of the number of times the symbol is actually used in the Genome. Note that this count is typically different from the number of times the symbol appears in the Karva expression. This can be a handy metric to assist in the fitness evaluation of a Genome. Note also that this currently only works for Math expressions. Hopefully this restriction will be lifted in the future. A workaround for using it with other types is to evaluate the Genome, and then g.symbolCount will already be populated.
type ScoringFunc ¶
ScoringFunc is the function that is used to evaluate the fitness of the model. Typically, a return value of 0 means that the function is nowhere close to being a valid solution and a return value of 1000 (or higher) means a perfect solution.