Beispiel #1
0
        public static int BinaryToDecimal(Gena binary)
        {
            var deca = 0;

            deca = Convert.ToInt32(binary.ToString(), 2);
            return(deca);
        }
Beispiel #2
0
        public static Gena DecimalToBinary(int dec)
        {
            List <int> bools = new List <int>()
            {
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0
            };

            string s = Convert.ToString(dec, 2);
            var    j = s.Length - 1;

            for (int i = bools.Count - 1; i >= 0 && j >= 0; i--)
            {
                bools[i] = s[j] - 48;
                j--;
            }

            var g = new Gena();

            g.ValoareGena = bools;
            return(g);
        }
 public void CreateRandom()
 {
     for (var i = 0; i < Config.MarimeCromozom; i++)
     {
         var gena = new Gena();
         gena.CreateRandom();
         while (Config.BinaryToDecimal(gena) >= Config.Domeniu.Count)
         {
             gena.CreateRandom();
         }
         ListaGene.Add(gena);
     }
 }