/// <summary> /// Initializes a new instance of the TradeSystemChromosome class. /// </summary> /// <param name="tradeSystem">The trade system the chromosome represents.</param> /// <param name="indicatorHelper">The indicator helper for randomizing the chromosome.</param> /// <param name="size">Chromosome size.</param> public TradeSystemChromosome(TradeSystem tradeSystem, IndicatorHelper indicatorHelper, int size) { TradeSystem temp = new TradeSystem(); temp.BuyCondition = new TradeCondition(); this.size = size; this.ChromosomeValue = temp; this.indicatorHelper = indicatorHelper; }
/// <summary> /// Initializes a new instance of the GeneticAlgorithm class. /// </summary> /// <param name="chromosomes">The number of chromosomes in the population.</param> /// <param name="generations">The number of generations to run.</param> /// <param name="chromosomeSize">The size of the chromosomes.</param> /// <param name="tradeSystemTemplate">A template to make TradeSystemChromosomes with</param> /// <param name="indicatorHelper">The indicator helper for generating new chromosomes.</param> /// <param name="breedingAlgorithm">The algorithm to breed with.</param> /// <param name="mutatingAlgorithm">The algorithm to mutate with.</param> /// <param name="fitnessAlgorithm">The algorithm to calculate fitness.</param> public GeneticAlgorithm(int chromosomes, int generations, int chromosomeSize, TradeSystem tradeSystemTemplate, IndicatorHelper indicatorHelper, IGeneticBreeding breedingAlgorithm, IGeneticMutating mutatingAlgorithm, IGeneticFitness fitnessAlgorithm) { this.chromosomes = new TradeSystemChromosome[chromosomes]; for (int i = 0; i < chromosomes; i++) { TradeSystemChromosome newchromosome = new TradeSystemChromosome(tradeSystemTemplate, indicatorHelper, chromosomeSize); this.chromosomes[i] = newchromosome; } this.generations = generations; this.breedingAlgorithm = breedingAlgorithm; this.fitnessAlgorithm = fitnessAlgorithm; this.mutatingAlgorithm = mutatingAlgorithm; GeneratePopulation(); }
/// <summary> /// Initializes a new instance of the TradeConditionMutation class. /// </summary> /// <param name="rate">The mutation rate.</param> /// <param name="indicatorHelper">The indicator helper to mutate with.</param> public TradeConditionMutation(double rate, IndicatorHelper indicatorHelper) { this.indicatorHelper = indicatorHelper; this.rate = rate; this.rand = new Random(); }