Ejemplo n.º 1
0
        public Xromossomi nachlist()
        {
            Xromossomi xrom = new Xromossomi();

            for (int i = 0; i < _countType; i++)
            {
                xrom.GenList.Add(new List <int>());
            }
            xrom.GenListOst.AddRange(_countClaims);

            for (int j = 0; j < xrom.GenList.Count; j++)
            {
                int buff = 0;
                for (int i = 0; i < N / 2 - 1; i++)
                {
                    if (xrom.GenListOst[j] == 2)
                    {
                        buff = 2;
                        xrom.GenListOst[j] = 0;
                    }
                    else
                    if (xrom.GenListOst[j] == 1)
                    {
                        xrom.GenList[j][xrom.GenList[j].Count - 1]++;
                        xrom.GenListOst[j] = 0;
                        buff = 0;
                    }
                    else
                    if (xrom.GenListOst[j] == 0)
                    {
                        buff = 0;
                    }
                    else
                    {
                        xrom.GenListOst[j] -= buff = rand.Next(2, xrom.GenListOst[j]);
                    }
                    xrom.GenList[j].Add(buff);
                }
                xrom.GenList[j].Add(xrom.GenListOst[j]);
            }
            return(xrom);
        }
Ejemplo n.º 2
0
        Xromossomi nach()
        {
            Xromossomi xrom = new Xromossomi();
            int        buff = 0;

            for (int i = 0; i < N / 2 - 1; i++)
            {
                if (xrom.ostA == 2)
                {
                    buff      = 2;
                    xrom.ostA = 0;
                }
                else
                if (xrom.ostA == 1)
                {
                    xrom.GenA[xrom.GenA.Count - 1]++;
                    xrom.ostA = 0;
                    buff      = 0;
                }
                else
                if (xrom.ostA == 0)
                {
                    buff = 0;
                }
                else
                {
                    xrom.ostA -= buff = rand.Next(2, xrom.ostA);
                }
                xrom.GenA.Add(buff);
            }
            xrom.GenA.Add(xrom.ostA);
            //
            int s = N % 3 == 2 ? N / 3 + 1 : N / 3;
            int t = N % 3 == 1 || N % 3 == 2 ? N / 3 + 1 : N / 3;

            buff = 0;
            for (int i = 0; i < N / 2 - 1; i++)
            {
                if (xrom.ostB == 0 && 10 == xrom.GenA.Sum() && xrom.GenA[2] != 0)
                {
                }

                if (xrom.ostB == 2)
                {
                    buff      = 2;
                    xrom.ostB = 0;
                }
                else
                if (xrom.ostB == 1)
                {
                    if (xrom.GenB.Count == 0)
                    {
                        xrom.GenA[(N / 3) - 1]++;
                    }
                    else
                    {
                        xrom.GenB[xrom.GenB.Count - 1]++;
                    }
                    xrom.ostB = 0;
                }
                else
                if (xrom.ostB == 0)
                {
                    buff = 0;
                }
                else
                {
                    xrom.ostB -= buff = rand.Next(2, xrom.ostB);
                }
                xrom.GenB.Add(buff);
            }
            xrom.GenB.Add(xrom.ostB);

            ///
            for (int i = 0; i < N / 2 - 1; i++)
            {
                if (xrom.ostC == 2)
                {
                    buff      = 2;
                    xrom.ostC = 0;
                }
                else
                if (xrom.ostC == 1)
                {
                    xrom.GenC[xrom.GenC.Count - 1]++;
                    xrom.ostC = 0;
                }
                else
                if (xrom.ostC == 0)
                {
                    buff = 0;
                }
                else
                {
                    xrom.ostC -= buff = rand.Next(2, xrom.ostC);
                }
                xrom.GenC.Add(buff);
            }

            if (xrom.ostC == 1)
            {
                xrom.GenC[xrom.GenC.Count - 1]++;
                xrom.ostC = 0;
            }
            else
            {
                xrom.GenC.Add(xrom.ostC);
            }

            return(xrom);
        }