leo
525b30c38e
All checks were successful
continuous-integration/drone/push Build is passing
base package (wip)
76 lines
2.4 KiB
Go
76 lines
2.4 KiB
Go
// Copyright 2023 wanderer <a_mirre at utb dot cz>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package de
|
|
|
|
type (
|
|
// DecisionVector is a []float64 abstraction representing the decision vector.
|
|
DecisionVector []float64
|
|
// FitnessVector is a []float64 abstraction representing the fitness vector.
|
|
FitnessVector []float64
|
|
// ConstraintVector is a []float64 abstraction representing the constraint vector.
|
|
ConstraintVector []float64
|
|
)
|
|
|
|
// PopulationIndividual representats a single population individual.
|
|
type PopulationIndividual struct {
|
|
CurX DecisionVector
|
|
CurV DecisionVector
|
|
CurC ConstraintVector
|
|
CurF FitnessVector
|
|
|
|
BestX DecisionVector
|
|
BestC ConstraintVector
|
|
BestF FitnessVector
|
|
}
|
|
|
|
// ChampionIndividual is a representation of the best individual currently
|
|
// available in the population.
|
|
type ChampionIndividual struct {
|
|
X DecisionVector
|
|
C ConstraintVector
|
|
F FitnessVector
|
|
}
|
|
|
|
// Population groups population individuals (agents) with metadata about the 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
|
|
// Seed is the value used to (re)init population.
|
|
Seed uint64
|
|
}
|
|
|
|
// GetIndividal returns a reference to individual at position n.
|
|
func (p *Population) GetIndividual(n uint) *PopulationIndividual { return &PopulationIndividual{} }
|
|
func (p *Population) GetBestIdx() int { return 0 }
|
|
func (p *Population) GetWorstIdx() int { return 0 }
|
|
func (p *Population) SetX(n int, nuX DecisionVector) {}
|
|
func (p *Population) SetV(n int, nuV DecisionVector) {}
|
|
|
|
// Init initialises all individuals.
|
|
func (p *Population) Init() {}
|
|
|
|
// Reinit reinitialises all individuals.
|
|
func (p *Population) Reinit() {}
|
|
|
|
// ReinitN reinitialises the individual at position n.
|
|
func (p *Population) ReinitN(n uint) {}
|
|
func (p *Population) Clear() {}
|
|
|
|
// meanVelocity computes the mean current velocity of all individuals in the population.
|
|
func (p *Population) MeanVelocity() float64 { return 0.0 }
|
|
|
|
// newPopulation returns a pointer to a new, uninitialised population.
|
|
func newPopulation(benchProblem string, np int) *Population {
|
|
p := &Population{}
|
|
|
|
p.Problem = benchProblem
|
|
|
|
// pre-alloc.
|
|
p.Population = make([]PopulationIndividual, 0, np)
|
|
|
|
return p
|
|
}
|