public virtual void Initialize( MachineDescription machineDescription, ProgramGraph programGraph) { this.machineDescription = machineDescription; this.programGraph = programGraph; transferInstructions = machineDescription.GetTransferInstructions(); operationNodes = programGraph.GetOperationNodes(); valueNodes = programGraph.GetValueNodes(); coveringDesc = programGraph.CreateCoveringDesc(machineDescription.Instructions); population = new SelectionGenomePopulation(PopulationSize, this); population.ScalingOperator = new LinearScaling(ScalingFactor, true); population.SelectionOperator = new RouletteWheelSelection(); population.MutationOperator = new SelectionGenomeMutation(); population.CrossoverOperator = new SelectionGenomeCrossover(); population.GenomeEvaluator = new SelectionGenomeEvaluator(scheduler); ga = new SimpleGA(population); ga.PMutation = configuration.PMutation; ga.PCrossover = configuration.PCrossover; ga.ComputeObjectiveStatistics = configuration.ComputeObjectiveStatistics; ga.ComputeFitnessStatistics = configuration.ComputeFitnessStatistics; ga.ComputeGenomeDiversity = configuration.ComputeGenomeDiversity; ga.GenerationComputed += new SimpleGA.EventHandler(UpdateGAMonitor); bestObjectiveMonitor = new double[MonitoredGenerations]; if (Initialized != null) Initialized(this); }
protected virtual void UpdateGAMonitor(SimpleGA ga) { int indexOfCurrentGen = ga.Generation % MonitoredGenerations; bestObjectiveMonitor[indexOfCurrentGen] = BestIndividual.Objective; }
protected virtual void InitializeGA() { ga = new SimpleGA(population); ga.PCrossover = configuration.PCrossover; ga.ComputeObjectiveStatistics = configuration.ComputeObjectiveStatistics; ga.ComputeFitnessStatistics = configuration.ComputeFitnessStatistics; ga.ComputeGenomeDiversity = configuration.ComputeGenomeDiversity; ga.GenerationComputed += new SimpleGA.EventHandler(UpdateGAMonitor); }