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) bool
- func (g *Genome) EvalInt(in []int) int
- func (g *Genome) EvalIntTuple(in, out []int)
- func (g *Genome) EvalMath(in []float64) float64
- func (g *Genome) Evaluate(stepsSinceReset int, obs gym.Obs, action interface{}) error
- func (g *Genome) EvaluateWithScore(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) EvalInt ¶ added in v2.1.0
EvalInt evaluates the genome as an integer expression and returns the result. in represents the int inputs available to the genome.
func (*Genome) EvalIntTuple ¶ added in v2.1.0
EvalIntTuple evaluates the genome by evaluating each gene and assigning its output to each element of the tuple.
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 ¶
Evaluate runs the model with the observation and populates the provided action based on the link function.
func (*Genome) EvaluateWithScore ¶ added in v2.1.0
func (g *Genome) EvaluateWithScore(sf ScoringFunc, c chan<- *Genome)
EvaluateWithScore 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.
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.