ga

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calculator

type Calculator interface {
	Calculate([]Chromosome) float64
}

Calculator 适应度计算器

type ChangeHandler added in v0.1.0

type ChangeHandler func() (Gene, error)

type Chromosome

type Chromosome interface {
	Genes() []Gene
	Gene(int) Gene
}

Chromosome 染色体

type Config

type Config interface {
	Generations() int
	PopulationSize() int
	CrossoverRate() float64
	MutationRate() float64
	InitMethod() int
}

Config 配置

type GA

type GA interface {
	Config() Config

	Initializer() Initializer

	Calculator() Calculator
}

type Gene added in v0.1.0

type Gene interface {
	Values() []int
}

Gene 基因

type Individual

type Individual interface {
	Chromosomes() []Chromosome
	Chromosome(int) Chromosome
	Fitness() float64
	SetFitness(float64)
	NewInstance([]Chromosome) Individual
	Print()
	Change() error
}

Individual 个体

func Run

func Run(ga GA) (Individual, error)

Run 运行算法 返回最佳个体

type Initializer

type Initializer interface {
	Init(int) Pn
	GetIns() Individual
}

Initializer 种群初始化

type Pn added in v0.1.0

type Pn []Individual

type Population

type Population struct {
	// contains filtered or unexported fields
}

func NewPopulation

func NewPopulation(ga GA) *Population

func (*Population) Evolve added in v0.1.0

func (pn *Population) Evolve() error

func (*Population) Individuals added in v0.1.0

func (pn *Population) Individuals() Pn

func (*Population) Initialize

func (pn *Population) Initialize()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL