16 #include "evolutionary_algorithm.h"
92 return(
"LinearRanking");
98 std::ostringstream buffer;
100 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
101 <<
"std::string write_fitness_assignment_method(void) const method.\n"
102 <<
"Unknown fitness assignment method.\n";
104 throw std::logic_error(buffer.str());
131 return(
"RouletteWheel");
137 std::ostringstream buffer;
139 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
140 <<
"std::string write_selection_method(void) const method.\n"
141 <<
"Unknown selection method.\n";
143 throw std::logic_error(buffer.str());
176 return(
"Intermediate");
182 std::ostringstream buffer;
184 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
185 <<
"std::string write_recombination_method(void) const method.\n"
186 <<
"Unknown recombination method.\n";
188 throw std::logic_error(buffer.str());
227 std::ostringstream buffer;
229 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
230 <<
"std::string get_mutation_method_name(void) const method.\n"
231 <<
"Unknown mutation method.\n";
233 throw std::logic_error(buffer.str());
587 if(new_population_size == 0)
613 if(!neural_network_pointer)
615 std::ostringstream buffer;
617 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
618 <<
"void set_population_size(size_t) method.\n"
619 <<
"Neural network pointer is NULL.\n";
621 throw std::logic_error(buffer.str());
628 if(new_population_size < 4)
630 std::ostringstream buffer;
632 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
633 <<
"void set_population_size(size_t) method.\n"
634 <<
"New population size must be equal or greater than 4.\n";
636 throw std::logic_error(buffer.str());
638 else if(new_population_size%2 != 0)
640 std::ostringstream buffer;
642 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
643 <<
"void set_population_size(size_t) method.\n"
644 <<
"New population size is not divisible by 2.\n";
646 throw std::logic_error(buffer.str());
662 fitness.resize(new_population_size);
683 if(new_fitness_assignment_method_name ==
"LinearRanking")
689 std::ostringstream buffer;
691 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
692 <<
"void set_fitness_assignment_method(const std::string&) method.\n"
693 <<
"Unknown fitness assignment method: " << new_fitness_assignment_method_name <<
".\n";
695 throw std::logic_error(buffer.str());
711 if(new_selection_method_name ==
"RouletteWheel")
717 std::ostringstream buffer;
719 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
720 <<
"void set_selection_method(const std::string&) method.\n"
721 <<
"Unknown selection method: " << new_selection_method_name <<
".\n";
723 throw std::logic_error(buffer.str());
740 if(new_recombination_method_name ==
"Line")
744 else if(new_recombination_method_name ==
"Intermediate")
750 std::ostringstream buffer;
752 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
753 <<
"void set_recombination_method(const std::string&) method.\n"
754 <<
"Unknown recombination method: " << new_recombination_method_name <<
".\n";
756 throw std::logic_error(buffer.str());
773 if(new_mutation_method_name ==
"Normal")
777 else if(new_mutation_method_name ==
"Uniform")
783 std::ostringstream buffer;
785 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
786 <<
"void set_mutation_method(const std::string&) method.\n"
787 <<
"Unknown mutationg method: " << new_mutation_method_name <<
".\n";
789 throw std::logic_error(buffer.str());
808 if(population_size == 0 && new_population.
empty())
821 std::ostringstream buffer;
823 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
824 <<
"void set_population(const Matrix<double>&) method.\n"
825 <<
"New population size is not equal to population size.\n";
827 throw std::logic_error(buffer.str());
831 std::ostringstream buffer;
833 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
834 <<
"void set_population(const Matrix<double>&) method.\n"
835 <<
"New number of parameters is not equal to number of parameters.\n";
837 throw std::logic_error(buffer.str());
862 if(new_performance.size() != population_size)
864 std::ostringstream buffer;
866 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
867 <<
"void set_performance(const Vector<double>&) method.\n"
868 <<
"Size is not equal to population size.\n";
870 throw std::logic_error(buffer.str());
895 if(new_fitness.size() != population_size)
897 std::ostringstream buffer;
899 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
900 <<
"void set_fitness(Vector<double>) method.\n"
901 <<
"Size is not equal to population size.\n";
903 throw std::logic_error(buffer.str());
928 if(new_selection.size() != population_size)
930 std::ostringstream buffer;
932 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
933 <<
"void set_selection(Vector<double>) method.\n"
934 <<
"Size is not equal to population size.\n";
936 throw std::logic_error(buffer.str());
1032 reserve_standard_deviation_performance_history = new_reserve_standard_deviation_performance_history;
1094 if(i >= population_size)
1096 std::ostringstream buffer;
1098 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1099 <<
"Vector<double> get_individual(const size_t&) const method.\n"
1100 <<
"Index must be less than population size.\n";
1102 throw std::logic_error(buffer.str());
1128 const size_t size = individual.size();
1136 if(i >= population_size)
1138 std::ostringstream buffer;
1140 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1141 <<
"set_individual(const size_t&, Vector<double>) method.\n"
1142 <<
"Index must be less than population size.\n";
1144 throw std::logic_error(buffer.str());
1146 else if(size != parameters_number)
1148 std::ostringstream buffer;
1150 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1151 <<
"set_individual(const size_t&, Vector<double>) method.\n"
1152 <<
"Size must be equal to number of parameters.\n";
1154 throw std::logic_error(buffer.str());
1187 if(new_warning_parameters_norm < 0.0)
1189 std::ostringstream buffer;
1191 buffer <<
"OpenNN Exception: TrainingAlgorithm class.\n"
1192 <<
"void set_warning_parameters_norm(const double&) method.\n"
1193 <<
"Warning parameters norm must be equal or greater than 0.\n";
1195 throw std::logic_error(buffer.str());
1218 if(new_error_parameters_norm < 0.0)
1220 std::ostringstream buffer;
1222 buffer <<
"OpenNN Exception: TrainingAlgorithm class.\n"
1223 <<
"void set_error_parameters_norm(const double&) method.\n"
1224 <<
"Error parameters norm must be equal or greater than 0.\n";
1226 throw std::logic_error(buffer.str());
1271 if(new_maximum_time < 0.0)
1273 std::ostringstream buffer;
1275 buffer <<
"OpenNN Exception: TrainingAlgorithm class.\n"
1276 <<
"void set_maximum_time(const double&) method.\n"
1277 <<
"Maximum time must be equal or greater than 0.\n";
1279 throw std::logic_error(buffer.str());
1326 if(new_display_period <= 0)
1328 std::ostringstream buffer;
1330 buffer <<
"OpenNN Exception: TrainingAlgorithm class.\n"
1331 <<
"void set_display_period(const size_t&) method.\n"
1332 <<
"First training rate must be greater than 0.\n";
1334 throw std::logic_error(buffer.str());
1360 for(
size_t i = 0; i < population_size; i++)
1367 return(population_norm);
1483 if(new_elitism_size > half_population_size)
1506 if(new_selective_pressure <= 0.0)
1508 std::ostringstream buffer;
1510 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1511 <<
"void set_selective_pressure(const double&) method. "
1512 <<
"Selective pressure must be greater than 0.\n";
1514 throw std::logic_error(buffer.str());
1532 if(new_recombination_size < 0.0)
1534 std::ostringstream buffer;
1536 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1537 <<
"void set_recombination_size(const double&) method.\n"
1538 <<
"Recombination size must be equal or greater than 0.\n";
1540 throw std::logic_error(buffer.str());
1560 if(new_mutation_rate < 0.0 || new_mutation_rate > 1.0)
1562 std::ostringstream buffer;
1564 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1565 <<
"void set_mutation_rate(const double&) method.\n"
1566 <<
"Mutation rate must be a value between 0 and 1.\n";
1568 throw std::logic_error(buffer.str());
1588 if(new_mutation_range < 0.0)
1590 std::ostringstream buffer;
1592 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1593 <<
"void set_mutation_range(const double&) method.\n"
1594 <<
"Mutation range must be equal or greater than 0.\n";
1596 throw std::logic_error(buffer.str());
1617 if(new_maximum_generations_number == 0)
1619 std::ostringstream buffer;
1621 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1622 <<
"void set_maximum_generations_number(size_t) method.\n"
1623 <<
"Maximum number of generations must be greater than 0.\n";
1625 throw std::logic_error(buffer.str());
1659 if(new_standard_deviation_performance_goal < 0.0)
1661 std::ostringstream buffer;
1663 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1664 <<
"void set_standard_deviation_performance_goal(const double&) method.\n"
1665 <<
"Standard deviation of performance goal must be equal or greater than 0.\n";
1667 throw std::logic_error(buffer.str());
1686 fitness_assignment_method = new_fitness_assignment_method;
1712 recombination_method = new_recombination_method;
1783 const size_t minimum_size = minimum.size();
1784 const size_t maximum_size = maximum.size();
1786 if(minimum_size != parameters_number || maximum_size != parameters_number)
1788 std::ostringstream buffer;
1790 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1791 <<
"void randomize_population_uniform(Vector<double>, Vector<double>).\n"
1792 <<
"Minimum value and maximum value sizes must be equal to number of parameters.\n";
1794 throw std::logic_error(buffer.str());
1803 for(
size_t i = 0; i < population_size; i++)
1856 const size_t mean_size = mean.size();
1857 const size_t standard_deviation_size = standard_deviation.size();
1859 if(mean_size != parameters_number || standard_deviation_size != parameters_number)
1861 std::ostringstream buffer;
1863 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1864 <<
"void randomize_population_normal(Vector<double>, Vector<double>).\n"
1865 <<
"Mean and standard deviation sizes must be equal to number of parameters.\n";
1867 throw std::logic_error(buffer.str());
1876 for(
size_t i = 0; i < population_size; i++)
1902 std::ostringstream buffer;
1904 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1905 <<
"void perform_fitness_assignment(void).\n"
1906 <<
"Unknown fitness assignment method.\n";
1908 throw std::logic_error(buffer.str());
1931 std::ostringstream buffer;
1933 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1934 <<
"void perform_selection(void).\n"
1935 <<
"Unknown selection method.\n";
1937 throw std::logic_error(buffer.str());
1950 if(selected_individuals_number != population_size/2)
1952 std::ostringstream buffer;
1954 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1955 <<
"void perform_selection(void).\n"
1956 <<
"Number of selected individuals is not equal to half of the population size.\n";
1958 throw std::logic_error(buffer.str());
1987 std::ostringstream buffer;
1989 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
1990 <<
"void perform_recombination(void).\n"
1991 <<
"Unknown recombination method.\n";
1993 throw std::logic_error(buffer.str());
2022 std::ostringstream buffer;
2024 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2025 <<
"void perform_mutationg(void).\n"
2026 <<
"Unknown mutation method.\n";
2028 throw std::logic_error(buffer.str());
2072 std::ostringstream buffer;
2074 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2075 <<
"void evaluate_population(void).\n"
2076 <<
"Performance functional pointer is NULL.\n";
2078 throw std::logic_error(buffer.str());
2091 if(!neural_network_pointer)
2093 std::ostringstream buffer;
2095 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2096 <<
"void evaluate_population(void).\n"
2097 <<
"Neural network pointer is NULL.\n";
2099 throw std::logic_error(buffer.str());
2112 for(
size_t i = 0; i < population_size; i++)
2120 std::ostringstream buffer;
2122 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2123 <<
"void evaluate_population(void) method.\n"
2124 <<
"Performance of individual " << i <<
" is not a real number.\n";
2126 throw std::logic_error(buffer.str());
2152 for(
size_t i = 0; i < population_size; i++)
2177 const size_t elite_individual_index = elite_individuals[i];
2179 selection[elite_individual_index] =
true;
2182 const size_t selection_target = population_size/2 -
elitism_size;
2184 if(selection_target <= 0)
2197 size_t selection_count = 0;
2201 while(selection_count != selection_target)
2205 pointer = calculate_random_uniform(0.0, fitness_sum);
2209 if(pointer < cumulative_fitness[0])
2219 for(
size_t i = 1; i < population_size; i++)
2221 if(pointer < cumulative_fitness[i] && pointer >= cumulative_fitness[i-1])
2239 std::ostringstream buffer;
2241 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2242 <<
"void perform_roulette_wheel_selection(void) method.\n"
2243 <<
"Selection count (" <<
selection.
count_occurrences(
true) <<
") is not equal to half population size (" << population_size/2 <<
").\n";
2245 throw std::logic_error(buffer.str());
2267 std::ostringstream buffer;
2269 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2270 <<
"void perform_intermediate_recombination(void) method.\n"
2271 <<
"Selection count (" <<
selection.
count_occurrences(
true) <<
") is not equal to half population size (" << population_size/2 <<
").\n";
2273 throw std::logic_error(buffer.str());
2282 Matrix<double> new_population(population_size, parameters_number);
2293 size_t new_population_size_count = 0;
2295 bool parent_2_candidate;
2297 size_t parent_2_candidate_index;
2299 double scaling_factor;
2301 for(
size_t i = 0; i < population_size; i++)
2311 for(
size_t j = 0; j < 2; j++)
2315 parent_2_candidate =
false;
2320 parent_2_candidate_index = (size_t)calculate_random_uniform(0.0, (
double)population_size);
2324 if(
selection[parent_2_candidate_index] && parent_2_candidate_index != i)
2326 parent_2_candidate =
true;
2328 recombination(new_population_size_count,0) = i;
2330 recombination(new_population_size_count,1) = parent_2_candidate_index;
2336 for(
size_t j = 0; j < parameters_number; j++)
2344 offspring[j] = scaling_factor*parent_1[j] + (1.0 - scaling_factor)*parent_2[j];
2349 new_population.
set_row(new_population_size_count, offspring);
2351 new_population_size_count++;
2353 }
while(parent_2_candidate !=
true);
2362 if(new_population_size_count != population_size)
2364 std::ostringstream buffer;
2366 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2367 <<
"void perform_intermediate_recombination(void) method.\n"
2368 <<
"Count new population size is not equal to population size.\n";
2370 throw std::logic_error(buffer.str());
2395 std::ostringstream buffer;
2397 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2398 <<
"void perform_line_recombination(void) method.\n"
2399 <<
"Selection count (" <<
selection.
count_occurrences(
true) <<
") is not equal to half population size (" << population_size/2 <<
").\n";
2401 throw std::logic_error(buffer.str());
2410 Matrix<double> new_population(population_size, parameters_number);
2423 size_t new_population_size_count = 0;
2425 bool parent_2_candidate;
2427 size_t parent_2_candidate_index;
2429 double scaling_factor;
2431 for(
size_t i = 0; i < population_size; i++)
2441 for(
size_t j = 0; j < 2; j++)
2445 parent_2_candidate =
false;
2451 parent_2_candidate_index = (size_t)calculate_random_uniform(0.0, (
double)population_size);
2455 if(
selection[parent_2_candidate_index] && parent_2_candidate_index != i)
2457 parent_2_candidate =
true;
2459 recombination(new_population_size_count,0) = i;
2460 recombination(new_population_size_count,1) = parent_2_candidate_index;
2472 parent_1_term = parent_1*scaling_factor;
2473 parent_2_term = parent_2*(1.0 - scaling_factor);
2475 offspring = parent_1_term + parent_2_term;
2479 new_population.
set_row(new_population_size_count, offspring);
2481 new_population_size_count++;
2483 }
while(!parent_2_candidate);
2490 if(new_population_size_count != population_size)
2492 std::ostringstream buffer;
2494 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2495 <<
"void perform_line_recombination(void) method.\n"
2496 <<
"Count new population size is not equal to population size.\n";
2498 throw std::logic_error(buffer.str());
2524 for(
size_t i = 0; i < population_size; i++)
2528 for(
size_t j = 0; j < parameters_number; j++)
2532 pointer = calculate_random_uniform(0.0, 1.0);
2562 for(
size_t i = 0; i < population_size; i++)
2566 for(
size_t j = 0; j < parameters_number; j++)
2570 pointer = calculate_random_uniform(0.0, 1.0);
2589 std::ostringstream buffer;
2597 buffer <<
"% Population history:\n"
2608 buffer <<
"% Best individual history:\n"
2617 buffer <<
"% Mean norm history:\n"
2625 buffer <<
"% Standard deviation norm history:\n"
2633 buffer <<
"% Best norm history:\n"
2641 buffer <<
"% performance history:\n"
2649 buffer <<
"% Mean performance history:\n"
2657 buffer <<
"% Standard deviation performance history:\n"
2665 buffer <<
"% Best performance history:\n"
2673 buffer <<
"% Generalization performance history:\n"
2681 buffer <<
"% Elapsed time history:\n"
2685 return(buffer.str());
2700 if(evolutionary_algorithm_pointer->get_reserve_population_history())
2702 population_history.resize(new_size);
2705 if(evolutionary_algorithm_pointer->get_reserve_best_individual_history())
2707 best_individual_history.resize(new_size);
2710 if(evolutionary_algorithm_pointer->get_reserve_mean_norm_history())
2712 mean_norm_history.resize(new_size);
2715 if(evolutionary_algorithm_pointer->get_reserve_standard_deviation_norm_history())
2717 standard_deviation_norm_history.resize(new_size);
2720 if(evolutionary_algorithm_pointer->get_reserve_best_norm_history())
2722 best_norm_history.resize(new_size);
2725 if(evolutionary_algorithm_pointer->get_reserve_mean_performance_history())
2727 mean_performance_history.resize(new_size);
2730 if(evolutionary_algorithm_pointer->get_reserve_standard_deviation_performance_history())
2732 standard_deviation_performance_history.resize(new_size);
2735 if(evolutionary_algorithm_pointer->get_reserve_best_performance_history())
2737 best_performance_history.resize(new_size);
2740 if(evolutionary_algorithm_pointer->get_reserve_generalization_performance_history())
2742 generalization_performance_history.resize(new_size);
2745 if(evolutionary_algorithm_pointer->get_reserve_elapsed_time_history())
2747 elapsed_time_history.resize(new_size);
2756 std::ostringstream buffer;
2763 names.push_back(
"Final mean norm");
2766 buffer << std::setprecision(precision) << final_mean_norm;
2768 values.push_back(buffer.str());
2772 names.push_back(
"Final standard deviation norm");
2775 buffer << std::setprecision(precision) << final_standard_deviation_norm;
2777 values.push_back(buffer.str());
2781 names.push_back(
"Final best norm");
2784 buffer << std::setprecision(precision) << final_best_norm;
2786 values.push_back(buffer.str());
2790 names.push_back(
"Final mean performance");
2793 buffer << std::setprecision(precision) << final_mean_performance;
2795 values.push_back(buffer.str());
2799 names.push_back(
"Final standard deviation performance");
2802 buffer << std::setprecision(precision) << final_standard_deviation_performance;
2804 values.push_back(buffer.str());
2808 names.push_back(
"Final best performance");
2811 buffer << std::setprecision(precision) << final_best_performance;
2813 values.push_back(buffer.str());
2821 names.push_back(
"Final generalization performance");
2824 buffer << std::setprecision(precision) << final_generalization_performance;
2826 values.push_back(buffer.str());
2831 names.push_back(
"Generations number");
2834 buffer << std::setprecision(precision) << generations_number;
2836 values.push_back(buffer.str());
2840 names.push_back(
"Elapsed time");
2843 buffer << std::setprecision(precision) << elapsed_time;
2845 values.push_back(buffer.str());
2849 const size_t rows_number = names.size();
2850 const size_t columns_number = 2;
2857 return(final_results);
2874 if(population_size == 0)
2876 std::ostringstream buffer;
2878 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
2879 <<
"EvolutionaryAlgorithmResults* perform_training(void) method.\n"
2880 <<
"Population size is zero.\n";
2882 throw std::logic_error(buffer.str());
2889 std::cout <<
"Training with the evolutionary algorithm...\n";
2896 size_t generalization_failures = 0;
2898 time_t beginning_time, current_time;
2899 time(&beginning_time);
2900 double elapsed_time;
2902 bool stop_training =
false;
2909 double standard_deviation_norm;
2912 size_t best_individual_index;
2913 double best_norm = 0.0;
2915 double best_performance_ever = 1.0e99;
2917 double best_generation_performance = 1.0e99;
2919 double generalization_performance = 0.0;
2963 if(best_generation_performance < best_performance_ever)
2973 best_performance_ever = best_generation_performance;
3028 time(¤t_time);
3029 elapsed_time = difftime(current_time, beginning_time);
3091 std::cout <<
"Generation " << generation <<
": Performance goal reached.\n"
3095 stop_training =
true;
3102 std::cout <<
"Generation " << generation <<
": Mean performance goal reached.\n";
3105 stop_training =
true;
3112 std::cout <<
"Generation " << generation <<
": Standard deviation of performance goal reached.\n";
3115 stop_training =
true;
3122 std::cout <<
"Generation " << generation <<
": Maximum generalization performance decreases reached.\n";
3123 std::cout <<
"Generalization performance decreases: "<< generalization_failures << std::endl;
3126 stop_training =
true;
3133 std::cout <<
"Generation " << generation <<
": Maximum training time reached.\n";
3136 stop_training =
true;
3143 std::cout <<
"Generation " << generation <<
": Maximum number of generations reached.\n";
3146 stop_training =
true;
3149 if(generation != 0 && generation %
save_period == 0)
3158 std::cout <<
"Mean norm: " << mean_norm <<
"\n"
3159 <<
"Standard deviation of norm: " << standard_deviation_norm <<
"\n"
3160 <<
"Best norm: " << best_norm <<
"\n"
3161 <<
"Mean performance: " << mean_performance <<
"\n"
3162 <<
"Standard deviation of performance: " << standard_deviation_performance <<
"\n"
3163 <<
"Best performance: " << best_performance_ever <<
"\n"
3165 <<
"Elapsed time: " << elapsed_time <<
";\n";
3184 std::cout <<
"Generation " << generation <<
";\n"
3185 <<
"Mean norm: " << mean_norm <<
"\n"
3186 <<
"Standard deviation of norm: " << standard_deviation_norm <<
"\n"
3187 <<
"Best norm: " << best_norm <<
"\n"
3188 <<
"Mean performance: " << mean_performance <<
"\n"
3189 <<
"Standard deviation of performance: " << standard_deviation_performance <<
"\n"
3190 <<
"Best performance: " << best_performance_ever <<
"\n"
3192 <<
"Elapsed time: " << elapsed_time <<
";\n";
3205 return(results_pointer);
3213 return(
"EVOLUTIONARY_ALGORITHM");
3223 std::ostringstream buffer;
3230 labels.push_back(
"Population size");
3235 values.push_back(buffer.str());
3239 labels.push_back(
"Fitness assignment method");
3244 labels.push_back(
"Selection method");
3249 labels.push_back(
"Recombination");
3254 labels.push_back(
"Mutation method");
3259 labels.push_back(
"Elitism size");
3264 values.push_back(buffer.str());
3268 labels.push_back(
"Selective pressure");
3273 values.push_back(buffer.str());
3277 labels.push_back(
"Recombination size");
3282 values.push_back(buffer.str());
3286 labels.push_back(
"Mutation rate");
3291 values.push_back(buffer.str());
3295 labels.push_back(
"Mutation range");
3300 values.push_back(buffer.str());
3304 labels.push_back(
"Best performance goal");
3309 values.push_back(buffer.str());
3313 labels.push_back(
"Maximum generalization failures");
3318 values.push_back(buffer.str());
3322 labels.push_back(
"Maximum generations number");
3327 values.push_back(buffer.str());
3331 labels.push_back(
"Maximum time");
3336 values.push_back(buffer.str());
3340 labels.push_back(
"Reserve generalization performance history");
3345 values.push_back(buffer.str());
3349 labels.push_back(
"Reserve elapsed time history");
3354 values.push_back(buffer.str());
3356 const size_t rows_number = labels.size();
3357 const size_t columns_number = 2;
3364 return(string_matrix);
3415 std::ostringstream buffer;
3417 tinyxml2::XMLDocument* document =
new tinyxml2::XMLDocument;
3421 tinyxml2::XMLElement* root_element = document->NewElement(
"EvolutionaryAlgorithm");
3423 document->InsertFirstChild(root_element);
3425 tinyxml2::XMLElement* element = NULL;
3426 tinyxml2::XMLText* text = NULL;
3430 element = document->NewElement(
"Population");
3431 root_element->LinkEndChild(element);
3435 text = document->NewText(population_string.c_str());
3436 element->LinkEndChild(text);
3440 element = document->NewElement(
"FitnessAssignmentMethod");
3441 root_element->LinkEndChild(element);
3444 element->LinkEndChild(text);
3448 element = document->NewElement(
"SelectionMethod");
3449 root_element->LinkEndChild(element);
3452 element->LinkEndChild(text);
3456 element = document->NewElement(
"RecombinationMethod");
3457 root_element->LinkEndChild(element);
3460 element->LinkEndChild(text);
3464 element = document->NewElement(
"MutationMethod");
3465 root_element->LinkEndChild(element);
3468 element->LinkEndChild(text);
3472 element = document->NewElement(
"ElitismSize");
3473 root_element->LinkEndChild(element);
3478 text = document->NewText(buffer.str().c_str());
3479 element->LinkEndChild(text);
3483 element = document->NewElement(
"SelectivePressure");
3484 root_element->LinkEndChild(element);
3489 text = document->NewText(buffer.str().c_str());
3490 element->LinkEndChild(text);
3494 element = document->NewElement(
"RecombinationSize");
3495 root_element->LinkEndChild(element);
3500 text = document->NewText(buffer.str().c_str());
3501 element->LinkEndChild(text);
3505 element = document->NewElement(
"MutationRate");
3506 root_element->LinkEndChild(element);
3511 text = document->NewText(buffer.str().c_str());
3512 element->LinkEndChild(text);
3516 element = document->NewElement(
"MutationRange");
3517 root_element->LinkEndChild(element);
3522 text = document->NewText(buffer.str().c_str());
3523 element->LinkEndChild(text);
3527 element = document->NewElement(
"MeanPerformanceGoal");
3528 root_element->LinkEndChild(element);
3533 text = document->NewText(buffer.str().c_str());
3534 element->LinkEndChild(text);
3538 element = document->NewElement(
"StandardDeviationPerformanceGoal");
3539 root_element->LinkEndChild(element);
3544 text = document->NewText(buffer.str().c_str());
3545 element->LinkEndChild(text);
3549 element = document->NewElement(
"BestPerformanceGoal");
3550 root_element->LinkEndChild(element);
3555 text = document->NewText(buffer.str().c_str());
3556 element->LinkEndChild(text);
3560 element = document->NewElement(
"MaximumGeneralizationPerformanceDecreases");
3561 root_element->LinkEndChild(element);
3566 text = document->NewText(buffer.str().c_str());
3567 element->LinkEndChild(text);
3571 element = document->NewElement(
"MaximumGenerationsNumber");
3572 root_element->LinkEndChild(element);
3577 text = document->NewText(buffer.str().c_str());
3578 element->LinkEndChild(text);
3582 element = document->NewElement(
"MaximumTime");
3583 root_element->LinkEndChild(element);
3588 text = document->NewText(buffer.str().c_str());
3589 element->LinkEndChild(text);
3593 element = document->NewElement(
"ReserveMeanNormHistory");
3594 root_element->LinkEndChild(element);
3599 text = document->NewText(buffer.str().c_str());
3600 element->LinkEndChild(text);
3604 element = document->NewElement(
"ReserveStandardDeviationNormHistory");
3605 root_element->LinkEndChild(element);
3610 text = document->NewText(buffer.str().c_str());
3611 element->LinkEndChild(text);
3615 element = document->NewElement(
"ReserveBestNormHistory");
3616 root_element->LinkEndChild(element);
3621 text = document->NewText(buffer.str().c_str());
3622 element->LinkEndChild(text);
3626 element = document->NewElement(
"ReserveMeanPerformanceHistory");
3627 root_element->LinkEndChild(element);
3632 text = document->NewText(buffer.str().c_str());
3633 element->LinkEndChild(text);
3637 element = document->NewElement(
"ReserveStandardDeviationPerformanceHistory");
3638 root_element->LinkEndChild(element);
3643 text = document->NewText(buffer.str().c_str());
3644 element->LinkEndChild(text);
3648 element = document->NewElement(
"ReserveBestPerformanceHistory");
3649 root_element->LinkEndChild(element);
3654 text = document->NewText(buffer.str().c_str());
3655 element->LinkEndChild(text);
3659 element = document->NewElement(
"ReserveGeneralizationPerformanceHistory");
3660 root_element->LinkEndChild(element);
3665 text = document->NewText(buffer.str().c_str());
3666 element->LinkEndChild(text);
3680 const tinyxml2::XMLElement* root_element = document.FirstChildElement(
"EvolutionaryAlgorithm");
3684 std::ostringstream buffer;
3686 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
3687 <<
"void from_XML(const tinyxml2::XMLDocument&) method.\n"
3688 <<
"Evolutionary algorithm element is NULL.\n";
3690 throw std::logic_error(buffer.str());
3697 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"Population");
3701 const char* population_text = element->GetText();
3706 new_population.
parse(population_text);
3720 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"FitnessAssignmentMethod");
3724 const std::string new_fitness_assignment_method = element->GetText();
3730 catch(
const std::logic_error& e)
3732 std::cout << e.what() << std::endl;
3739 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"SelectionMethod");
3743 const std::string new_selection_method = element->GetText();
3749 catch(
const std::logic_error& e)
3751 std::cout << e.what() << std::endl;
3758 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"RecombinationMethod");
3762 const std::string new_recombination_method = element->GetText();
3768 catch(
const std::logic_error& e)
3770 std::cout << e.what() << std::endl;
3777 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"MutationMethod");
3781 const std::string new_mutation_method = element->GetText();
3787 catch(
const std::logic_error& e)
3789 std::cout << e.what() << std::endl;
3796 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"ElitismSize");
3800 const size_t new_elitism_size = atoi(element->GetText());
3806 catch(
const std::logic_error& e)
3808 std::cout << e.what() << std::endl;
3815 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"SelectivePressure");
3819 const double new_selective_pressure = atof(element->GetText());
3825 catch(
const std::logic_error& e)
3827 std::cout << e.what() << std::endl;
3834 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"RecombinationSize");
3838 const double new_recombination_size = atof(element->GetText());
3844 catch(
const std::logic_error& e)
3846 std::cout << e.what() << std::endl;
3853 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"MutationRate");
3857 const double new_mutation_rate = atof(element->GetText());
3863 catch(
const std::logic_error& e)
3865 std::cout << e.what() << std::endl;
3872 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"MutationRange");
3876 const double new_mutation_range = atof(element->GetText());
3882 catch(
const std::logic_error& e)
3884 std::cout << e.what() << std::endl;
3891 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"MeanPerformanceGoal");
3895 const double new_mean_performance_goal = atof(element->GetText());
3901 catch(
const std::logic_error& e)
3903 std::cout << e.what() << std::endl;
3910 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"StandardDeviationPerformanceGoal");
3914 const double new_standard_deviation_performance_goal = atof(element->GetText());
3920 catch(
const std::logic_error& e)
3922 std::cout << e.what() << std::endl;
3929 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"BestPerformanceGoal");
3933 const double new_best_performance_goal = atof(element->GetText());
3939 catch(
const std::logic_error& e)
3941 std::cout << e.what() << std::endl;
3948 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"MaximumGeneralizationPerformanceDecreases");
3952 const size_t new_maximum_generalization_performance_decreases = atoi(element->GetText());
3958 catch(
const std::logic_error& e)
3960 std::cout << e.what() << std::endl;
3967 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"MaximumGenerationsNumber");
3971 const size_t new_maximum_generations_number = atoi(element->GetText());
3977 catch(
const std::logic_error& e)
3979 std::cout << e.what() << std::endl;
3986 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"MaximumTime");
3990 const double new_maximum_time = atof(element->GetText());
3996 catch(
const std::logic_error& e)
3998 std::cout << e.what() << std::endl;
4005 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"ReserveMeanNormHistory");
4009 const bool new_mean_norm_history = (atoi(element->GetText()) != 0);
4016 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"ReserveStandardDeviationNormHistory");
4020 const bool new_standard_deviation_norm_history = (atoi(element->GetText()) != 0);
4027 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"ReserveBestNormHistory");
4031 const bool new_best_norm_history = (atoi(element->GetText()) != 0);
4038 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"ReserveMeanPerformanceHistory");
4042 const bool new_mean_performance_history = (atoi(element->GetText()) != 0);
4049 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"ReserveStandardDeviationPerformanceHistory");
4053 const bool new_standard_deviation_performance_history = (atoi(element->GetText()) != 0);
4060 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"ReserveBestPerformanceHistory");
4064 const bool new_best_performance_history = (atoi(element->GetText()) != 0);
4071 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"ReserveGeneralizationPerformanceHistory");
4075 const bool new_generalization_performance_history = (atoi(element->GetText()) != 0);
4112 std::ostringstream buffer;
4114 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
4115 <<
"void initialize_random(void) method.\n"
4116 <<
"Unknown recombination method.\n";
4118 throw std::logic_error(buffer.str());
4141 std::ostringstream buffer;
4143 buffer <<
"OpenNN Exception: EvolutionaryAlgorithm class.\n"
4144 <<
"void initialize_random(void) method.\n"
4145 <<
"Unknown mutation method.\n";
4147 throw std::logic_error(buffer.str());
4152 const size_t new_population_size = (size_t)calculate_random_uniform(1.0, 11.0)*4;
Vector< Matrix< double > > population_history
History of the population matrix over the generations.
const SelectionMethod & get_selection_method(void) const
Returns the selection method used for training.
void set_population_size(const size_t &)
void set_reserve_mean_performance_history(const bool &)
double final_best_performance
Performance of the best individual ever.
const double & get_mutation_range(void) const
Returns the mutation range value.
void set_selective_pressure(const double &)
void set_maximum_generations_number(const size_t &)
bool reserve_best_individual_history
void set_reserve_generalization_performance_history(const bool &)
const double & get_mean_performance_goal(void) const
Returns the mean performance value of the population at which training will stop. ...
size_t count_parameters_number(void) const
void randomize_uniform(const double &=-1.0, const double &=1.0)
const double & get_mutation_rate(void) const
Returns the mutation rate value.
void set_selection(const Vector< bool > &)
const size_t & get_maximum_generations_number(void) const
Returns the maximum number of generations to train.
const double & get_best_performance_goal(void) const
Vector< double > calculate_population_norm(void) const
Returns a vector containing the norm of each individual in the population.
const bool & get_reserve_population_history(void) const
Returns true if the population history vector of matrices is to be reserved, and false otherwise...
size_t get_population_size(void) const
Returns the number of individuals in the population.
void set_reserve_all_training_history(const bool &)
const double & get_standard_deviation_performance_goal(void) const
Returns the standard deviation of the performance at which training will stop.
std::string write_training_algorithm_type(void) const
This method writes a string with the type of training algoritm.
void initialize(const T &)
void initialize_population(const double &)
const bool & get_reserve_standard_deviation_norm_history(void) const
void evolve_population(void)
Generates a new population matrix by applying fitness assignment, selection, recombination and mutati...
const double & get_error_parameters_norm(void) const
bool reserve_standard_deviation_norm_history
True if the standard deviation of norm history vector is to be reserved, false otherwise.
size_t maximum_generalization_performance_decreases
tinyxml2::XMLDocument * to_XML(void) const
Vector< double > get_individual(const size_t &) const
void set_reserve_mean_norm_history(const bool &)
const RecombinationMethod & get_recombination_method(void) const
Returns the recombination method used for training.
double selective_pressure
void set_fitness(const Vector< double > &)
void set_standard_deviation_performance_goal(const double &)
void perform_intermediate_recombination(void)
void initialize_random(void)
void set_reserve_elapsed_time_history(const bool &)
const Vector< double > & get_performance(void) const
Returns the actual performance value of all individuals in the population.
void set(void)
Sets the size of a vector to zero.
bool display
Display messages to screen.
Vector< size_t > calculate_maximal_indices(const size_t &) const
double final_mean_performance
Final mean population performance.
void perform_linear_ranking_fitness_assignment(void)
Vector< double > standard_deviation_norm_history
History of the standard deviation of the individuals norm over the generations.
void set_reserve_best_individual_history(const bool &)
void set_performance(const Vector< double > &)
void perform_recombination(void)
Recombinates the selected individuals according to the recombination operator.
void set_selection_method(const SelectionMethod &)
std::string to_string(const std::string &=" ") const
bool reserve_generalization_performance_history
True if the Generalization performance history vector is to be reserved, false otherwise.
double maximum_time
Maximum training time. It is used as a stopping criterion.
double final_standard_deviation_performance
Final standard deviation of the population performance.
const FitnessAssignmentMethod & get_fitness_assignment_method(void) const
Returns the fitness assignment method used for training.
void resize_training_history(const size_t &)
EvolutionaryAlgorithmResults * perform_training(void)
Vector< double > mean_norm_history
History of the mean norm of the individuals over the generations.
EvolutionaryAlgorithm(void)
const bool & get_reserve_best_individual_history(void) const
Returns true if the best individual history vector of vectors is to be reserved, and false otherwise...
bool reserve_elapsed_time_history
True if the elapsed time history vector is to be reserved, false otherwise.
Matrix< std::string > to_string_matrix(void) const
void set_reserve_population_history(const bool &)
Vector< bool > selection
Selected individuals in population.
void evaluate_population(void)
T calculate_minimum(void) const
Returns the smallest element in the vector.
std::string write_mutation_method(void) const
Returns a string with the name of the method used for mutation.
Vector< T > calculate_cumulative(void) const
bool reserve_population_history
Vector< double > mean_performance_history
History of the mean performance of the individuals over the generations.
const double & get_warning_parameters_norm(void) const
void set_population(const Matrix< double > &)
void perform_uniform_mutation(void)
size_t save_period
Number of iterations between the training saving progress.
std::string to_string(void) const
Returns a string representation of the current evolutionary algorithm resutls structure.
double final_mean_norm
Final mean norm of the population.
const MutationMethod & get_mutation_method(void) const
Returns the mutation method used for training.
const size_t & get_columns_number(void) const
Returns the number of columns in the matrix.
Vector< double > best_norm_history
History of the norm of the best individual over the generations.
void perform_mutation(void)
Mutates the population matrix according to the mutation operator.
Vector< Vector< double > > performance_history
History of the population performance over the generations.
void set_mutation_method(const MutationMethod &)
void set_warning_parameters_norm(const double &)
Vector< double > generalization_performance_history
History of the generalization performance of the best individual over each generations.
bool reserve_standard_deviation_performance_history
True if the standard deviation of performance history vector is to be reserved, false otherwise...
double calculate_norm(void) const
Returns the vector norm.
size_t calculate_maximal_index(void) const
Returns the index of the largest element in the vector.
bool reserve_best_norm_history
True if the best norm history vector is to be reserved, false otherwise.
virtual ~EvolutionaryAlgorithm(void)
Destructor.
void set_individual(const size_t &, const Vector< double > &)
const double & get_recombination_size(void) const
Returns the recombination size value.
void set_recombination_size(const double &)
double elapsed_time
Total elapsed time in the training process.
void parse(const std::string &)
std::string write_recombination_method(void) const
Returns a string with the name of the method used for recombination.
std::string neural_network_file_name
Path where the neural network is saved.
Vector< size_t > calculate_greater_rank(void) const
SelectionMethod selection_method
Selection training operators enumeration.
void randomize_population_normal(void)
void set_display_period(const size_t &)
double warning_parameters_norm
Value for the parameters norm at which a warning message is written to the screen.
const double & get_maximum_time(void) const
Returns the maximum training time.
double calculate_standard_deviation(void) const
Returns the standard deviation of the elements in the vector.
const bool & get_reserve_best_performance_history(void) const
Returns true if the best performance history vector is to be reserved, and false otherwise.
double final_best_norm
Final norm of the best individual ever.
void set_column(const size_t &, const Vector< T > &)
void initialize(const T &)
const bool & get_reserve_best_norm_history(void) const
void set_maximum_generalization_performance_decreases(const size_t &)
void set_mutation_range(const double &)
MutationMethod mutation_method
Mutation training operators enumeration.
void set_error_parameters_norm(const double &)
void perform_normal_mutation(void)
double final_standard_deviation_norm
Final standard deviation of the population norm.
const double & get_selective_pressure(void) const
Returns the selective pressure value.
size_t calculate_minimal_index(void) const
Returns the index of the smallest element in the vector.
double calculate_standard_deviation_performance(void) const
Returns the standard deviation value of the individuals performance.
void set_fitness_assignment_method(const FitnessAssignmentMethod &)
bool reserve_best_performance_history
True if the best performance history vector is to be reserved, false otherwise.
Matrix< std::string > write_final_results(const size_t &precision=3) const
Returns a default (empty) string matrix with the final results from training.
void randomize_normal(const double &=0.0, const double &=1.0)
Vector< double > performance
Performance of population.
void set(void)
This method set the numbers of rows and columns of the matrix to zero.
const size_t & get_rows_number(void) const
Returns the number of rows in the matrix.
std::string write_fitness_assignment_method(void) const
Returns a string with the name of the method used for fitness assignment.
size_t maximum_generations_number
Maximum number of generations to perform_training.
void perform_line_recombination(void)
const bool & get_reserve_standard_deviation_performance_history(void) const
bool reserve_mean_norm_history
True if the mean norm history vector is to be reserved, false otherwise.
Vector< double > standard_deviation_performance_history
History of the standard deviation of the population performance over the generations.
void set_reserve_standard_deviation_performance_history(const bool &)
void set_recombination_method(const RecombinationMethod &)
void from_XML(const tinyxml2::XMLDocument &)
void save(const std::string &) const
double standard_deviation_performance_goal
virtual void check(void) const
void randomize_uniform(const double &=-1.0, const double &=1.0)
void perform_selection(void)
Selects for recombination some individuals from the population according to the selection operator...
FitnessAssignmentMethod
Enumeration of the available training operators for fitness assignment.
double calculate_mean_performance(void) const
Returns the mean value of the individuals performance.
size_t generations_number
Number of generations needed by the evolutionary algorithm.
Vector< double > best_performance_history
History of the performance of the best individual over each generations.
double best_performance_goal
Best goal value for the performance. It is used as a stopping criterion.
const bool & get_reserve_elapsed_time_history(void) const
Returns true if the elapsed time history vector is to be reserved, and false otherwise.
Vector< double > fitness
Fitness of population.
Matrix< double > population
Population matrix.
SelectionMethod
Enumeration of the available training operators for selection.
FitnessAssignmentMethod fitness_assignment_method
Fitness assignment training operators enumeration.
void randomize_population_uniform(void)
std::string write_selection_method(void) const
Returns a string with the name of the method used for selection.
size_t calculate_best_individual_index(void) const
Returns the index of the individual with greatest fitness.
bool reserve_mean_performance_history
True if the mean performance history vector is to be reserved, false otherwise.
const Vector< bool > & get_selection(void) const
Returns the actual selection value of all individuals in the population.
const bool & get_reserve_mean_norm_history(void) const
Returns true if the mean population norm history vector is to be reserved, and false otherwise...
const bool & get_reserve_generalization_performance_history(void) const
Returns true if the Generalization performance history vector is to be reserved, and false otherwise...
void set_maximum_time(const double &)
double recombination_size
void set_elitism_size(const size_t &)
void set_reserve_best_performance_history(const bool &)
double calculate_mean(void) const
Returns the mean of the elements in the vector.
const bool & get_reserve_mean_performance_history(void) const
Returns true if the mean performance history vector is to be reserved, and false otherwise.
Vector< double > elapsed_time_history
History of the elapsed time over the generations.
void perform_roulette_wheel_selection(void)
PerformanceFunctional * performance_functional_pointer
Pointer to a performance functional for a multilayer perceptron object.
const size_t & get_maximum_generalization_performance_decreases(void) const
Returns the maximum number of generalization failures during the training process.
void set_mutation_rate(const double &)
bool empty(void) const
Returns true if number of rows and columns is zero.
RecombinationMethod recombination_method
Recombination training operators enumeration.
MutationMethod
Enumeration of the available training operators for mutation.
void set_reserve_standard_deviation_norm_history(const bool &)
T calculate_sum(void) const
Returns the sum of the elements in the vector.
void set_reserve_best_norm_history(const bool &)
double mean_performance_goal
double final_generalization_performance
Generalization performance after training.
void set_row(const size_t &, const Vector< T > &)
size_t display_period
Number of iterations between the training showing progress.
double error_parameters_norm
Value for the parameters norm at which the training process is assumed to fail.
void set_mean_performance_goal(const double &)
const Matrix< double > & get_population(void) const
Returns the population matrix.
Vector< T > arrange_row(const size_t &) const
RecombinationMethod
Enumeration of the available training operators for recombination.
const size_t & get_elitism_size(void) const
Returns the number of individuals which will always be selected for recombination.
Vector< Vector< double > > best_individual_history
History of the best individual parameters over the generations.
void randomize_normal(const double &=0.0, const double &=1.0)
const Vector< double > & get_fitness(void) const
Returns the actual fitness value of all individuals in the population.
size_t count_occurrences(const T &) const
Returns the number of times that a certain value is contained in the vector.
void perform_fitness_assignment(void)
Assigns a fitness value to all the individuals in the population according to the finess assignment o...
void set_best_performance_goal(const double &)
void set_parameters(const Vector< double > &)