Beispiel #1
0
 public MelodyGenerator(ICrossoverOperator crossoverOperator, ISimilarityFitnessCalculator fitnessCalculator, IInitializazer initializer, List <IMeasureMutationOperator> measureMutationOperators, List <IMelodyMutationOperator> melodyMutationOperators, IReplacementOperator replacementOperator, ISelector selector, IStoppingCriterionChecker stopChecker)
 {
     _crossoverOperator        = crossoverOperator;
     _fitnessCalculator        = fitnessCalculator;
     _initializer              = initializer;
     _measureMutationOperators = measureMutationOperators;
     _melodyMutationOperators  = melodyMutationOperators;
     _replacementOperator      = replacementOperator;
     _selector    = selector;
     _stopChecker = stopChecker;
     Generations  = new List <Population>();
 }
 public SteadyStateGeneticAlgorithm(
     IProblem <T> problem,
     int populationSize,
     ISelectionOperator <T> selectionOperator,
     ICrossoverOperator <T> crossoverOperator,
     IMutationOperator <T> mutationOperator,
     ITerminationCondition terminationCondition,
     double generationGap,
     IReplacementOperator <T> replacementOperator) :
     base(problem, populationSize, selectionOperator,
          crossoverOperator, mutationOperator, terminationCondition)
 {
     _generationGap       = generationGap;
     _replacementOperator = replacementOperator;
 }
 public GeneticAlgorithmBuilder(
     IProblem <T> problem,
     ICrossoverOperator <T> crossoverOperator,
     IMutationOperator <T> mutationOperator)
 {
     _problem             = problem;
     _crossoverOperator   = crossoverOperator;
     _mutationOperator    = mutationOperator;
     _selectionOperator   = new TournamentSelectionOperator <T>(3, problem);
     _replacementOperator = new WorstFitnessReplacementOperator <T>(problem);
     _populationSize      = 1000;
     _maxGenerations      = 1000;
     _maxEvaluations      = 100000;
     _fitnessValue        = 10e-6;
     _elitismRate         = 1.0 / _populationSize;
     _generationGap       = 0.4;
     _variant             = GeneticAlgorithmVariant.SteadyState;
 }
 public GeneticAlgorithmBuilder <T> SetReplacementOperator(IReplacementOperator <T> replacementOperator)
 {
     _replacementOperator = replacementOperator;
     return(this);
 }