Skip to content

Commit

Permalink
Doc Adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsof committed Jan 28, 2014
1 parent b955e76 commit a1841b1
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 56 deletions.
2 changes: 1 addition & 1 deletion EvolveSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvolveSharp", "EvolveSharp\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{CE4B0B63-EFAF-4418-8156-F142E8FDD06D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvolveSharp.Samples.Tsp", "Samples\Tsp\EvolveSharp.Samples.Tsp.csproj", "{BADBF639-DDAD-4ACE-BDD2-03499E51328F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tsp", "Samples\Tsp\Tsp.csproj", "{BADBF639-DDAD-4ACE-BDD2-03499E51328F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
8 changes: 4 additions & 4 deletions EvolveSharp/CrossoverMethods/ICrossoverMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace EvolveSharp.CrossoverMethods
public interface ICrossoverMethod
{
/// <summary>
/// Execute crossover
/// Performs a crossover between two individuals
/// </summary>
/// <param name="inidividual1">Individual</param>
/// <param name="individual1">Individual</param>
/// <param name="individual2">Individual</param>
/// <returns>Two children mixing their parents</returns>
Tuple<IIndividual<T>,IIndividual<T>> Crossover<T>(IIndividual<T> inidividual1, IIndividual<T> individual2);
/// <returns>Two sons of individuals</returns>
Tuple<IIndividual<T>,IIndividual<T>> Crossover<T>(IIndividual<T> individual1, IIndividual<T> individual2);
}
}
2 changes: 1 addition & 1 deletion EvolveSharp/GeneticAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public GeneticAlgorithm(int populationCount, int geneCount, IFitnessFunction<dou
/// <summary>
/// Get the best individual based in the fitness' value
/// </summary>
/// <returns>the best genome</returns>
/// <returns>The best Individual</returns>
public IIndividual<double> BestIndividual
{
get
Expand Down
11 changes: 6 additions & 5 deletions EvolveSharp/Individuals/IIndividual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
namespace EvolveSharp.Individuals
{
/// <summary>
/// Interface to support implementation of several kind of individual
/// Interface to support implementation of several kind of individuals
/// </summary>
public interface IIndividual<T> : IComparable<IIndividual<T>>, ICloneable
{
/// <summary>
/// Length of individual
/// Length of individual's gene
/// </summary>
int Length { get; }

/// <summary>
/// Access each locus of individual
/// </summary>
/// <param name="locus">Lower part of individual</param>
/// <param name="key">Index of a individual's gene</param>
/// <returns>Value this position</returns>
T this[int locus] { get; set; }
T this[int key] { get; set; }

/// <summary>
/// Get the gene list
Expand All @@ -37,8 +37,9 @@ public interface IIndividual<T> : IComparable<IIndividual<T>>, ICloneable
new int CompareTo(IIndividual<T> other);

/// <summary>
/// Compare if the value this individual is equal to vaule other individual
/// Set Fitness Function in the Individual
/// </summary>
/// <param name="fitnessFunction">Fitness Function</param>
void SetFitnessFunction(IFitnessFunction<T> fitnessFunction);
}
}
42 changes: 19 additions & 23 deletions EvolveSharp/Individuals/Individual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public class Individual<T> : IIndividual<T>
private IFitnessFunction<T> _fitnessFunction;

/// <summary>
/// Builder a new genome from a list of genes
/// Builder a new individual from a list of genes
/// </summary>
/// <param name="genes">List of genes which forms a Genome</param>
/// <param name="genes">List of genes which forms a Individual</param>
public Individual(IList<T> genes)
{
_genes = genes;
Expand All @@ -28,13 +28,13 @@ public T this[int key]
}

/// <summary>
/// Builder a new genome from other Binary Genome
/// Builder a new individual from another
/// </summary>
/// <param name="genome">Binary Genome</param>
public Individual(Individual<T> genome)
/// <param name="individual">Individual</param>
public Individual(Individual<T> individual)
{
_genes = genome._genes;
_fitnessFunction = genome._fitnessFunction;
_genes = individual._genes;
_fitnessFunction = individual._fitnessFunction;
}

public int Length
Expand All @@ -60,27 +60,23 @@ public double Fitness
}
}

/*public IList<double> Genes {
get { return _genes; }
}*/

/// <summary>
/// Compare if the value this genome is equal to other genome
/// Compare if the value this individual is equal to other individual
/// </summary>
/// <param name="obj">The genome to compare with this</param>
/// <returns>if the genomes are equal or not</returns>
/// <param name="obj">The individual to compare with this</param>
/// <returns>if the individuals are equal or not</returns>
public override bool Equals(object obj)
{
if (obj == null)
return false;

var genome = obj as Individual<T>;
if (genome == null)
var individual = obj as Individual<T>;
if (individual == null)
return false;

for (var locus = 0; locus != _genes.Count; locus++)
{
if (!EqualityComparer<T>.Default.Equals(_genes[locus], genome._genes[locus]))
if (!EqualityComparer<T>.Default.Equals(_genes[locus], individual._genes[locus]))
{
return false;
}
Expand All @@ -99,9 +95,9 @@ public override int GetHashCode()
}

/// <summary>
/// Print the values of each locus of genome
/// Print the values of each gene of individual
/// </summary>
/// <returns>Values of genome in a string</returns>
/// <returns>Values of individual in a string</returns>
public override string ToString()
{
var output = new StringBuilder(_genes.Count);
Expand Down Expand Up @@ -130,19 +126,19 @@ public int CompareTo(IIndividual<T> other)
}

/// <summary>
/// Set Fitness Function in the Genome
/// Set Fitness Function in the Individual
/// </summary>
/// <param name="fitnessFunction">Class Implements in the Code of user</param>
/// <param name="fitnessFunction">Fitness Function</param>
public void SetFitnessFunction(IFitnessFunction<T> fitnessFunction)
{
_fitnessFunction = fitnessFunction;
_fitness = null;
}

/// <summary>
/// Create a identical Genome with other memory address
/// Create a identical Individual with other memory address
/// </summary>
/// <returns>A copy of genome passed in the parameters</returns>
/// <returns>A copy of individual</returns>
public object Clone()
{
var newGenes = new T[_genes.Count];
Expand Down
2 changes: 1 addition & 1 deletion EvolveSharp/Initializers/ComplementaryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace EvolveSharp.Initializers
{
/// <summary>
/// Creates a population with half of genomes exactly reverse each other
/// Creates a population with half of individuals exactly reverse each other
/// </summary>
public class ComplementaryInitializer : IInitializer<double>
{
Expand Down
2 changes: 1 addition & 1 deletion EvolveSharp/Initializers/IInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IInitializer<T>
/// <summary>
/// Creates a population based in a size
/// </summary>
/// <param name="size">Number of genomes should be in this population</param>
/// <param name="size">Number of individuals should be in this population</param>
/// <param name="fitnessFunction">Population's fitness function</param>
/// <returns></returns>
IEnumerable<IIndividual<T>> Generate(int size, IFitnessFunction<T> fitnessFunction);
Expand Down
4 changes: 2 additions & 2 deletions EvolveSharp/Mutators/FlipGeneMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace EvolveSharp.Mutators
/// <summary>
/// Class implements the interface 'IMutator'.
/// This kind of Mutation is called of Flip Gene.
/// It used to Binary Genomes. It reverses all locus to value opposite.
/// It used to Double Individuals. It reverses all genes to value opposite.
/// </summary>
public class FlipGeneMutator : IMutator<double>
{
/// <summary>
/// Execute Mutation in the individual for reference
/// </summary>
/// <param name="individual">Genome</param>
/// <param name="individual">Individual</param>
public void Mutate(IIndividual<double> individual)
{
for (var locus = 0; locus < individual.Length; locus++)
Expand Down
2 changes: 1 addition & 1 deletion EvolveSharp/Mutators/RandomMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public RandomMutator(double rateMutation)
/// <summary>
/// Execute Mutation in the individual for reference with based in the rate
/// </summary>
/// <param name="individual">Genome</param>
/// <param name="individual">Individual</param>
public void Mutate(IIndividual<double> individual)
{
if (Helper.Random.NextDouble() < _rateMutation)
Expand Down
2 changes: 1 addition & 1 deletion EvolveSharp/Mutators/UniformMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public UniformMutator(double ratePerGene)
/// <summary>
/// Execute Mutation in the individual for reference with based in the rate
/// </summary>
/// <param name="individual">Genome</param>
/// <param name="individual">Individual</param>
public void Mutate(IIndividual<double> individual)
{
for(var locus = 0; locus < individual.Length; locus++)
Expand Down
6 changes: 3 additions & 3 deletions EvolveSharp/Selectors/ISelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ namespace EvolveSharp.Selectors
public interface ISelector
{
/// <summary>
/// Select a genome of population
/// Select one individual of population
/// </summary>
/// <param name="geneticAlgorithm">population which want to select a genome</param>
/// <returns>the genome selected</returns>
/// <param name="population">population which want to select a individual</param>
/// <returns>The individual selected</returns>
IIndividual<T> Select<T>(IList<IIndividual<T>> population);
}
}
8 changes: 4 additions & 4 deletions EvolveSharp/Selectors/RouletteWheelSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace EvolveSharp.Selectors
{
/// <summary>
/// This a kind of Selection called of Roulette Wheel.
/// It chooses a genome at random using the Fitness function as a weight of choice
/// It chooses a individual at random using the Fitness function as a weight of choice
/// </summary>
public class RouletteWheelSelector : ISelector
{
/// <summary>
/// Select one genome of population
/// Select one individual of population
/// </summary>
/// <param name="population">Population with genomes</param>
/// <returns>The genome chosen</returns>
/// <param name="population">Population with individuals</param>
/// <returns>The individual chosen</returns>
public IIndividual<T> Select<T>(IList<IIndividual<T>> population)
{
var tournament = Helper.Random.NextDouble();
Expand Down
18 changes: 9 additions & 9 deletions EvolveSharp/Selectors/TournamentSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ namespace EvolveSharp.Selectors
{
/// <summary>
/// This a kind of Selection called of Tournament.
/// It chooses two genomes at random and compare between them which has a
/// It chooses two individuals at random and compare between them which has a
/// better evaluate through the Fitness Function
/// </summary>
public class TournamentSelector : ISelector
{
/// <summary>
/// Select one genome of population
/// Select one individual of population
/// </summary>
/// <param name="population">Population with genomes</param>
/// <returns>The genome chosen</returns>
/// <param name="population">Population with individuals</param>
/// <returns>The individual chosen</returns>
public IIndividual<T> Select<T>(IList<IIndividual<T>> population)
{
var genome1 = Helper.Random.Next(0, population.Count);
var genome2 = Helper.Random.Next(0, population.Count);
var index1 = Helper.Random.Next(0, population.Count);
var index2 = Helper.Random.Next(0, population.Count);

if (population[genome1].CompareTo(population[genome2]) < 0)
if (population[index1].CompareTo(population[index2]) < 0)
{
return population[genome2];
return population[index2];
}
return population[genome1];
return population[index1];
}
}
}
File renamed without changes.

0 comments on commit a1841b1

Please sign in to comment.