コード例 #1
0
ファイル: BeesAlgorithm.cs プロジェクト: Maksym7355608/DO
        public (List <int>, float) GetTheBestBee()
        {
            var        best     = TheBestScouts.First(y => CalculateCF(y) == TheBestScouts.Max(x => CalculateCF(x)));
            List <int> cf_names = new List <int>();

            for (int i = 0; i < best.Count; i++)
            {
                if (best[i] == 1)
                {
                    cf_names.Add(i);
                }
            }

            var cf = CalculateCF(best);

            return(cf_names, cf);
        }
コード例 #2
0
ファイル: BeesAlgorithm.cs プロジェクト: Maksym7355608/DO
        public void RunForagingBees()
        {
            ConcreteForaging = new List <int>();
            Grouping         = new Dictionary <List <int>, List <List <int> > >();
            var cfs     = TheBestScouts.Select(x => CalculateCF(x)).ToList();
            var sum_cfs = TheBestScouts.Sum(x => CalculateCF(x));

            for (int i = 0; i < TheBestScouts.Count; i++)
            {
                ConcreteForaging.Add(Convert.ToInt32(cfs[i] / sum_cfs * ForagingCount));
            }

            List <List <int> > best = new List <List <int> >();

            for (int i = 0; i < ConcreteForaging.Count; i++)
            {
                for (int j = 0; j < ConcreteForaging[i]; j++)
                {
                    best.Add(CreateForaging(TheBestScouts[i]));
                }
                Grouping.Add(TheBestScouts[i], best);
                best.Clear();
            }
        }