public void TransferWithRoulette(InstationGenerator tmp, AcoMaster tmr)
        {
            ArrayList trs = new ArrayList();

            foreach (Entity el in elements)
            {
                Entity a = (Entity)el.Clone();
                trs.Add(a);
            }
            tmp.CreateNewInstantion(trs, maintances, true, tmr);
        }
        public void Init(int size, int population, double smoothParam, double evarParam)
        {
            topValue.Clear();
            topValuesTimes.Clear();
            InstationGenerator instanceFirst = new InstationGenerator();

            nonGMO = new ArrayList();
            GMO    = new ArrayList();
            //int iter = 0;
            int bestScore = Int32.MaxValue;

            MyTimer.Start = DateTime.Now;
            TimeSpan span = new TimeSpan(0, 0, 0);

            //TimeSpan endVar = new TimeSpan(0, 0, 45);
            while (1 == 1)
            {
                if ((span = DateTime.Now - MyTimer.Start) > endVar)
                {
                    break;
                }
                populationHandler.Clear();
                for (int i = 0; i < population; i++)
                {
                    instanceFirst = new InstationGenerator
                    {
                        size = size
                    };
                    gen.TransferWithRoulette(instanceFirst, this);
                    if (instanceFirst.getInstantionScore() < bestScore)
                    {
                        bestScore    = instanceFirst.getInstantionScore();
                        instanceBest = null;
                        instanceBest = instanceFirst;
                        string mods = "";
                        if (instanceBest.isModified == true)
                        {
                            GMO.Clear();
                            mods = "GMO!";
                            GMO.Add(bestScore);
                        }
                        else
                        {
                            nonGMO.Clear();
                            mods = "NGMO!";
                            nonGMO.Add(bestScore);
                        }
                        Console.WriteLine(bestScore + " " + mods);
                        //instanceFirst.PrintMachines();
                        topValue.Add(bestScore);
                        topValuesTimes.Add(string.Format("{0:ss}", (MyTimer.Start - DateTime.Now)));
                    }

                    //Console.WriteLine(instanceFirst.getInstantionScore());
                    //instanceFirst.PrintMachines();
                    populationHandler.Add(instanceFirst);
                }
                //Console.WriteLine("*BEEP* : " + iter);
                //iter = 0;
                ArrayList topElements = new ArrayList();
                for (int s = 0; s < 5; s++)
                {
                    Random rnd            = new Random();
                    int    rulette        = rnd.Next(0, 10);
                    int    tmpPos         = 0;
                    int    maxValue       = 0;
                    int    positionAtList = 0;
                    if (rulette < 10)
                    {
                        foreach (InstationGenerator instance in populationHandler)
                        {
                            if (instance.getInstantionScore() > maxValue)
                            {
                                maxValue       = instance.getInstantionScore();
                                positionAtList = tmpPos;
                            }
                            tmpPos++;
                        }
                    }
                    else
                    {
                        positionAtList = rnd.Next(0, (populationHandler.Count - 1));
                    }
                    topElements.Add((InstationGenerator)populationHandler[positionAtList]);
                    populationHandler.RemoveAt(positionAtList);
                }
                //evar
                for (int ix = 0; ix < size; ix++)
                {
                    for (int iy = 0; iy < size; iy++)
                    {
                        if (arr[ix, iy] > 0)
                        {
                            if (arr[ix, iy] > 0)
                            {
                                arr[ix, iy] = Evaporate(arr[ix, iy], evarParam);
                            }
                            if (arrx2[ix, iy] > 0)
                            {
                                arrx2[ix, iy] = Evaporate(arrx2[ix, iy], evarParam);
                            }
                        }
                    }
                }
                //grants new values
                //1st machine
                double grants = 1;
                foreach (InstationGenerator instance in topElements)
                {
                    ArrayList tmp = instance.getFirstMachine();
                    int       previous = 0, actual = 0;
                    foreach (Entity element in tmp)
                    {
                        if (element.GetTypeOfEntity() == 0)
                        {
                            previous = actual;
                            actual   = element.GetOperationID();
                            if (previous == actual)
                            {
                                continue;
                            }
                            arr[previous, actual] += grants;
                            arr[previous, actual]  = Smooth(0.1, arr[previous, actual], smoothParam);
                        }
                    }
                    grants = (grants - 0.1);
                }
                //2nd machine
                grants = 1;
                foreach (InstationGenerator instance in topElements)
                {
                    ArrayList tmp = instance.getSecondMachine();
                    int       previous = 0, actual = 0;
                    foreach (Entity element in tmp)
                    {
                        if (element.GetTypeOfEntity() == 0)
                        {
                            previous = actual;
                            actual   = element.GetOperationID();
                            if (previous == actual)
                            {
                                continue;
                            }
                            arrx2[previous, actual] += grants;
                            arrx2[previous, actual]  = Smooth(0.1, arrx2[previous, actual], smoothParam);
                        }
                    }
                    grants = (grants - 0.1);
                }
                // smooth
            }
            //best one
            string mod = "";

            if (instanceBest.isModified == true)
            {
                mod = "GMO!";
            }
            else
            {
                mod = "GMO Free!";
            }
            Console.WriteLine("Best score found: " + instanceBest.getInstantionScore() + " " + mod);
            SaveScores();
            SaveOutput(smoothParam, evarParam);
            //instanceBest.PrintMachines();
        }