private void Changed(object sender, GeneticAPI.Events.APIEventArgs e) { if (!String.IsNullOrWhiteSpace(e.message)) { Console.Write(e.message); } Console.WriteLine(e.avgfitness); }
public GUIGAEvent(GeneticAPI.Events.APIEventArgs e, int ai_generations) : base(e.message, e.error, e.avgfitness, e.popbestfitness, e.bestfitness, e.bestchrom, e.finished) { ii_generations = ai_generations; }
//Handles event from GA. private void Changed(object sender, GeneticAPI.Events.APIEventArgs e) { if (ida_starttime == DateTime.MinValue) { ida_starttime = DateTime.Now; } //Record statistics. ii_reccount++; id_avgavg += e.avgfitness; id_avgavgavg += e.avgfitness; il_msgcount++; ii_gencount++; if (e.finished) { Complete(); } if (ii_reccount >= ii_recpergen) { e.avgfitness = (id_avgavg / ii_reccount); id_best = e.bestfitness; is_bestchrom = e.bestchrom; ii_reccount = 0; id_avgavg = 0; //Send event to GUI. GUIGAEvent gui_e = new GUIGAEvent(e, ii_gencount); if (ii_gencount > ii_generations) gui_e.ib_pastgens = true; OnChartUpdate(gui_e); } }