Example #1
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();
        }
Example #2
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();
        }