Documentation ¶
Index ¶
- Constants
- Variables
- func SortByFitnessAndNeurons(indis []eaopt.Individual)
- func TrainMLP(csvdata string) (mlp.MultiLayerNetwork, float64, error)
- type MLPClient
- type MLPServer
- func (s *MLPServer) BorrowIndividual(ctx context.Context, e *empty.Empty) (*mlp.MLPMsg, error)
- func (s *MLPServer) GetProblemDescription(ctx context.Context, in *empty.Empty) (*mlp.ProblemDescription, error)
- func (s *MLPServer) GetStats(ctx context.Context, in *empty.Empty) (*mlp.Stats, error)
- func (s *MLPServer) ReturnIndividual(ctx context.Context, msg *mlp.MLPMsg) (*empty.Empty, error)
- type PoolModel
- type Population
- func (pop *Population) Add(indiv eaopt.Individual)
- func (pop *Population) Fold(f func(eaopt.Individual) bool)
- func (pop *Population) Length() int
- func (pop *Population) RandIndividual(rnd *rand.Rand) (eaopt.Individual, error)
- func (pop *Population) Remove(indiv eaopt.Individual)
- func (pop *Population) Snapshot() map[string]cache.Item
Constants ¶
const ( // Precission states the fitness precission. // e.g. 100 is 2 decimals (default) Precission float64 = 100 // TrainEpochs states how many epochs to train the MLP in the Train operator TrainEpochs int = 100 // MutateRate states the probability of a neuron to be mutated once the Mutate operator is applied MutateRate float64 = 1 )
Variables ¶
var Log = logrus.New()
Log is the logger instance for the GA
Functions ¶
func SortByFitnessAndNeurons ¶
func SortByFitnessAndNeurons(indis []eaopt.Individual)
SortByFitnessAndNeurons First sorts by Fitness and then by number of neurons
Types ¶
type MLPClient ¶
type MLPClient struct { ServerAddr string Log *logrus.Logger ID string CustomDialer func(s string, dt time.Duration) (net.Conn, error) // contains filtered or unexported fields }
MLPClient is a client to communicate with the GRPC server
func (*MLPClient) Start ¶
Start starts the client on a while loop borrowing, evaluating and returning individuals
func (*MLPClient) StatsFetcher ¶
func (c *MLPClient) StatsFetcher(client *mlp.DistributedEAClient)
StatsFetcher is a thread to ask server about stats {best_fitness, best_neurons, total_evaluations_overall}
type MLPServer ¶
type MLPServer struct { Log *logrus.Logger Input chan eaopt.Individual Output chan eaopt.Individual Pool *PoolModel // contains filtered or unexported fields }
MLPServer implements DistributedEA service
func (*MLPServer) BorrowIndividual ¶
BorrowIndividual implements DistributedEA service
func (*MLPServer) GetProblemDescription ¶
func (s *MLPServer) GetProblemDescription(ctx context.Context, in *empty.Empty) (*mlp.ProblemDescription, error)
GetProblemDescription returs the configuration for the problem execution to the client
type PoolModel ¶
type PoolModel struct { Rnd *rand.Rand KeepBest bool SortFunction func([]eaopt.Individual) ExtraOperators []eaopt.ExtraOperator EarlyStop func(*PoolModel) bool // Callbacks BestCallback func(*PoolModel) GenerationCallback func(*PoolModel) CrossRate float64 MutRate float64 PopSize int MaxEvaluations int BestSolution eaopt.Individual // contains filtered or unexported fields }
PoolModel is a pool-based evolutionary algorithm
func (*PoolModel) GetAverageFitness ¶
GetAverageFitness returns the vaerage fitness of the population
func (*PoolModel) GetTotalEvaluations ¶
GetTotalEvaluations returns the total number of evaluations carried out so far
type Population ¶
type Population struct {
// contains filtered or unexported fields
}
Population stores individuals
func (*Population) Fold ¶
func (pop *Population) Fold(f func(eaopt.Individual) bool)
Fold applies function f to each individual in the population until the end is reached or f returns false
func (*Population) Length ¶
func (pop *Population) Length() int
Length returns the size of the population
func (*Population) RandIndividual ¶
func (pop *Population) RandIndividual(rnd *rand.Rand) (eaopt.Individual, error)
RandIndividual takes an snapshot of the population and returns a random entry from it
func (*Population) Remove ¶
func (pop *Population) Remove(indiv eaopt.Individual)
Remove an individual
func (*Population) Snapshot ¶
func (pop *Population) Snapshot() map[string]cache.Item
Snapshot returns the state of the population at the moment it was called. TODO: Wrap the cache.Item type to eaopt.Individual