public final class SelfPlayOptimizer extends PBIL implements AutoCloseable
epsilon, EPSILON, generations, genotypeLength, LEARNING_RATE, learningRate, MAX_DIVERGENCE, MUTATION_PROBABILITY, MUTATION_SHIFT, mutationProbability, mutationShift, NEGATIVE_LEARNING_RATE, negLearningRate, POPULATION_SIZE, populationSize
Constructor and Description |
---|
SelfPlayOptimizer(List<SelfPlayEngines<TunableEngine>> engines,
Set<ParameterType> parameterTypes,
int games,
long timePerGame,
long timeIncPerMove,
double validationFactor,
double[] initialProbabilityVector,
int populationSize,
Double learningRate,
Double negativeLearningRate,
Double mutationProbability,
Double mutationShift,
Integer generations,
Logger logger)
Constructs a new instance according to the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected double |
computeFitness(String genotype)
Measures the fitness of the genotype.
|
getCurrentGeneration, getCurrentHighestFitness, getEntropy, getProbabilityVector, optimize
public SelfPlayOptimizer(List<SelfPlayEngines<TunableEngine>> engines, Set<ParameterType> parameterTypes, int games, long timePerGame, long timeIncPerMove, double validationFactor, double[] initialProbabilityVector, int populationSize, Double learningRate, Double negativeLearningRate, Double mutationProbability, Double mutationShift, Integer generations, Logger logger) throws Exception, IllegalArgumentException
engines
- A list of SelfPlayEngines
instances that each contain the engines needed
for one optimization thread. For each non-null element in the list, a new thread will be utilized for the optimization. E.g. if engines
is a list of four non-null elements, the games in the fitness function will be distributed and played parallel on four threads. The
list's first element cannot be null or a NullPointerException
is thrown.parameterTypes
- The set of chess engine parameter types to tune with game play. If it is null, all parameters will be tuned.games
- The number of games to play to assess the fitness of the parameters.timePerGame
- The time each engine will have per game in milliseconds.timeIncPerMove
- The number of milliseconds with which the remaining time of an engine is incremented after each legal move.validationFactor
- The factor of the original number of games to play in addition when assessing the fitness of a parameter set
whose fitness surpassed the current highest fitness after having played the original number of games.initialProbabilityVector
- The starting probability vector for the optimization. It allows the algorithm to pick up where a
previous, terminated optimization process left off. If the array's length is smaller than the engine to be tuned's parameters' binary
string's length, it will be extended with elements of the value 0.5d; if the length of the array is greater than engine to be tuned's
parameters' binary string's length, only the first x elements will be considered, where x equals the parameters' binary string's
length. If it is null, an array with a length equal to the parameters' binary string's length, only containing elements that have the
value 0.5d will be used.populationSize
- The number of samples to produce per generation.learningRate
- The learning rate of the evolutionary algorithm.negativeLearningRate
- The negative learning rate of the evolutionary algorithm.mutationProbability
- The mutation probability of the genotypes.mutationShift
- The mutation shift of the genotypes.generations
- The number of generations to complete. If it is null, the training will go on until convergence or until it's
manually stopped.logger
- A logger to log the optimization process. It cannot be null.Exception
- If the engines cannot be initialized.IllegalArgumentException
- If logger is null.protected double computeFitness(String genotype)
PBIL
computeFitness
in class PBIL
genotype
- The genotype represented by a string of binary digits of the specified length.public void close()
close
in interface AutoCloseable
Copyright © 2020. All rights reserved.