Add enum for Selection method

This commit is contained in:
2025-07-11 17:15:11 +07:00
parent f720cb7321
commit c62570e15d
10 changed files with 59 additions and 39 deletions

View File

@@ -203,7 +203,7 @@ public class GeneticService : IGeneticService
int populationSize,
int generations,
double mutationRate,
string selectionMethod,
GeneticSelectionMethod selectionMethod,
int elitismPercentage,
double maxTakeProfit,
List<IndicatorType> eligibleIndicators)
@@ -422,13 +422,13 @@ public class GeneticService : IGeneticService
}
}
private ISelection GetSelection(string selectionMethod)
private ISelection GetSelection(GeneticSelectionMethod selectionMethod)
{
return selectionMethod.ToLower() switch
return selectionMethod switch
{
"tournament" => new TournamentSelection(),
"roulette" => new RouletteWheelSelection(),
"fitness-weighted" => new RankSelection(), // Use rank selection as approximation
GeneticSelectionMethod.Tournament => new TournamentSelection(),
GeneticSelectionMethod.Roulette => new RouletteWheelSelection(),
GeneticSelectionMethod.FitnessWeighted => new RankSelection(), // Use rank selection as approximation
_ => new TournamentSelection()
};
}