Files
jube-fork/Accord.Genetic/Selection Algorithms/EliteSelection.cs
richard-churchman cc0a2bee21 Extensive modifications to the serialisation of Neural Network models to support Newtonsoft Json.net rather than Binary Serializer.
Included open-source Accord.net library code natively to the solution given the deprecated state of that project.  Accord.net will be supported inside Jube for own needs (such as upgrading to .Net 7+).

Accord.net libraries modified to compile to .Net 6.

Modified Accord.net libraries to better support Newtonsoft Json.net serialisation.

Included annotations in the Accord.net libraries to house important dependency statistics. Serialised json can be used independently of Jube to recall a Neural Network.

Removal of Binary Serializer totally as a precursor to the projects support of .Net 7+.

Extensive bug fixing in crucial functions of Neural Network training and recall.  While this part of the system remains in Alpha, it is substantially more fit for purpose.
2023-12-24 10:22:22 +01:00

49 lines
1.4 KiB
C#

// AForge Genetic Library
// AForge.NET framework
// http://www.aforgenet.com/framework/
//
// Copyright © Andrew Kirillov, 2006-2009
// [email protected]
//
namespace Accord.Genetic
{
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Elite selection method.
/// </summary>
///
/// <remarks>Elite selection method selects specified amount of
/// best chromosomes to the next generation.</remarks>
///
public class EliteSelection : ISelectionMethod
{
/// <summary>
/// Initializes a new instance of the <see cref="EliteSelection"/> class.
/// </summary>
public EliteSelection( ) { }
/// <summary>
/// Apply selection to the specified population.
/// </summary>
///
/// <param name="chromosomes">Population, which should be filtered.</param>
/// <param name="size">The amount of chromosomes to keep.</param>
///
/// <remarks>Filters specified population keeping only specified amount of best
/// chromosomes.</remarks>
///
public void ApplySelection( List<IChromosome> chromosomes, int size )
{
// sort chromosomes
chromosomes.Sort( );
// remove bad chromosomes
chromosomes.RemoveRange( size, chromosomes.Count - size );
}
}
}