Esempio n. 1
0
        void btnStart_Click(object sender, EventArgs e)
        {
            if (MaxProcesses < 1 || MaxMachines < 1 || MaxJob < 1)
            {
                MessageBox.Show("Erro ao PLanificar : Não existem Processoes, Maquinas ou Trabalhos para efectuar");
                return;
            }
            this.timer1.Enabled  = true;
            this.timer1.Interval = 500;

            /*try
             * {*/
            Data.DataTable = getDatas();
            Data.Tasks     = Tasks;
            Data.Machines  = ResourcesNeeded;
            Colors.GenerateRandomHSV(MaxJob, MaxProcessCount);
            if (genetik != null && !genetik.Stopped)
            {
                genetik.Stop();
                Thread.Sleep(100);
            }

            int popSize = 10000;


            genetik = new GeneticMachine(MaxJob, MaxProcesses, MaxMachines, popSize);

            genetik.MutOdd     = 1;
            genetik.GroupSize  = 5;
            genetik.MinTimeOdd = 0;

            genetik.SelectionType = (SelectionTypes)SelectionTypes.Tournament;
            genetik.CrossOver     = (COTypes)COTypes.TwoPoint;
            genetik.MutationTypes = (MutationTypes)MutationTypes.ChangeValue;

            genetik.Refresh           = true;
            genetik.BestValueChanged += genetik_BestValueChanged;
            genetik.ProgressChanged  += genetik_ProgressChanged;
            best = true;
            stp.Reset();
            stp.Start();
            genetik.Start();
            btnStop.Enabled = true;

            /*}
             * catch(Exception ea)
             * {
             *  MessageBox.Show("Data table is wrong");
             * }*/
        }
Esempio n. 2
0
        void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                btnExport.Enabled = false;
                Data.DataTable    = getDatas();
                Colors.GenerateRandomHSV(job);
                if (genetik != null && !genetik.Stopped)
                {
                    genetik.Stop();
                    Thread.Sleep(100);
                }

                int popSize = popnmud.Value.ToInt();
                genetik = new GeneticMachine(job, proc, mac, popSize);

                genetik.MutOdd     = mutnmud.Value.ToInt();
                genetik.GroupSize  = groupnmud.Value.ToInt();
                genetik.MinTimeOdd = nmudMinTime.Value.ToInt();

                genetik.SelectionType = (SelectionTypes)cbSelTypes.SelectedIndex;
                genetik.CrossOver     = (COTypes)cbCOTypes.SelectedIndex;
                genetik.MutationTypes = (MutationTypes)cbMutTypes.SelectedIndex;

                genetik.Refresh           = chkRefresh.Checked;
                genetik.BestValueChanged += genetik_BestValueChanged;
                genetik.ProgressChanged  += genetik_ProgressChanged;
                best             = true;
                resPanel.Visible = true;
                resPanel.Width   = boxPanel.Width;
                resPanel.Height  = this.Height - btnHideRes.Top - 60;
                boxPanel.Visible = false;
                stp.Reset();
                stp.Start();
                genetik.Start();
                btnStop.Enabled = true;
                btnHideRes.Text = "<<";
            }
            catch
            {
                MessageBox.Show("Data table is wrong");
            }
        }