Documentation
¶
Overview ¶
Package ga implements Genetic Algorithms.
Index ¶
- type ChampionIndividual
- type ConstraintVector
- type DE
- type DecisionVector
- type FitnessVector
- type JDE
- type Population
- func (p *Population) Clear()
- func (p *Population) GetBestIdx() int
- func (p *Population) GetIndividual(n uint) *PopulationIndividual
- func (p *Population) GetWorstIdx() int
- func (p *Population) Init()
- func (p *Population) MeanVelocity() float64
- func (p *Population) Reinit()
- func (p *Population) ReinitN(n uint)
- func (p *Population) SelectDonors(currentIdx int) []PopulationIndividual
- func (p *Population) Size() int
- type PopulationIndividual
- type SOMAT3A
- type SOMAT3AChampionIndividual
- type SOMAT3APopulation
- func (p *SOMAT3APopulation) Clear()
- func (p *SOMAT3APopulation) GetBestIdx() int
- func (p *SOMAT3APopulation) GetIndividual(n uint) *PopulationIndividual
- func (p *SOMAT3APopulation) GetWorstIdx() int
- func (p *SOMAT3APopulation) Init()
- func (p *SOMAT3APopulation) Reinit()
- func (p *SOMAT3APopulation) Size() int
- type SOMAT3APopulationIndividual
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChampionIndividual ¶
type ChampionIndividual struct {
X DecisionVector
}
ChampionIndividual is a representation of the best individual currently available in the population.
type ConstraintVector ¶
type ConstraintVector []float64
ConstraintVector is a []float64 abstraction representing the constraint vector.
type DE ¶
type DE struct {
// Generations denotes the number of generations the population evolves
// for. Special value -1 disables limiting the number of generations.
Generations int
// BenchMinIters is the number of iterations the bench function will be re-run (for statistical purposes).
BenchMinIters int
// Dimensions to solve the problem for.
Dimensions []int
// F is the differential weight (mutation/weighting factor).
F float64
// CR is the crossover probability constant.
CR float64
// MutationStrategy selects the mutation strategy, i.e. the variant of the
// DE algorithm (0..17), see mutationStrategies.go for more details.
MutationStrategy int
// NP is the initial population size.
NP int
// BenchName is a name of the problem to optimise.
BenchName string
// contains filtered or unexported fields
}
DE is a holder for the settings of an instance of a Differential Evolution (DE) algorithm.
func (*DE) Init ¶
func (d *DE) Init( generations, benchMinIters, mutStrategy, np int, f, cr float64, dimensions []int, bench string, ch chan []stats.Stats, chAlgoMeans chan *stats.AlgoBenchMean, )
Init initialises the DE algorithm, performs sanity checks on the inputs.
func (*DE) InitAndRun ¶
func (d *DE) InitAndRun( generations, benchMinIters, mutStrategy, np int, f, cr float64, dimensions []int, bench string, ch chan []stats.Stats, chAlgoMeans chan *stats.AlgoBenchMean, )
InitAndRun initialises the DE algorithm, performs sanity checks on the inputs and calls the Run method.
type DecisionVector ¶
type DecisionVector []float64
DecisionVector is a []float64 abstraction representing the decision vector.
type FitnessVector ¶
type FitnessVector []float64
FitnessVector is a []float64 abstraction representing the fitness vector.
type JDE ¶
type JDE struct {
// Generations denotes the number of generations the population evolves
// for. Special value -1 disables limiting the number of generations.
Generations int
// BenchMinIters is the number of iterations the bench function will be re-run (for statistical purposes).
BenchMinIters int
// Dimensions to solve the problem for.
Dimensions []int
// F is the initial value of the differential weight (mutation/weighting factor).
F float64
// CR is the initial value of the crossover probability constant.
CR float64
// MutationStrategy selects the mutation strategy, i.e. the variant of the
// jDE algorithm (0..17), see mutationStrategies.go for more details.
MutationStrategy int
// AdptScheme is the parameter self-adaptation scheme (0..1).
AdptScheme int
// NP is the initial population size.
NP int
// BenchName is a name of the problem to optimise.
BenchName string
// contains filtered or unexported fields
}
JDE is a holder for the settings of an instance of a self-adapting differential evolution (jDE) algorithm.
func (*JDE) Init ¶
func (j *JDE) Init( generations, benchMinIters, mutStrategy, adptScheme, np int, f, cr float64, dimensions []int, bench string, ch chan []stats.Stats, chAlgoMeans chan *stats.AlgoBenchMean, )
Init initialises the jDE algorithm, performs sanity checks on the inputs.
func (*JDE) InitAndRun ¶
func (j *JDE) InitAndRun( generations, benchMinIters, mutStrategy, adptScheme, np int, f, cr float64, dimensions []int, bench string, ch chan []stats.Stats, chAlgoMeans chan *stats.AlgoBenchMean, )
InitAndRun initialises the jDE algorithm, performs sanity checks on the inputs and calls the Run method.
type Population ¶
type Population struct {
// Population is a slice of population individuals.
Population []PopulationIndividual
// Champion represents the best individual of the population.
Champion ChampionIndividual
// Problem is the current benchmarking function this population is attempting to optimise.
Problem string
// ProblemFunction is the actual function to optimise.
ProblemFunc func([]float64) float64
// Dimen is the dimensionality of the problem being optimised.
Dimen int
// Seed is the value used to (re)init population.
Seed uint64
// BestF is the best recorded value of the differential weight F.
BestF float64
// BestCR is the best recorded value of the differential weight CR.
BestCR float64
// CurF is the current value of F.
CurF float64
// CurCR is the current value of the differential weight CR.
CurCR float64
// contains filtered or unexported fields
}
Population groups population individuals (agents) with metadata about the population.
func (*Population) GetBestIdx ¶
func (p *Population) GetBestIdx() int
GetBestIdx returns the index of the best population individual.
func (*Population) GetIndividual ¶
func (p *Population) GetIndividual(n uint) *PopulationIndividual
GetIndividual returns a reference to individual at position n.
func (*Population) GetWorstIdx ¶
func (p *Population) GetWorstIdx() int
GetWorstIdx returns the index of the worst population individual.
func (*Population) Init ¶
func (p *Population) Init()
Init initialises all individuals to random values.
func (*Population) MeanVelocity ¶
func (p *Population) MeanVelocity() float64
MeanVelocity computes the mean current velocity of all individuals in the population.
func (*Population) ReinitN ¶
func (p *Population) ReinitN(n uint)
ReinitN reinitialises the individual at position n.
func (*Population) SelectDonors ¶
func (p *Population) SelectDonors(currentIdx int) []PopulationIndividual
func (*Population) Size ¶
func (p *Population) Size() int
Size returns the number of population individuals.
type PopulationIndividual ¶
type PopulationIndividual struct {
CurX DecisionVector
CurF FitnessVector
BestX DecisionVector
BestC ConstraintVector
BestF FitnessVector
}
PopulationIndividual represents a single population individual.
type SOMAT3A ¶
type SOMAT3A struct {
// Generations is the number of generations to evolve for. Disable limit
// with -1.
Generations int
// BenchMinIters is the number of iterations that the bench function will
// be re-run.
BenchMinIters int
// Dimensions in which to look for a solution.
Dimensions []int
// NP is the initial population size.
NP int
// K is the number of individuals to choose the leader from.
K int
// M denotes how many individuals are picked from the population to form a
// `team` during the organisation phase, can be thought of as "team size".
M int
// N is the number of best individuals in each team selected for actual
// migration.
N int
// Njumps is the fixed number of jumps that each chosen migrating
// individual performs on their way to the leader.
Njumps int
// BenchName is the human-friendly name of the benchmarking function.
BenchName string
// contains filtered or unexported fields
}
SOMAT3A holds the settings for an instance of SOMA T3A algorithm. nolint: unused
func NewSOMAT3A ¶
func NewSOMAT3A() *SOMAT3A
NewSOMAT3A returns a pointer to a new, uninitialised SOMAT3A instance.
type SOMAT3AChampionIndividual ¶
type SOMAT3AChampionIndividual struct {
X DecisionVector
}
ChampionIndividual is a representation of the best individual currently available in the population.
type SOMAT3APopulation ¶
type SOMAT3APopulation struct {
// Population is a slice of population individuals.
Population []SOMAT3APopulationIndividual
// Champion represents the best individual of the population.
Champion SOMAT3AChampionIndividual
// Problem is the current benchmarking function this population is attempting to optimise.
Problem string
// ProblemFunction is the actual function to optimise.
ProblemFunc func([]float64) float64
// Dimen is the dimensionality of the problem being optimised.
Dimen int
// Seed is the value used to (re)init population.
Seed uint64
// PRT is the perturbation parameter.
PRT float64
// K is the number of individuals to choose the leader from.
K int
// M denotes how many individuals are picked from the population to form a
// `team` during the organisation phase, can be thought of as "team size".
M int
// N is the number of best individuals in each team selected for actual
// migration.
N int
// Njumps is the fixed number of jumps that each chosen migrating
// individual performs on their way to the leader.
Njumps int
// contains filtered or unexported fields
}
Population groups population individuals (agents) with metadata about the population.
func (*SOMAT3APopulation) GetBestIdx ¶
func (p *SOMAT3APopulation) GetBestIdx() int
GetBestIdx returns the index of the best population individual.
func (*SOMAT3APopulation) GetIndividual ¶
func (p *SOMAT3APopulation) GetIndividual(n uint) *PopulationIndividual
GetIndividual returns a reference to individual at position n.
func (*SOMAT3APopulation) GetWorstIdx ¶
func (p *SOMAT3APopulation) GetWorstIdx() int
GetWorstIdx returns the index of the worst population individual.
func (*SOMAT3APopulation) Init ¶
func (p *SOMAT3APopulation) Init()
Init initialises all individuals to random values.
func (*SOMAT3APopulation) Reinit ¶
func (p *SOMAT3APopulation) Reinit()
Reinit reinitialises all individuals.
func (*SOMAT3APopulation) Size ¶
func (p *SOMAT3APopulation) Size() int
Size returns the number of population individuals.
type SOMAT3APopulationIndividual ¶
type SOMAT3APopulationIndividual struct {
CurX DecisionVector
PRTVector []float64
Jumps [][]float64
}
PopulationIndividual represents a single population individual.