Closed constructor-igor closed 5 years ago
You can inherit from Population
class and override the CreateNewGeneration
method:
public class ExternalEvaluationPopulation : Population
{
public override void CreateNewGeneration(IList<IChromosome> chromosomes)
{
base.CreateNewGeneration(chromosomes);
// Here you can send all chromosomes from CurrentGeneration property to your HPC system,
// then, after the HPC system returns the fitness value, you can set it on each chromosome's Fitness property.
}
}
And your IFitness implementation just needs to return the chromosome pre-calculated fitness:
public class MyProblemFitness : IFitness
{
public double Evaluate (IChromosome chromosome)
{
return chromosome.Fitness.Value;
}
}
thank you for explanation! I'll try and inform.
Today, GeneticSharp calculates fitness by single chromosome. Calculation of fitness for my problem can take a time and I want to sends all calculation (single population) to a HPC system. How can I get all chromosomes, calculate all fitness values and return them?