Exemple #1
0
 private void btnConfig_Click(object sender, EventArgs e)
 {
     this.drawingHelper = new DrawingHelper(this.pictureBoxConfig);
     this.telcoSur      = Config.GetBaseConfig();
     CreateUIConfig();
     btnDefaultConfig.Enabled = false;
 }
 public CustomConfig(TelcoSur telcoSur) : base()
 {
     InitializeComponent();
     this.TelcoSur = telcoSur;
     if (TelcoSur != null)
     {
         LoadConfig();
     }
 }
 public GeneticAlgorithm(TelcoSur telcoSur, GeneticAlgorithmParameters parameters)
 {
     this.TelcoSur             = telcoSur;
     this.elitismPercentage    = parameters.ElitismPercentage;
     this.crossoverProbability = parameters.CrossoverProbability;
     this.mutationProbability  = parameters.MutationProbability;
     this.generationExpected   = parameters.GenerationExpected;
     this.Population           = parameters.Population;
     this.ChromosomeMaxLength  = parameters.ChrmosomeMaxLength;
 }
Exemple #4
0
        private void btnCustomConfig_Click(object sender, EventArgs e)
        {
            var frm = new CustomConfig(telcoSur);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                this.telcoSur = frm.TelcoSur;
                CreateUIConfig();
            }
        }
        public static TelcoSur GetBaseConfig()
        {
            TelcoSur telcoSur = new TelcoSur();

            telcoSur.Cities    = BuildBaseCities();
            telcoSur.Catalogue = BuildBaseCatalogue();
            telcoSur.FiberChannelKmsAvailable = 800;
            telcoSur.FiberChannelKmCost       = 1000;
            telcoSur.PenaltyPercent           = 50;
            return(telcoSur);
        }
Exemple #6
0
        private void ShowSolution(TelcoSur telcoSur)
        {
            var selection = telcoSur.Solution.Genes.GroupBy(p => ((City)p.ObjectValue).Name)
                            .Select(g => g.First())
                            .ToList();

            var centralNode = (City)selection.First().ObjectValue;

            drawingHelper.DrawCentralNodel(centralNode);

            var earnings = selection.Sum(z => ((City)z.ObjectValue).CalculateEarnings(telcoSur));
            var distance = 0.0;

            for (int i = 0; i < selection.Count; i++)
            {
                var j = i + 1;

                if (j == selection.Count)
                {
                    j = 0;
                }

                var city      = (City)selection[i].ObjectValue;
                var otherCity = (City)selection[j].ObjectValue;

                distance += city.GetDistanceTo(otherCity);
            }

            if (selection.ToList().Count == 2)
            {
                drawingHelper.DrawRoute((City)selection[0].ObjectValue, (City)selection[1].ObjectValue, "1");
            }

            if (selection.ToList().Count > 2)
            {
                for (int i = 0; i < selection.Count; i++)
                {
                    var j = i + 1;

                    if (j == selection.Count)
                    {
                        drawingHelper.DrawRoute((City)selection[i].ObjectValue, (City)selection[0].ObjectValue, j.ToString());
                        break;
                    }

                    drawingHelper.DrawRoute((City)selection[i].ObjectValue, (City)selection[j].ObjectValue, j.ToString());
                }
            }
            var log = $"Fitness: {telcoSur.Solution.Fitness.ToString("0.######")}, Fiber Channel Km's: {distance.ToString("#.##")} kms, Earnings: $ {earnings.ToString("#.##")}";

            lblSolution.Text = log;
            Logger.Log(log, true);
            Logger.Log("...end.", true);
        }