예제 #1
0
 public void Dispose()
 {
     fromTxt    = null;
     toTxt      = null;
     fromCsv    = null;
     toCsv      = null;
     fileFinder = null;
 }
예제 #2
0
        private void startButton_Click(object sender, EventArgs e)
        {
            double a         = Convert.ToDouble(aBox.Text);
            double b         = Convert.ToDouble(bBox.Text);
            double d         = Convert.ToDouble(dBox.Text);
            double tau       = Convert.ToDouble(tauBox.Text);
            int    T         = Convert.ToInt32(Tbox.Text);
            Random generator = new Random();
            int    round     = 0;
            int    l         = (int)Math.Ceiling(Math.Log(((b - a) * (1 / d)) + 1, 2));

            double pom = d;

            while (pom < 1)
            {
                round++;
                pom *= 10;
            }

            List <Individual> individuals = null;
            List <Individual> ListVb      = new List <Individual>();
            List <Individual> ListVbest   = new List <Individual>();
            Individual        Vbest;

            Individual individual = Geo.MakeFirstInd(a, b, d, l, generator);

            Vbest = individual.Clone();
            ListVb.Add(individual.Clone());
            ListVbest.Add(Vbest.Clone());
            for (int i = 1; i < T; i++)
            {
                individuals = Geo.MakePopulation(individual, a, b, l, round);

                Geo.CountProbability(individuals, tau);

                Geo.MutateInd(individual, individuals, a, b, l, round, generator);

                if (Vbest.Fx < individual.Fx)
                {
                    Vbest = individual.Clone();
                }

                ListVbest.Add(Vbest.Clone());
                ListVb.Add(individual.Clone());
                individuals.Clear();
            }

            individuals.Add(Vbest);
            var bindingList = new BindingList <Individual>(individuals);
            var source      = new BindingSource(bindingList, null);

            table.DataSource = source;

            ToTxt.WriteToFile(ListVb, T, tau, d);
            MakeChart(ListVb, ListVbest);
        }
예제 #3
0
 private void clearAll()
 {
     txtName.Clear();
     txtOtherNames.Clear();
     txtMatricNumber.Clear();
     txtUID.Clear();
     txtMatricNumber.Clear();
     boxDepartment.Text = "";
     radioFalse.Select();
     txtUID.Text       = "";
     bxSex.Text        = "";
     txtSearch.Text    = "";
     boxPayment.Text   = "";
     addTicket.Checked = false;
     ToTxt.Clear();
     fromTxt.Clear();
     sendTicket.Clear();
     textMass.Clear();
     pictureBox1.Image = null;
 }
예제 #4
0
        private void startBtn_Click(object sender, EventArgs e)
        {
            double a         = Convert.ToDouble(aBox.Text);
            double b         = Convert.ToDouble(bBox.Text);
            double d         = Convert.ToDouble(dBox.Text);
            int    T         = Convert.ToInt32(Tbox.Text);
            Random generator = new Random();
            int    round     = 0;
            int    l         = (int)Math.Ceiling(Math.Log(((b - a) * (1 / d)) + 1, 2));

            double pom = d;

            while (pom < 1)
            {
                round++;
                pom *= 10;
            }
            List <Individual>         individuals  = new List <Individual>();
            List <List <Individual> > ListofListVc = new List <List <Individual> >();
            List <Individual>         ListVcBest   = new List <Individual>();
            Individual        Vc;
            Individual        VBest = null;
            Individual        Vn;
            List <Individual> listVc;

            for (int i = 0; i < T; i++)
            {
                listVc = new List <Individual>();
                Vc     = HC.MakeFirstInd(a, b, d, l, generator);
                listVc.Add(Vc.Clone());
                if (i == 0)
                {
                    VBest = Vc.Clone();
                }
                while (true)
                {
                    Vn = HC.MakeVn(Vc, a, b, l, round);
                    if (Vn.Fx > Vc.Fx)
                    {
                        Vc = Vn.Clone();
                        listVc.Add(Vc.Clone());
                    }
                    else
                    {
                        break;
                    }
                }
                ListofListVc.Add(listVc);
                if (VBest.Fx < Vc.Fx)
                {
                    VBest = Vc.Clone();
                }
                ListVcBest.Add(VBest.Clone());
                if (VBest.Xreal == 10.999)
                {
                    break;
                }
            }
            individuals.Add(VBest);
            var bindingList = new BindingList <Individual>(individuals);
            var source      = new BindingSource(bindingList, null);

            table.DataSource = source;
            ToTxt.WriteToFile(ListofListVc, T, d);
            MakeChart(ListofListVc, ListVcBest);
        }