Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultModel ¶
type DefaultModel struct { }
func (DefaultModel) Crossover ¶
func (dm DefaultModel) Crossover(parent1 Individual, parent2 Individual) (Individual, error)
Crossover is fixed point crossover. It does not ensure uniqueness of genes.
func (DefaultModel) Mutate ¶
func (dm DefaultModel) Mutate(individual Individual) (Individual, error)
func (DefaultModel) SelectParent ¶
func (dm DefaultModel) SelectParent(population *Population) Individual
type GA ¶
type GA struct {
// contains filtered or unexported fields
}
func NewCustomGA ¶
func NewDefaultGA ¶
func NewDefaultGA(generationNumber int, populationSize int, mutationRate float64, individual Individual) GA
maybe use builder pattern?
func (*GA) Run ¶
func (g *GA) Run() Individual
Implement user provided callback function that takes individual as parameter We will call this callback with parameter g.population.calculateBestIndividual User can get properties of this individual and save it in an array and use it.
func (*GA) RunWithLog ¶
func (g *GA) RunWithLog(printIndividual printIndividual) Individual
type Individual ¶
type Individual interface { CalculateFitness() float64 GenerateIndividual() Individual }
type Model ¶
type Model interface { SelectParent(population *Population) Individual Crossover(parent1 Individual, parent2 Individual) (Individual, error) Mutate(individual Individual) (Individual, error) }
type PermutationModel ¶
type PermutationModel struct {
DefaultModel
}
func (PermutationModel) Crossover ¶
func (pm PermutationModel) Crossover(parent1 Individual, parent2 Individual) (Individual, error)
Crossover is ordered crossover implementation
func (PermutationModel) Mutate ¶
func (pm PermutationModel) Mutate(individual Individual) (Individual, error)
Mutate is swap mutation implementation
type Population ¶
type Population struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.