GeneticAlgorithm<P extends PopulationSample> class
Genetic Algorithm: tournament selection, blend crossover, Gaussian mutation, elitism.
- Inheritance
-
- Object
- Training<
double, Float32x4, SignalFloat32x4, Scale< double> , P> - PopulationTrainer<
P> - GeneticAlgorithm
Constructors
-
GeneticAlgorithm(ANN<
double, Float32x4, SignalFloat32x4, Scale< ann, SamplesSet<double> >P> samplesSet, {int populationSize = 50, double mutationRate = 0.1, double mutationSigma = 0.3, int elitism = 2, Random? random, String? subject})
Properties
- algorithmName → String
-
The training algorithm name.
finalinherited
-
ann
→ ANN<
double, Float32x4, SignalFloat32x4, Scale< double> > -
The ANN to train.
finalinherited
- bestTrainingError → double
-
The lowest training error seen by checkBestTrainingError since the
last resetBestTraining.
no setterinherited
- dim ↔ int
-
latefinalinherited
- elapsedTime → Duration?
-
no setterinherited
- elitism → int
-
final
- enableSelectInitialANN ↔ bool
-
If true will select the initial ANN calling selectInitialANN.
getter/setter pairinherited
- endTime → DateTime?
-
The end time of the last training session or null if not finished yet.
no setterinherited
- globalError → double
-
Returns the current training global error (set by train).
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialAnnEpochs ↔ int
-
Number of epochs to perform in the ANNs in the selection pool.
getter/setter pairinherited
- initialAnnPoolSize ↔ int
-
The initial ANN pool size.
getter/setter pairinherited
- lastGlobalError → double
-
no setterinherited
- logEnabled ↔ bool
-
If true logging will be enabled.
getter/setter pairinherited
- logger → TrainingLogger
-
finalinherited
- logProgressEnabled ↔ bool
-
If true logging of progress will be enabled.
getter/setter pairinherited
- mutationRate → double
-
final
- mutationSigma → double
-
final
- parameters → String
-
no setterinherited
- populationSize → int
-
final
- random → Random
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
samples
→ List<
P> -
Returns the samples of samplesSet
no setterinherited
-
samplesSet
→ SamplesSet<
P> -
The samples set for training.
finalinherited
- samplesSubject → String
-
Returns the subject of samplesSet
no setterinherited
- startTime → DateTime?
-
The start time of the last training session or null if reset.
no setterinherited
- subject → String
-
The training subject. Defaults to
samplesSet.subject.finalinherited - totalFailedEpochs → int
-
no setterinherited
- totalTrainedEpochs → int
-
Returns the total number of epochs of all the training session.
A call to reset won't reset this value.
no setterinherited
- totalTrainingActivations → int
-
Returns the total number of activations of all the training session.
A call to reset won't reset this value.
no setterinherited
- trainedEpochs → int
-
Returns the number of epochs of the last training session.
no setterinherited
- trainingActivations → int
-
Returns the number of activations of the last training session.
no setterinherited
- trainingSamplesSize → int
-
no setterinherited
Methods
-
checkBestTrainingError(
double trainingError) → void -
inherited
-
computeGlobalError(
List< P> samples) → double -
inherited
-
evaluate(
List< double> genome) → double -
Sets the weights and returns the fitness (mean squared error).
inherited
-
finishGeneration(
double targetGlobalError) → bool -
Installs the best genome found so far and returns whether the target error
has been reached.
inherited
-
gaussianGenome(
List< double> center, double sigma) → List<double> -
inherited
-
initializeParameters(
) → void -
Initialize training parameters.
inherited
-
initializeTraining(
) → void -
inherited
-
learn(
List< P> samples, double targetGlobalError) → bool -
Learn the training of
sample. Called by train.override -
logError(
String message, [dynamic error, StackTrace? stackTrace]) → void -
inherited
-
logInfo(
String message) → void -
inherited
-
logProgress(
String message) → void -
inherited
-
logWarn(
String message) → void -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recordTrainingBlock(
double globalError, int epochs) → void -
Records the outcome of an externally-driven training block (e.g. the async
WebGPU trainers, which run epochs off the synchronous
_trainImplloop) so the public bookkeeping getters (globalError, trainedEpochs, totalTrainedEpochs, trainingActivations) reflect it. Also updates the best-training snapshot via checkBestTrainingError.inherited -
reset(
) → void -
Reset this instance for a future training sessions.
inherited
-
resetBestTraining(
) → void -
Discards the best weights/error tracked by checkBestTrainingError.
inherited
-
selectInitialANN(
List< P> samples, double targetGlobalError, [Random? random]) → void -
Selects the initial ANN.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
train(
int epochs, double targetGlobalError) → double -
Train the samples for n
epochsand returns the last global error.inherited -
trainUntilGlobalError(
{double? targetGlobalError, int epochsBlock = 50, int maxEpochs = 1000000, double maxEpochsLimitRatio = 3, int maxRetries = 5, double retryIncreaseMaxEpochsRatio = 1.50, Random? random}) → bool -
Train the ann until
targetGlobalError, withmaxEpochsper training session and amaxRetrieswhen a training session can't reach the target global error.inherited -
updateParameters(
) → void -
Update training parameters.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited