Documentation ¶
Overview ¶
Package de contains implementation details of Differential Evolution kind of algorithms.
Index ¶
- Constants
- func LogFatalf(s string, v ...any)
- func LogFatalln(s string)
- func LogPrintf(s string, v ...any)
- func LogPrintln(v ...any)
- type ChampionIndividual
- type ConstraintVector
- 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) SetV(n int, nuV DecisionVector)
- func (p *Population) SetX(n int, nuX DecisionVector)
- type PopulationIndividual
Constants ¶
const ( // DEBest1Exp is the DE/best/1/exp strategy. DEBest1Exp int = iota // DERand1Exp is the DE/rand/1/exp strategy. DERand1Exp // DERandtoBest1Exp is the DE/rand-to-best/1/exp strategy. DERandtoBest1Exp // DEBest2Exp is the DE/best/2/exp strategy. DEBest2Exp // DERand2Exp is the DE/rand/2/exp strategy. DERand2Exp // DEBest1Bin is the DE/best/1/bin strategy. DEBest1Bin // DERand1Bin is the DE/rand/1/bin strategy. DERand1Bin // DERandtoBest1Bin is the DE/rand-to-best/1/bin strategy. DERandtoBest1Bin // DEBest2Bin is the DE/best/2/bin strategy. DEBest2Bin // DERand2Bin is the DE/rand/2/bin strategy. DERand2Bin // DEBest3Exp is the DE/best/3/exp strategy. DEBest3Exp // DEBest3Bin is the DE/best/3/bin strategy. DEBest3Bin // DERand3Exp is the DE/rand/3/exp strategy. DERand3Exp // DERand3Bin is the DE/rand/3/bin strategy. DERand3Bin // DERandtoCurrent2E is the DE/rand-to-current/2/exp strategy. DERandtoCurrent2Exp // DERandtoCurrent2Bin is the DE/rand-to-current/2/bin strategy. DERandtoCurrent2Bin // DERandtoBestandCurrent2Exp is the DE/rand-to-best-and-current/2/exp strategy. DERandtoBestandCurrent2Exp // DERandtoBestandCurrent2Bin is the DE/rand-to-best-and-current/2/bin strategy. DERandtoBestandCurrent2Bin )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChampionIndividual ¶
type ChampionIndividual struct { X DecisionVector C ConstraintVector F FitnessVector }
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 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 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 // 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 // Problem is the current benchmarking function this population is attempting to optimise. Problem string // Dimen is the dimensionality of the problem being optimised. Dimen int // Seed is the value used to (re)init population. Seed uint64 }
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
GetIndividal 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) SetV ¶
func (p *Population) SetV(n int, nuV DecisionVector)
func (*Population) SetX ¶
func (p *Population) SetX(n int, nuX DecisionVector)
type PopulationIndividual ¶
type PopulationIndividual struct { CurX DecisionVector CurV DecisionVector CurC ConstraintVector CurF FitnessVector BestX DecisionVector BestC ConstraintVector BestF FitnessVector }
PopulationIndividual representats a single population individual.