Example #1
0
        public override Vec2i Select_Parent_Coordinates(Random randomness_provider, MEL__Algorithm <T> map_elites)
        {
            //int w = map_elites.state.individuals.GetLength(0);
            //int h = map_elites.state.individuals.GetLength(1);

            double[,] parent_fitness_table = map_elites.Q_ST_Fitness_Table();
            double highest_fitness = parent_fitness_table.Max();

            Vec2i best_value_coordinates = MEL_PSM__Help_Methods.Best_Value_Coordinates(
                randomness_provider,
                map_elites.state.individual_exists,
                parent_fitness_table,
                highest_fitness
                );

            return(best_value_coordinates);

            //List<Vec2i> candidates = new List<Vec2i>();

            //for (int x = 0; x < w; x++)
            //{
            //    for (int y = 0; y < h; y++)
            //    {
            //        if (parent_fitness_table[x, y] == highest_fitness)
            //        {
            //            candidates.Add(new Vec2i(x, y));
            //        }
            //    }
            //}

            //return candidates.Random_Item(randomness_provider);
        }
Example #2
0
        public static void Save_Feature_Tables_PNG <T>(
            string this_experiment__output_folder,
            int random_seed,
            int current_iteration,
            MEL__Algorithm <T> map_elites,
            double min_fitness,
            double max_fitness
            )
            where T : MEL__Individual
        {
            // data analysis tables - folder paths
            string individual_exists__png_folder = Path.Combine(
                this_experiment__output_folder, "PNG_0_A_individual_exists");
            string fitness__png_folder = Path.Combine(
                this_experiment__output_folder, "PNG_0_B_fitness");
            string selections_per_location__png_folder = Path.Combine(
                this_experiment__output_folder, "PNG_1_A_selections_per_location");
            string offspring_survivals_per_location__png_folder = Path.Combine(
                this_experiment__output_folder, "PNG_1_B_offspring_survivals_per_location");

            IO_Utilities.CreateFolder(individual_exists__png_folder);
            IO_Utilities.CreateFolder(fitness__png_folder);
            IO_Utilities.CreateFolder(selections_per_location__png_folder);
            IO_Utilities.CreateFolder(offspring_survivals_per_location__png_folder);

            /////////////////////////////////////////////////////////////////////////
            // SAVE PNG FILES...
            ////////////////////////////////////////////////////////////////////////

            Bitmap individual_exists__image =
                map_elites.state.individual_exists.To_HeatMap(
                    Color.FromArgb(255, 255, 255),
                    Color.FromArgb(0, 0, 0)
                    );

            string individual_exists__png__file_path =
                Path.Combine(individual_exists__png_folder,
                             "individual_exists__"
                             + "seed_" + random_seed.ToString()
                             + "__iter_" + current_iteration.ToString()
                             + ".png"
                             );

            individual_exists__image.SaveToDisk(
                individual_exists__png__file_path
                );
            individual_exists__image.Dispose();



            var fitness_table = map_elites.Q_ST_Fitness_Table();

            Bitmap fitness__image =
                fitness_table.To_HeatMap(
                    min_fitness,
                    max_fitness,
                    Color.Red,
                    Color.Green,
                    Color.Magenta
                    );
            string fitness__png__file_path =
                Path.Combine(fitness__png_folder,
                             "fitness__"
                             + "seed_" + random_seed.ToString()
                             + "__iter_" + current_iteration.ToString()
                             + ".png"
                             );

            fitness__image.SaveToDisk(
                fitness__png__file_path
                );
            fitness__image.Dispose();


            Bitmap selections_per_location__image =
                map_elites.state.selections__per__location.To_HeatMap(
                    0,
                    map_elites.state.selections__per__location.Max(),
                    Color.Red,
                    Color.Magenta
                    );
            string selections_per_location__png__file_path =
                Path.Combine(selections_per_location__png_folder,
                             "selections_per_location__"
                             + "seed_" + random_seed.ToString()
                             + "__iter_" + current_iteration.ToString()
                             + ".png"
                             );

            selections_per_location__image.SaveToDisk(
                selections_per_location__png__file_path
                );
            selections_per_location__image.Dispose();


            Bitmap offspring_survivals_per_location__image =
                map_elites.state.offspring_survivals__per__location.To_HeatMap(
                    0,
                    map_elites.state.offspring_survivals__per__location.Max(),
                    Color.Red,
                    Color.Magenta
                    );
            string offspring_survivals_per_location__png__file_path =
                Path.Combine(offspring_survivals_per_location__png_folder,
                             "offspring_survivals_per_location__"
                             + "seed_" + random_seed.ToString()
                             + "__iter_" + current_iteration.ToString()
                             + ".png"
                             );

            offspring_survivals_per_location__image.SaveToDisk(
                offspring_survivals_per_location__png__file_path
                );
            offspring_survivals_per_location__image.Dispose();
        }
Example #3
0
        public static void Save_Feature_Tables_CSV <T>(
            string this_experiment__output_folder,
            int random_seed,
            int current_iteration,
            MEL__Algorithm <T> map_elites
            )
            where T : MEL__Individual
        {
            // data analysis tables - folder paths
            string individual_exists__csv_folder = Path.Combine(
                this_experiment__output_folder, "CSV_0_A_individual_exists");
            string fitness__csv_folder = Path.Combine(
                this_experiment__output_folder, "CSV_0_B_fitness");
            string selections_per_location__csv_folder = Path.Combine(
                this_experiment__output_folder, "CSV_1_A_selections_per_location");
            string offspring_survivals_per_location__csv_folder = Path.Combine(
                this_experiment__output_folder, "CSV_1_B_offspring_survivals_per_location");

            IO_Utilities.CreateFolder(individual_exists__csv_folder);
            IO_Utilities.CreateFolder(fitness__csv_folder);
            IO_Utilities.CreateFolder(selections_per_location__csv_folder);
            IO_Utilities.CreateFolder(offspring_survivals_per_location__csv_folder);

            /////////////////////////////////////////////////////////////////////////
            // SAVE CSV FILES...
            ////////////////////////////////////////////////////////////////////////

            string individual_exists_table__csv__file_path =
                Path.Combine(individual_exists__csv_folder,
                             "individual_exists_table__"
                             + "seed_" + random_seed.ToString()
                             + "__iter_" + current_iteration.ToString()
                             + ".csv"
                             );

            IO_Utilities.Append_To_File(
                individual_exists_table__csv__file_path,
                map_elites.state.individual_exists.To_CSV_0_1()
                );

            string fitness_table__csv__file_path =
                Path.Combine(fitness__csv_folder,
                             "fitness_table__"
                             + "seed_" + random_seed.ToString()
                             + "__iter_" + current_iteration.ToString()
                             + ".csv"
                             );

            IO_Utilities.Append_To_File(
                fitness_table__csv__file_path,
                map_elites.Q_ST_Fitness_Table().To_CSV()
                );


            string selections_per_location__csv__file_path =
                Path.Combine(selections_per_location__csv_folder,
                             "selections_per_location__"
                             + "seed_" + random_seed.ToString()
                             + "__iter_" + current_iteration.ToString()
                             + ".csv"
                             );

            IO_Utilities.Append_To_File(
                selections_per_location__csv__file_path,
                map_elites.state.selections__per__location.To_CSV()
                );

            string offspring_survivals_per_location__csv__file_path =
                Path.Combine(offspring_survivals_per_location__csv_folder,
                             "offspring_survivals_per_location__"
                             + "seed_" + random_seed.ToString()
                             + "__iter_" + current_iteration.ToString()
                             + ".csv"
                             );

            IO_Utilities.Append_To_File(
                offspring_survivals_per_location__csv__file_path,
                map_elites.state.offspring_survivals__per__location.To_CSV()
                );
        }