de

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinomialCrossover

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

BinomialCrossover implements a binomial crossover operation.

func NewBinomialCrossover

func NewBinomialCrossover(rndGen *rand.LockedRand) *BinomialCrossover

NewBinomialCrossover returns a new BinomialCrossover.

func (*BinomialCrossover) Crossover

func (c *BinomialCrossover) Crossover(p *Population)

Crossover performs the crossover operation over the p population.

type Config

type Config struct {
	// The number of member of the populations
	PopulationSize int
	// The size of the dense vector
	VectorSize int
	// The maximum number of generations over which the entire population is evolved
	MaxGenerations int
	// The number of batches used to calculate the scores of the TargetVector and Trial vectors
	BatchSize int
	// The number of optimization steps to do for each generation
	OptimizationSteps int
	// Differential weight (default 0.5)
	MutationFactor mat.Float
	// Crossover probability (default 0.9)
	CrossoverRate mat.Float
	// Weight factor used by DEGL mutation strategy (default 0.5)
	WeightFactor mat.Float
	// The (positive) bound
	Bound mat.Float
	// Whether to alter the mutation factor and the crossover rate on the Trial evaluation
	Adaptive bool
	// Reset the population if the best solution remains unchanged after for this long
	ResetAfter int
	// The random seed.
	Seed uint64
}

Config provides configuration settings for a DifferentialEvolution optimizer.

type Crossover

type Crossover interface {
	Crossover(p *Population)
}

Crossover is implemented by values that provides crossover operations.

type DeglMutation

type DeglMutation struct {
	NeighborhoodRadius mat.Float
	Bound              mat.Float
}

DeglMutation implements Differential Evolution with Global and Local Neighborhoods mutation strategy.

Reference:

"Design of Two-Channel Quadrature Mirror Filter Banks Using Differential Evolution with Global and Local Neighborhoods"
Authors: Pradipta Ghosh, Hamim Zafar, Joydeep Banerjee, Swagatam Das (2011)
(https://www.springerprofessional.de/en/design-of-two-channel-quadrature-mirror-filter-banks-using-diffe/3805398)

func NewDeglMutation

func NewDeglMutation(NeighborhoodRadius, bound mat.Float) *DeglMutation

NewDeglMutation returns a new DeglMutation.

func (*DeglMutation) Mutate

func (m *DeglMutation) Mutate(p *Population)

Mutate calculate the mutated vector (donor vector) as:

G = xi + MutationFactor (best − xi) + MutationFactor (xa − xb)
L = xi + MutationFactor (bestNeighbor − xi) + MutationFactor (xc − xd)
yi = clip(w * L + (1-w) * G)

type DifferentialEvolution

type DifferentialEvolution struct {
	// The initial configuration
	Config
	// contains filtered or unexported fields
}

DifferentialEvolution implements a simple and efficient heuristic for global optimization over continuous spaces. Reference: https://link.springer.com/article/10.1023/A:1008202821328 (Storn & Price, 1997)

func NewOptimizer

func NewOptimizer(
	config Config,
	mutation Mutator,
	crossover Crossover,
	score func(solution mat.Matrix, batch int) mat.Float,
	validate func(solution mat.Matrix) mat.Float,
	onNewBest func(solution *ScoredVector),
) *DifferentialEvolution

NewOptimizer returns a new DifferentialEvolution ready to optimize your problem.

func (*DifferentialEvolution) Optimize

func (o *DifferentialEvolution) Optimize()

Optimize performs the Differential Evolution optimization process.

type Member

type Member struct {
	// The hyper-params tha might change over the generations
	MemberHyperParams
	// The target vector
	TargetVector mat.Matrix
	// The donor vector
	DonorVector mat.Matrix
	// The score of the target vector obtained during the last evaluation
	TargetScore mat.Float
	// The score of the trial vector obtained during the last evaluation
	TrialScore mat.Float
	// The score of the target vector on the validation set
	ValidationScore mat.Float
}

Member represents a member of the Population.

func NewMember

func NewMember(vector mat.Matrix, hyperParams MemberHyperParams) *Member

NewMember returns a new population member.

type MemberHyperParams

type MemberHyperParams struct {
	// Differential weight (default 0.5)
	MutationFactor mat.Float
	// Crossover probability (default 0.9)
	CrossoverRate mat.Float
	// Weight factor used by DEGL mutation (default 0.5)
	WeightFactor mat.Float
}

MemberHyperParams contains the hyper-parameters of a Member.

func (*MemberHyperParams) MutateHyperParams

func (a *MemberHyperParams) MutateHyperParams(l, u mat.Float)

MutateHyperParams mutates the hyper-parameters according to l and u. Suggested values: l = 0.1, u = 0.9.

type Mutator

type Mutator interface {
	Mutate(p *Population)
}

Mutator is implemented by values that provides mutation operations.

type Population

type Population struct {
	Members []*Member
}

Population represents the population.

func NewRandomPopulation

func NewRandomPopulation(populationSize int, vectorSize int, bound mat.Float, rndGen *rand.LockedRand, initHyperParams MemberHyperParams) *Population

NewRandomPopulation returns a new Population with members initialized randomly according to the given configuration.

func (*Population) FindBest

func (p *Population) FindBest(lowIndex, highIndex int, upperBound mat.Float, initArgMin int) (argMin int, minScore mat.Float)

FindBest finds the best member from the Population.

func (*Population) FindBestNeighbor

func (p *Population) FindBestNeighbor(index, windowSize int) (argMin int, minScore mat.Float)

FindBestNeighbor finds the best neighbor member from the Population.

type RandomMutation

type RandomMutation struct {
	Bound mat.Float
}

RandomMutation implements a random mutation operation.

func NewRandomMutation

func NewRandomMutation(bound mat.Float) *RandomMutation

NewRandomMutation returns a new RandomMutation.

func (*RandomMutation) Mutate

func (m *RandomMutation) Mutate(p *Population)

Mutate executes the mutation generating a "donor vector" for every element of the population. For each vector xi in the current generation, called target vector, a vector yi, called donor vector, is obtained as linear combination of some vectors in the population selected according to DE/rand/1 strategy, where

yi = clip(xa + MutationFactor * (xb − xc))

type ScoredVector

type ScoredVector struct {
	Vector mat.Matrix
	Score  mat.Float
}

ScoredVector is a pair which associates a Score to a Vector corresponding to a specific solution.

type State

type State struct {
	// The current generation
	CurGeneration int
	// The current batch
	CurBatch int
	// The current optimization step
	CurOptimizationStep int
	// contains filtered or unexported fields
}

State represents a status of the differential evolution process.

Jump to

Keyboard shortcuts

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