func updateComplexity(v *Web, pop neat.Population) { // Build complexity slice x := make([]float64, len(pop.Genomes)) for i, g := range pop.Genomes { x[i] = float64(g.Complexity()) } var b neat.Genome max := -1.0 for _, g := range pop.Genomes { if g.Fitness > max { b = g max = g.Fitness } } // Append the record min, _ := stats.Min(x) max, _ = stats.Max(x) mean, _ := stats.Mean(x) v.complexity = append(v.complexity, [4]float64{ min, mean, max, float64(b.Complexity()), }) }
func (c Classic) Mutate(g *neat.Genome) error { old := g.Complexity() if err := c.Complexify.Mutate(g); err != nil { return err } if g.Complexity() == old { if err := c.Weight.Mutate(g); err != nil { return err } if err := c.Trait.Mutate(g); err != nil { return err } } return nil }
func (c Complete) Mutate(g *neat.Genome) error { old := g.Complexity() if err := c.Phased.Mutate(g); err != nil { return err } if g.Complexity() == old { if err := c.Weight.Mutate(g); err != nil { return err } if err := c.Trait.Mutate(g); err != nil { return err } if err := c.Activation.Mutate(g); err != nil { return err } } return nil }