Documentation ¶
Overview ¶
Package lab is engine of genetic algorithm.
Index ¶
- func IndexOfMax(v []float64) int
- func IndexOfMaxExcluded(v []float64, excl []int) int
- func SetAggregator(code string, aggr Aggregator)
- func SetProcessor(code string, proc Processor)
- type Aggregator
- type Config
- type Lab
- func (l *Lab) Export() ([]byte, error)
- func (l *Lab) GetConfig() Config
- func (l *Lab) GetExec() bool
- func (l *Lab) GetProjects() []int
- func (l *Lab) Import(data []byte) error
- func (l *Lab) ProjectActivate(id int)
- func (l *Lab) ProjectAdd(layout [][]Node) int
- func (l *Lab) ProjectDeactivate(id int)
- func (l *Lab) ProjectDelete(id int)
- func (l *Lab) ProjectLayout(id int) [][]Node
- func (l *Lab) ProjectSet(id int, layout [][]Node)
- func (l *Lab) ProjectStat(id int) (int, int, int, string, bool)
- func (l *Lab) ProjectStatus(id int) bool
- func (l *Lab) ProjectValue(id int, in []float64) []float64
- func (l *Lab) Run()
- func (l *Lab) Setup(c Config) error
- func (l *Lab) Stop()
- func (l *Lab) Value(in []float64) []float64
- func (l *Lab) Volume(in []float64) [][]float64
- type Next
- type Node
- type Processor
- type Producer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IndexOfMax ¶
IndexOfMax returns index of element has maximum value of slice.
func IndexOfMaxExcluded ¶
IndexOfMaxExcluded returns index of element has maximum value of slice, excluding some indexes.
func SetAggregator ¶
func SetAggregator(code string, aggr Aggregator)
SetAggregator adds or sets custom aggregation function to functions map. To activate custom aggregation function need to set value of code to Config.Aggr and pass Config to Lab.Setup. May be used to overwrite builtin functions.
func SetProcessor ¶
SetProcessor adds or sets custom processor function to functions map. To activate custom processor function need to set value of code to Config.Proc and pass Config to Lab.Setup. May be used to overwrite builtin functions.
Types ¶
type Aggregator ¶
Aggregator provides function that aggregates values from out of the node.
type Config ¶
type Config struct { // Size is maximum size of generation pool and every evolution method. Size int // Aggr is code of Aggregator lab function. // Builtin functions is "sum", "avg", "min", "max". // Default is "avg". Aggr string // Proc is code of Processor lab function. // Builtin functions is "linear", "binary", "relu", "lrelu", "silu", "sigmoid", "softplus", "softsign", "tanh", "arctan", "sinusoid", "gaussian". // Default is "linear". Proc string // Goal option if true, than Lab will stop examine when target is reached. Goal bool // Duel option if true, than Lab will use challenge mode when produce result. Duel bool }
Config provides Lab configuration.
type Lab ¶
type Lab struct {
// contains filtered or unexported fields
}
Lab provides Lab data.
func (*Lab) GetProjects ¶
GetProjects returns slice of projects id.
func (*Lab) ProjectActivate ¶
ProjectActivate activate project by id.
func (*Lab) ProjectAdd ¶
ProjectAdd adds new project. Returns id of new project.
func (*Lab) ProjectDeactivate ¶
ProjectDeactivate deactivate project by id.
func (*Lab) ProjectLayout ¶
ProjectLayout returns layout project by id.
func (*Lab) ProjectSet ¶
ProjectSet updates project layout by id. Reset all data of project when update layout.
func (*Lab) ProjectStat ¶
ProjectStat returns current stats of project: generated count, evoluted count, age, best, goal state
func (*Lab) ProjectStatus ¶
ProjectStatus status of project.
func (*Lab) ProjectValue ¶
ProjectValue returns out node values of top entity project selected by id.
type Next ¶
Next provides wrapper function that returns value of last node after execution. This is a service type, usually used in Producer.Produce.
type Node ¶
type Node struct { // Src is a slice of links to source nodes. Src [][2]int // Out is a size of node. Out int }
Node provides interchange of node settings between Lab and external module.
type Producer ¶
type Producer interface { // Load used for loading and prepare data for producing. Settings map is optional. Load(map[string]string) error // Setup used for change settings of producer in runtime. Setup(string, string) error // Produce returns result for first entity. // Uses second entity like opponent and previous result when Config.Duel is true. Produce(Next, Next, []float64) []float64 // Validate returns proper state of entity. Validate([]float64) bool // Compare return true if first result better than second. Used for sort and filter entities. Compare([]float64, []float64) bool // Best returns formatted string of best result. Best([]float64) string // Goal returns goal state. If true, lab is reached target. Goal([]float64) bool }
Producer provides prepare and control lab examine.