Пример #1
0
 protected virtual void OnChartUpdate(GUIGAEvent e)
 {
     if (ChartUpdate != null)
     {
         ChartUpdate(this, e);
     }
 }
Пример #2
0
        //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);
            }
        }
Пример #3
0
        //Recieve changed event from GA class.
        private void Changed(object sender, GUIGAEvent e)
        {
            if (!e.ib_pastgens)
            {
                UpdateLabels(e);
                for (int i = 0; i < SERIES.Count; i++)
                {
                    if (SERIES[i] == "Average Fitness")
                    {
                        UpdateGraph(SERIES[i], e.avgfitness);
                    }
                    else
                    {
                        UpdateGraph(SERIES[i], e.bestfitness);
                    }
                }
            }
            if (e.finished)
            {
                try
                {
                    //try
                    //{
                    //    io_ga.SROGThread.Abort();
                    //} catch (Exception ex)
                    //{
                    //    Debug.WriteLine("Couldn't abort SROG thread");
                    //}
                    SROGThreads.Add(io_ga.SROGThread);
                    io_gathread.Abort();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("oops");
                }
                finally
                {
                    io_gathread = null;
                    WriteToPDF("Results/" + io_runs[0].FileName());

                    UpdateListBox();
                    //io_runs = new BindingList<GARun>(io_runs);
                    Start();
                }
            }
        }
Пример #4
0
 //Updates the labels.
 private void UpdateLabels(GUIGAEvent e)
 {
     try
     {
         if (this.cha_line_ga.InvokeRequired)
         {
             UpdateLabelsCallback lo_cb = new UpdateLabelsCallback(UpdateLabels);
             this.Invoke(lo_cb, new Object[] { e });
         }
         else
         {
             lb_bestfit.Text = e.bestfitness.ToString();
             lb_gen.Text     = e.ii_generations.ToString();
             lb_pavfit.Text  = e.avgfitness.ToString();
             lb_bestc.Text   = e.bestchrom;
         }
     }
     catch (Exception ex)
     {
     }
 }
Пример #5
0
        //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);
            }
        }
Пример #6
0
 protected virtual void OnChartUpdate(GUIGAEvent e)
 {
     if (ChartUpdate != null)
     {
         ChartUpdate(this, e);
     }
 }
Пример #7
0
        //Updates the labels.
        private void UpdateLabels(GUIGAEvent e)
        {
            try
            {
                if (this.cha_line_ga.InvokeRequired)
                {
                    UpdateLabelsCallback lo_cb = new UpdateLabelsCallback(UpdateLabels);
                    this.Invoke(lo_cb, new Object[] { e });
                }
                else
                {
                    lb_bestfit.Text = e.bestfitness.ToString();
                    lb_gen.Text = e.ii_generations.ToString();
                    lb_pavfit.Text = e.avgfitness.ToString();
                    lb_bestc.Text = e.bestchrom;
                }
            }
            catch (Exception ex)
            {

            }
        }
Пример #8
0
        //Recieve changed event from GA class.
        private void Changed(object sender, GUIGAEvent e)
        {
            if (!e.ib_pastgens)
            {
                UpdateLabels(e);
                for (int i = 0; i < SERIES.Count; i++)
                {
                    if (SERIES[i] == "Average Fitness")
                    {
                        UpdateGraph(SERIES[i], e.avgfitness);
                    }
                    else
                    {
                        UpdateGraph(SERIES[i], e.bestfitness);
                    }
                }
            }
            if (e.finished)
            {
                try
                {
                    //try
                    //{
                    //    io_ga.SROGThread.Abort();
                    //} catch (Exception ex)
                    //{
                    //    Debug.WriteLine("Couldn't abort SROG thread");
                    //}
                    SROGThreads.Add(io_ga.SROGThread);
                    io_gathread.Abort();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("oops");
                }
                finally
                {
                    io_gathread = null;
                    WriteToPDF("Results/" + io_runs[0].FileName());

                    UpdateListBox();
                    //io_runs = new BindingList<GARun>(io_runs);
                    Start();
                }

            }
        }