internal void informarResultados(GaEventArgs e, long cantIteracionesMax)
        {
            Chromosome cromo;
            informarNuevaLinea(Color.Indigo, string.Format("Cantidad de individuos: {0}, Cantidad de iteraciones Máxima: {1}", e.Population.PopulationSize, cantIteracionesMax));
            informarNuevaLinea(Color.Brown, string.Format("El mayor valor de ajuste alcanzado por la población final: {0}", e.Population.MaximumFitness));
            informarNuevaLinea(Color.Red, string.Format("Número de iteración: {0}, Cantidad de cromosomas evaluados:", e.Generation, e.Evaluations));
            informarNuevaLinea(Color.BlueViolet, "Mejor solución de la población final:");
            cromo = e.Population.Solutions.Find(x => x.Fitness == e.Population.MaximumFitness);
            informarCromosoma(cromo);

            informarNuevaLinea(Color.BlueViolet, "Mejor solución de la corrida:");
            if (mejorIteracion != 0)
            {
                informarNuevaLinea(Color.Red, string.Format("Número de iteración: {0}, Cantidad de cromosomas evaluados: {1}", mejorIteracion, mejorGeneracion));
                informarCromosoma(mejorSolucion);
            }
            else informarNuevaLinea(Color.HotPink, "No hubo una mejor solucion durante la corrida");

            informarNuevaLinea(Color.BlueViolet, "Población de la solución:");

            foreach (Chromosome cromosoma in e.Population.Solutions)
            {
                informarCromosoma(cromosoma);
            }
        }
 public void ShowChart(GaEventArgs e)
 {
     chart.Show();
     var maxIndividualChromosome = e.Population.GetTop(1).First();
     var maxIndividual = Acertijo.Instance.CrearModelos(maxIndividualChromosome);
     resultsText.Text = "Generaciones: " + e.Generation + "\n" +
         "Población final: " + "\n" +
         "Tamaño: " + e.Population.PopulationSize + " individuos" + "\n" +
         "Mejor individuo: " + "\n"+
         "Mejor individuo Fitness: " + e.Population.MaximumFitness.ToString() + "\n";
     foreach (var persona in maxIndividual)
     {
         resultsText.Text += "Nombre: " + persona.Name + ", Nacionalidad: " + persona.Nationality + ", Vehículo: " + persona.Vehicle + ", Gesto: " + persona.MouthAction + "\n";
     }
 }
Ejemplo n.º 3
0
        private void Ga_OnGenerationComplete(object sender, GaEventArgs e)
        {
            var fittest = e.Population.GetTop(1)[0];
            for (int i = 0; i < fittest.Genes.Count; i++)
            {


                StringBuilder sb = new StringBuilder();
                int stock = stocks[i];
                int[] solitems = (int[])fittest.Genes[i].ObjectValue;
                int sum = solitems.Sum();

                Debug.WriteLine(string.Format("Stock {0} - Length {1} with {2}", i, stock, string.Join(",", solitems)));
            }
        }
 private void OnGenerationComplete(GaEventArgs e)
 {
     progressBar.Value = (int) (Decimal.Divide(e.Generation, AGHelper.cantidadDeIteraciones) * 100);
     currentResultsTab.AddPoint(e.Generation, e.Population.MaximumFitness);
     currentResultsTab.ShowChart(e);
 }
Ejemplo n.º 5
0
 private void Ga_OnGenerationComplete(object sender, GaEventArgs e)
 {
     
 }
Ejemplo n.º 6
0
        private void Ga_OnRunComplete(object sender, GaEventArgs e)
        {
            var fittest = e.Population.GetTop(1)[0];
            Debug.WriteLine("Fittest chromosome or best solution");
            DebugChromosome(fittest);
            int totCut=0,totUncut=0, totWaste = 0, totStock = 0,totToCut=0;
            foreach (var gene in fittest.Genes)
            {
                var cutplan = (gene.ObjectValue as CutPlan);
                totWaste += cutplan.Waste==cutplan.StockLength?0:cutplan.Waste;
                totStock += cutplan.Waste == cutplan.StockLength ? 0 : cutplan.StockLength;
                totCut += cutplan.CutLength;
                totUncut += cutplan.Waste == cutplan.StockLength ? cutplan.StockLength : 0;
            }
            items.ForEach(item => totToCut += item.TotalLength);
            Debug.WriteLine("Total To Cut:" + totToCut);
            Debug.WriteLine("Total Cut:" + totCut);
            Debug.WriteLine("Total Waste:" + totWaste);
            Debug.WriteLine("Total Stock:" + totStock);
            Debug.WriteLine(string.Format("Percentage Waste {0:P2} ", (totWaste*1.0 / totStock)));
            Debug.WriteLine("Uncut Stock:" + totUncut);

            if (totToCut > totCut)
            {
                Debug.WriteLine("No stock to cut all need");
                Debug.WriteLine(totToCut - totCut + " rest tot cut");
            }
            /* for (int i = 0; i < fittest.Genes.Count; i++)
             {


                 StringBuilder sb = new StringBuilder();
                 int stock = stocks[i];
                 int[] solitems = (int[])fittest.Genes[i].ObjectValue;
                 int sum = solitems.Sum();

                 Debug.WriteLine(string.Format("Stock {0} - Length {1} with {2}", i, stock, string.Join(",", solitems)));
             }*/
        }
Ejemplo n.º 7
0
 static void ga_OnRunComplete(object sender, GaEventArgs e)
 {
     var fittest = e.Population.GetTop(1)[0];
     foreach (var gene in fittest.Genes)
     {
         Log.Trace(System.Convert.ToString((int) gene.RealValue));
     }
 }
Ejemplo n.º 8
0
 private static void ga_OnGenerationComplete(object sender, GaEventArgs e)
 {
     var fittest = e.Population.GetTop(1)[0];
     var sharpe = RunAlgorithm(fittest);
     Log.Trace("Generation: {0}, Fitness: {1},Distance: {2}", e.Generation, fittest.Fitness, sharpe);
 }
Ejemplo n.º 9
0
        // Callback for when a generation completes its iteration.
        private static void ga_OnGenerationComplete(object sender, GaEventArgs e)
        {
            // We print in the console the current results of the algorithm for every 100 generations
            // when not in calibration mode. When calibration, we print only for the last generation.
            if ((!IS_CALIBRATION && e.Generation % 100 == 0) || e.Generation == NUMBER_OF_GENERATIONS)
            {
                var fittest = getFittestChromosome(e.Population);
                var distanceToTravel = 0.0;

                if (!FITNESS_CONSIDERS_PARTITIONS)
                {
                    distanceToTravel = CalculateDistance(fittest);
                }
                else
                {
                    var greedy_mTSP =
                        new GreedyAlgorithm(Utils.fittestToCitiesList(CITIES, fittest), DEPOT, NUMBER_OF_DRONES);
                    distanceToTravel = greedy_mTSP.solve().Item1;
                }

                Console.WriteLine("Generation: {0}, Fitness: {1}, Distance: {2}", e.Generation, fittest.Fitness, distanceToTravel);
            }
        }
 private void ga_OnGenerationComplete(object sender, GaEventArgs e)
 {
     var fittest = e.Population.GetTop(1)[0];
     asignarMejorPoblacion(e);
     if (OnGenerationCompleteCallback != null)
     {
         OnGenerationCompleteCallback(e);
     }
 }
 private void asignarMejorPoblacion(GaEventArgs e)
 {
     Chromosome cromo = e.Population.Solutions.Find(x => x.Fitness == e.Population.MaximumFitness);
     if (cromo.Fitness > mejorFitness)
     {
         mejorFitness = cromo.Fitness;
         logger.asignarMejorSolucion(cromo, e.Generation, e.Evaluations);
     }
 }
Ejemplo n.º 12
0
 private void ga_OnGenerationComplete(object sender, GaEventArgs e)
 {
     var chromosome = e.Population.GetTop(1)[0];
     List<int> tmp = GetUsableValues(chromosome.ToBinaryString());
     string output = String.Format("inhibitorKills {0}\t towerKills {1}\t firstTower {2}\t firstBlood {3}\t firstBaron {4}\t firstInhibitor {5}\t firstDragon {6}\t baronKills {7}\t dragonKills {8}",
                                     tmp[0] / 250.0, tmp[1] / 250.0, tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7] / 250.0, tmp[8] / 250.0);
     Console.WriteLine(output + Environment.NewLine + chromosome.Fitness + Environment.NewLine);
 }
Ejemplo n.º 13
0
 static void ga_OnRunComplete(object sender, GaEventArgs e)
 {
     var fittest = e.Population.GetTop(1)[0];
     foreach (var gene in fittest.Genes)
     {
         Console.WriteLine((int)gene.RealValue);
     }
 }
Ejemplo n.º 14
0
 static void ga_OnRunComplete(object sender, GaEventArgs e)
 {
     var fittest = e.Population.GetTop(1)[0];
     foreach (var gene in fittest.Genes)
     {
         ConfigVars v = (ConfigVars)gene.ObjectValue;
         foreach(KeyValuePair<string,object> kvp in v.vars)
             Console.WriteLine("Variable {0}:, value {1}",kvp.Key,kvp.Value.ToString());
     }
 }
Ejemplo n.º 15
0
        static void ga_OnRunComplete(object sender, GaEventArgs e)
        {
            var fittest = getFittestChromosome(e.Population);

            // Call the algorithm to generate the mTSP solution.
            var greedy_mTSP = new GreedyAlgorithm(Utils.fittestToCitiesList(CITIES, fittest), DEPOT, NUMBER_OF_DRONES);
            solution = greedy_mTSP.solve().Item1;
            partitionPoints = greedy_mTSP.solve().Item2;
            timeElapsed = STOPWATCH.ElapsedMilliseconds;
            fittestChromosome = fittest;

            Console.WriteLine("Final solution (MinMax cost): {0}", solution);
            Console.WriteLine("Time elapsed: {0} ms", STOPWATCH.ElapsedMilliseconds);
        }
 private void OnRunComplete(GaEventArgs e)
 {
     currentResultsTab.ShowChart(e);
     progressBar.Value = 0;
     groupBox1.Enabled = true;
     Iniciar.Enabled = true;
 }
Ejemplo n.º 17
0
        private void Ga_OnRunComplete(object sender, GaEventArgs e)
        {
#if DEBUG
            Debug.WriteLine("Run Complete ...");
#endif
            var args = new SolverEventArgs(e.Population, e.Generation, e.Evaluations, Beams);

            OnSolved(this, args);
        }
 void ga_OnRunComplete(object sender, GaEventArgs e)
 {
     reloj.Stop();
     if (OnRunCompleteCallback != null)
     {
         OnRunCompleteCallback(e);
     }
 }