private static HabitatConfiguration GetHabitatConfiguration() { HabitatConfiguration config = new HabitatConfiguration(); config.CrossoverRate = .7; config.FitnessAlgorithm = new DifferenceAlgorithm(new MathChromosomeInterpreter(), goalValue); config.MutationRate = .001; config.NumberGenerator = numberGenerator; config.PoolGenerator = new BinaryChromosomePoolGenerator(numberGenerator, new BinaryChromosomePoolConfiguration() { ChromosomeSequenceLength = chromosomeLength, PadToNibble = false }); config.ReproductionSelector = new RouletteWheelSelector(numberGenerator); config.SequenceMutator = new BinarySequenceMutator(); return(config); }
private static void Initialize() { goalValue = GetGoalValue(); numberGenerator = new Random(); HabitatConfiguration config = GetHabitatConfiguration(); myHabitat = new Habitat(config); nextPool = new List <Chromosome>(); source = new Chromosome(); source.Score = int.MaxValue; target = new Chromosome(); target.Score = int.MaxValue; alpha = new Chromosome(); alpha.Score = double.MaxValue; pool = myHabitat.GenerateSeedPool(populationSize); myHabitat.Score(pool); }