private void button1_Click(object sender, EventArgs e)
        {
            Boolean terminate = false;
            DateTime Begin = DateTime.Now;
            //while(terminate == false)
            //{
            PopulationGenerator popGen = new PopulationGenerator(Convert.ToInt32(txt_PopSize.Text), Convert.ToInt32(txt_ChromosomeLength.Text));
            Population = popGen.GeneratePopulation();
            Z340 z340 = new Z340();

            Fitness fit = new Fitness(Population, z340);
            Population = fit.calcFitness();

            //Selection selection = new Selection(Population);
            //Chromosome[] intermediate = selection.selectAlleles();

            //Genetics gen = new Genetics(Convert.ToDouble(txt_CrossoverRate.Text), Convert.ToDouble(txt_MutationRate.Text));
            //Population = gen.reproduce(intermediate);

            //Termination terminator = new Termination();
            //terminate = terminator.doesTerminate(Begin);
            //}

            foreach(Chromosome c in Population)
            {
                label1.Text += c.ToString();
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Boolean  terminate = false;
            DateTime Begin     = DateTime.Now;
            //while(terminate == false)
            //{
            PopulationGenerator popGen = new PopulationGenerator(Convert.ToInt32(txt_PopSize.Text), Convert.ToInt32(txt_ChromosomeLength.Text));

            Population = popGen.GeneratePopulation();
            Z340 z340 = new Z340();

            Fitness fit = new Fitness(Population, z340);

            Population = fit.calcFitness();

            //Selection selection = new Selection(Population);
            //Chromosome[] intermediate = selection.selectAlleles();

            //Genetics gen = new Genetics(Convert.ToDouble(txt_CrossoverRate.Text), Convert.ToDouble(txt_MutationRate.Text));
            //Population = gen.reproduce(intermediate);

            //Termination terminator = new Termination();
            //terminate = terminator.doesTerminate(Begin);
            //}

            foreach (Chromosome c in Population)
            {
                label1.Text += c.ToString();
            }
        }
示例#3
0
        public Fitness(Chromosome[] population, Z340 cipher)
        {
            Population = population;
            Cipher     = cipher;

            Search    = new ngram[10];
            Search[0] = new ngram("th", 2);
            Search[1] = new ngram("he", 1);
            Search[2] = new ngram("in", 1);
            Search[3] = new ngram("er", 1);
            Search[4] = new ngram("an", 1);
            Search[5] = new ngram("ed", 1);
            Search[6] = new ngram("the", 5);
            Search[7] = new ngram("ing", 5);
            Search[8] = new ngram("and", 5);
            Search[9] = new ngram("eee", -5);
        }
        public Fitness(Chromosome[] population, Z340 cipher)
        {
            Population = population;
            Cipher = cipher;

            Search = new ngram[10];
            Search[0] = new ngram("th", 2);
            Search[1] = new ngram("he", 1);
            Search[2] = new ngram("in", 1);
            Search[3] = new ngram("er", 1);
            Search[4] = new ngram("an", 1);
            Search[5] = new ngram("ed", 1);
            Search[6] = new ngram("the", 5);
            Search[7] = new ngram("ing", 5);
            Search[8] = new ngram("and", 5);
            Search[9] = new ngram("eee", -5);
        }