Exemplo n.º 1
0
        private void GatherData(IList <GeneticAlgorithmAgent> agents)
        {
            DataCollector.AddDataPoint(DataCollector.SetsNames.MinFitness, agents.Min(agent => agent.Fitness));
            DataCollector.AddDataPoint(DataCollector.SetsNames.MaxFitness, agents.Max(agent => agent.Fitness));
            DataCollector.AddDataPoint(DataCollector.SetsNames.AvgFitness, agents.Average(agent => agent.Fitness));

            IDictionary <string, int> topologyTrends = new Dictionary <string, int>();

            foreach (var network in agents.Select(agent => agent.Network))
            {
                string topologyIdentifier = network.GetTopologyIdentifier();
                if (!topologyTrends.ContainsKey(topologyIdentifier))
                {
                    topologyTrends.Add(topologyIdentifier, 1);
                }
                else
                {
                    topologyTrends[topologyIdentifier]++;
                }
            }

            var topologyTrendsStringBuilder = new StringBuilder();

            foreach (var kvp in topologyTrends)
            {
                topologyTrendsStringBuilder.Append($"{kvp.Key}:{kvp.Value},");
            }

            DataCollector.AddDataPoint(DataCollector.SetsNames.TopologyTrends, topologyTrendsStringBuilder.ToString());
        }