示例#1
0
        private void MutateChromosome(SetCoveringProblemData data, int [] chromosome, int n)
        {
            int k = Utility.Random.Next(n);

            var probabilityOfMutation = 1.0 / E(data, k);

            double probabilityDivistionFactor = 0;

            for (int i = 0; i < n; ++i)
            {
                probabilityDivistionFactor += 1.0 / E(data, i);
            }

            probabilityOfMutation /= probabilityDivistionFactor;

            if (probabilityOfMutation > 1.0 / n && data.ColumnCount(0, k) > data.ColumnCount(1, k))
            {
                chromosome[k] = (chromosome[k] + 1) % 2;
            }
        }
示例#2
0
 private double E(SetCoveringProblemData data, int j)
 {
     return(-data.ColumnCount(0, j) * Math.Log(data.ColumnCount(0, j)) - data.ColumnCount(1, j) * Math.Log(data.ColumnCount(1, j)));
 }