Dynamic_Games.PAES.mutate C# (CSharp) Method

mutate() public method

public mutate ( Solution s ) : void
s Solution
return void
        void mutate(Solution s)
        {
            int i;
            int var;

            for (i = 0; i < genes; i++)
            {
                if ((r.Next() / (Int32.MaxValue + 1.0)) < pm) // mutate gene ?
                {
                    var = 1 + (int)((alleles - 1) * (r.Next() / (Int32.MaxValue + 1.0)));  // generate var between 1 and alleles-2
                    s.chrom[i] = (s.chrom[i] + var) % alleles;  // add var to allele value of current gene and mod.
                }
            }
        }