Exemplo n.º 1
0
 public void OnProgress(TChromosome best)
 {
     DataChart.Series[0].Points.AddY(best.Fitness);
     DataChart.Update();
     ErrorLbl.Text = "Error: " + HighScore.ToString();
     ErrorLbl.Refresh();
 }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     ErrorLbl.Hide();
     Cap       = TB1.Text;
     TotalFuel = TB2.Text;
     if (Cap != "" && TotalFuel != "")
     {
         try
         {
             TotalF = Convert.ToInt32(TotalFuel);
             SetUp(TotalF);
         }
         catch
         {
             ErrorLbl.Text = "Enter a correct Fuel Value";
             ShowHide();
         }
     }
     else
     {
         ErrorLbl.Text = "Fill All Textboxes";
         ShowHide();
     }
 }
Exemplo n.º 3
0
        private void runAlgo()
        {
            LoadAlgo();
            var bw = new BackgroundWorker();

            bw.DoWork += (sender, args) =>
            {
                int done    = 0;
                int shuffle = 0;
                while (done < GlobalJadwal.GlobalSolusi.Count)
                {
                    Row = Log.NewRow(); Row["Status"] = "Waktu"; Row["Keterangan"] = "Cek Penalti";
                    Log.Rows.Add(Row);
                    LokalPinalti = optimasi.local_pinalti(GlobalJadwal.GlobalSolusi[done]);
                    Row          = Log.NewRow(); Row["Status"] = "Lokal Penalti"; Row["Keterangan"] = "Lokal Penalti : " + LokalPinalti;
                    Log.Rows.Add(Row);
                    GlobalPinalti = optimasi.global_pinalti(GlobalJadwal, done);
                    Row           = Log.NewRow(); Row["Status"] = "Global Penalti"; Row["Keterangan"] = "Global Penalti : " + GlobalPinalti;
                    Log.Rows.Add(Row);
                    if (GlobalPinalti == 0 && LokalPinalti == 0)
                    {
                        Row = Log.NewRow(); Row["Status"] = "Optimal"; Row["Keterangan"] = "Kelas : " + GlobalJadwal.GlobalSolusi[done].Kelas;
                        Log.Rows.Add(Row);
                        done++;
                        double x = (done * 1.00 / GlobalJadwal.GlobalSolusi.Count * 1.00) * 100.00;
                        x = Math.Floor(x);
                        progress_loading.Invoke((MethodInvoker)(() => progress_loading.Text = x + "%"));
                        loading.Invoke((MethodInvoker)(() => loading.Value = int.Parse(x.ToString())));
                        shuffle = 0;
                    }
                    else
                    {
                        Row = Log.NewRow(); Row["Status"] = "Proses"; Row["Keterangan"] = "Interchanging";
                        Log.Rows.Add(Row);
                        GlobalJadwal = optimasi.interchanging(GlobalJadwal, done);
                        Row          = Log.NewRow(); Row["Status"] = "Waktu"; Row["Keterangan"] = "Cek Penalti";
                        Log.Rows.Add(Row);
                        LokalPinalti = optimasi.local_pinalti(GlobalJadwal.GlobalSolusi[done]);
                        Row          = Log.NewRow(); Row["Status"] = "Lokal Penalti"; Row["Keterangan"] = "Lokal Penalti : " + LokalPinalti;
                        Log.Rows.Add(Row);
                        GlobalPinalti = optimasi.global_pinalti(GlobalJadwal, done);
                        Row           = Log.NewRow(); Row["Status"] = "Global Penalti"; Row["Keterangan"] = "Global Penalti : " + GlobalPinalti;
                        Log.Rows.Add(Row);
                        if (GlobalPinalti > 0 || LokalPinalti > 0)
                        {
                            Row = Log.NewRow(); Row["Status"] = "Proses"; Row["Keterangan"] = "Insertion";
                            Log.Rows.Add(Row);
                            GlobalJadwal.GlobalSolusi[done] = optimasi.insertion(GlobalJadwal.GlobalSolusi[done]);

                            Row = Log.NewRow(); Row["Status"] = "Proses"; Row["Keterangan"] = "Intensifikasi";
                            Log.Rows.Add(Row);
                            GlobalJadwal = optimasi.intensifikasi(GlobalJadwal, done);
                            shuffle++;
                        }
                        else
                        {
                            done++;
                            double x = (done * 1.00 / GlobalJadwal.GlobalSolusi.Count * 1.00) * 100.00;
                            x = Math.Floor(x);
                            progress_loading.Invoke((MethodInvoker)(() => progress_loading.Text = x + "%"));
                            loading.Invoke((MethodInvoker)(() => loading.Value = int.Parse(x.ToString())));
                            shuffle = 0;
                        }
                    }
                    if (done < GlobalJadwal.GlobalSolusi.Count)
                    {
                        ErrorLbl.Invoke((MethodInvoker)(() => ErrorLbl.Text = GlobalJadwal.GlobalSolusi[done].Kelas + " Lokal Penalti: " + LokalPinalti.ToString()));
                        GlobalErrorLbl.Invoke((MethodInvoker)(() => GlobalErrorLbl.Text = GlobalJadwal.GlobalSolusi[done].Kelas + " Global Penalti: " + GlobalPinalti.ToString() + done.ToString()));
                    }
                    if (shuffle > 500)
                    {
                        if (shuffle < 3 && done > 0)
                        {
                            done -= 1;
                        }
                        else if (done >= 3)
                        {
                            done -= 2;
                        }
                        double x = (done * 1.00 / GlobalJadwal.GlobalSolusi.Count * 1.00) * 100.00;
                        x = Math.Floor(x);
                        progress_loading.Invoke((MethodInvoker)(() => progress_loading.Text = x + "%"));
                        loading.Invoke((MethodInvoker)(() => loading.Value = int.Parse(x.ToString())));
                        shuffle = 0;
                        Row     = Log.NewRow(); Row["Status"] = "Proses"; Row["Keterangan"] = "Insertion";
                        Log.Rows.Add(Row);
                        GlobalJadwal.GlobalSolusi[done] = optimasi.insertion(GlobalJadwal.GlobalSolusi[done]);
                        Row = Log.NewRow(); Row["Status"] = "Proses"; Row["Keterangan"] = "Intensifikasi";
                        Log.Rows.Add(Row);
                        GlobalJadwal = optimasi.intensifikasi(GlobalJadwal, done);
                        shuffle++;
                    }

                    Thread.Sleep(200);
                }
            };
            bw.RunWorkerCompleted += (sender, args) =>
            {
                hasiljadwal x = new hasiljadwal(this);
                op = true;
                x.Show();
                this.Close();
            };

            bw.RunWorkerAsync();
        }
Exemplo n.º 4
0
 private void ShowHide()
 {
     ErrorLbl.Show();
 }
Exemplo n.º 5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     ErrorLbl.Hide();
 }
Exemplo n.º 6
0
        void ReleaseDesignerOutlets()
        {
            if (Acc != null)
            {
                Acc.Dispose();
                Acc = null;
            }

            if (AccLbl != null)
            {
                AccLbl.Dispose();
                AccLbl = null;
            }

            if (Alt != null)
            {
                Alt.Dispose();
                Alt = null;
            }

            if (AltAcc != null)
            {
                AltAcc.Dispose();
                AltAcc = null;
            }

            if (AltAccLbl != null)
            {
                AltAccLbl.Dispose();
                AltAccLbl = null;
            }

            if (AltLbl != null)
            {
                AltLbl.Dispose();
                AltLbl = null;
            }

            if (Error != null)
            {
                Error.Dispose();
                Error = null;
            }

            if (ErrorLbl != null)
            {
                ErrorLbl.Dispose();
                ErrorLbl = null;
            }

            if (Hdg != null)
            {
                Hdg.Dispose();
                Hdg = null;
            }

            if (HdgAcc != null)
            {
                HdgAcc.Dispose();
                HdgAcc = null;
            }

            if (HdgAccLbl != null)
            {
                HdgAccLbl.Dispose();
                HdgAccLbl = null;
            }

            if (HdgLbl != null)
            {
                HdgLbl.Dispose();
                HdgLbl = null;
            }

            if (Lat != null)
            {
                Lat.Dispose();
                Lat = null;
            }

            if (LatLbl != null)
            {
                LatLbl.Dispose();
                LatLbl = null;
            }

            if (Lon != null)
            {
                Lon.Dispose();
                Lon = null;
            }

            if (LonLbl != null)
            {
                LonLbl.Dispose();
                LonLbl = null;
            }

            if (Spd != null)
            {
                Spd.Dispose();
                Spd = null;
            }

            if (SpdLbl != null)
            {
                SpdLbl.Dispose();
                SpdLbl = null;
            }

            if (Updated != null)
            {
                Updated.Dispose();
                Updated = null;
            }

            if (UpdatedLbl != null)
            {
                UpdatedLbl.Dispose();
                UpdatedLbl = null;
            }
        }