de

package
v0.0.0-...-7a5de80 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package de contains implementation details of Differential Evolution kind of algorithms.

Index

Constants

View Source
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

func LogFatalf

func LogFatalf(s string, v ...any)

LogFatalf wraps the jDE logger's Fatalf func.

func LogFatalln

func LogFatalln(s string)

LogFatalln wraps the jDE logger's Fatalln func.

func LogPrintf

func LogPrintf(s string, v ...any)

LogPrintf wraps the jDE logger's Printf func.

func LogPrintln

func LogPrintln(v ...any)

LogPrintln wraps the jDE logger's Println func.

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 NewjDE

func NewjDE() *JDE

NewjDE returns a pointer to a new, uninitialised jDE instance.

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.

func (*JDE) Run

func (j *JDE) Run()

Run self-adapting differential evolution algorithm.

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) Clear

func (p *Population) Clear()

Clear sets all vectors to 0.

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) Reinit

func (p *Population) Reinit()

Reinit reinitialises all individuals.

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.

Jump to

Keyboard shortcuts

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