GeneticSharp is a fast, extensible, multi-platform and multithreading C# Genetic Algorithm library that simplifies the development of applications using Genetic Algorithms (GAs).
I'm trying to understand which type of Chromosome should I be considering to solve my problem.
In my case, I receive a ingredient stock. Every ingredient has a price and list of nutrients related. I must generate formulas that accomplish nutritional conditions (a list of nutrients within a specified range) with the minimum cost. So, my GA algorithm, not only has to tell me which ingredient choses, but also its amount. I tried with ChromosomeBase:
public class FormulaChromosome : ChromosomeBase
{
private readonly List<IngredientContract> _ingredientContracts;
public FormulaChromosome(List<IngredientContract> ingredientContracts) : base(ingredientContracts.Count)
{
_ingredientContracts = ingredientContracts;
CreateGenes();
}
public override Gene GenerateGene(int geneIndex)
{
return new Gene(RandomizationProvider.Current.GetInt(0, 101));
}
public override IChromosome CreateNew()
{
return new FormulaChromosome(_ingredientContracts);
}
public List<IngredientContract> GetIngredientContracts()
{
var ingredientList = new List<IngredientContract>();
for (int i = 0; i < Length; i++)
{
_ingredientContracts[i].PercentageTaken = (int)(GetGene(i).Value);
ingredientList.Add(_ingredientContracts[i]);
}
return ingredientList;
}
}
GenerateGene returns an integer [0, 100] which I consider to be the percentage taken of that gene (ingredient) from the given stock.
Is my problem codification ok? Should I change to FloatingPointChromosome for this case?
I'm trying to understand which type of Chromosome should I be considering to solve my problem.
In my case, I receive a ingredient stock. Every ingredient has a price and list of nutrients related. I must generate formulas that accomplish nutritional conditions (a list of nutrients within a specified range) with the minimum cost. So, my GA algorithm, not only has to tell me which ingredient choses, but also its amount. I tried with ChromosomeBase:
GenerateGene returns an integer [0, 100] which I consider to be the percentage taken of that gene (ingredient) from the given stock.
Is my problem codification ok? Should I change to FloatingPointChromosome for this case?