00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <string>
00019 #include <sstream>
00020 #include <iostream>
00021 #include <fstream>
00022 #include <algorithm>
00023 #include <functional>
00024 #include <cmath>
00025 #include <ctime>
00026
00027
00028
00029 #include "RandomSearch.h"
00030
00031 namespace Flood
00032 {
00033
00034
00035
00040
00041 RandomSearch::RandomSearch(ObjectiveFunctional* new_objective_functional_pointer)
00042 : TrainingAlgorithm(new_objective_functional_pointer)
00043 {
00044 set_default();
00045 }
00046
00047
00048
00049
00053
00054 RandomSearch::RandomSearch(void) : TrainingAlgorithm()
00055 {
00056 set_default();
00057 }
00058
00059
00060
00061
00063
00064 RandomSearch::~RandomSearch(void)
00065 {
00066
00067 }
00068
00069
00070
00071
00073
00074 double RandomSearch::get_training_rate_reduction_factor(void)
00075 {
00076 return(training_rate_reduction_factor);
00077 }
00078
00079
00080
00081
00083
00084 int RandomSearch::get_training_rate_reduction_period(void)
00085 {
00086 return(training_rate_reduction_period);
00087 }
00088
00089
00090
00091
00093
00094 bool RandomSearch::get_reserve_potential_parameters_history(void)
00095 {
00096 return(reserve_potential_parameters_history);
00097 }
00098
00099
00100
00101
00103
00104 bool RandomSearch::get_reserve_potential_parameters_norm_history(void)
00105 {
00106 return(reserve_potential_parameters_norm_history);
00107 }
00108
00109
00110
00111
00113
00114 bool RandomSearch::get_reserve_potential_evaluation_history(void)
00115 {
00116 return(reserve_potential_evaluation_history);
00117 }
00118
00119
00120
00121
00123
00124 Vector< Vector<double> > RandomSearch::get_potential_parameters_history(void)
00125 {
00126 return(potential_parameters_history);
00127 }
00128
00129
00130
00131
00133
00134 Vector<double> RandomSearch::get_potential_parameters_norm_history(void)
00135 {
00136 return(potential_parameters_norm_history);
00137 }
00138
00139
00140
00141
00143
00144 Vector<double> RandomSearch::get_potential_evaluation_history(void)
00145 {
00146 return(potential_evaluation_history);
00147 }
00148
00149
00150
00151
00167
00168 void RandomSearch::set_default(void)
00169 {
00170
00171
00172 first_training_rate = 1.0;
00173
00174 training_rate_reduction_factor = 0.9;
00175 training_rate_reduction_period = 10;
00176
00177
00178
00179 minimum_evaluation_improvement = 0.0;
00180 evaluation_goal = -1.0e99;
00181
00182 maximum_epochs_number = 1000;
00183 maximum_time = 1000.0;
00184
00185
00186
00187 reserve_potential_parameters_history = false;
00188 reserve_parameters_history = false;
00189 reserve_potential_parameters_norm_history = false;
00190 reserve_parameters_norm_history = false;
00191
00192 reserve_potential_evaluation_history = false;
00193 reserve_evaluation_history = false;
00194
00195 reserve_training_direction_history = false;
00196 reserve_training_rate_history = false;
00197 reserve_elapsed_time_history = false;
00198
00199
00200
00201 display = true;
00202 display_period = 100;
00203 }
00204
00205
00206
00207
00208 void RandomSearch::set_training_rate_reduction_factor(double new_training_rate_reduction_factor)
00209 {
00210 training_rate_reduction_factor = new_training_rate_reduction_factor;
00211 }
00212
00213
00214
00215
00216 void RandomSearch::set_training_rate_reduction_period(int new_training_rate_reduction_period)
00217 {
00218 training_rate_reduction_period = new_training_rate_reduction_period;
00219 }
00220
00221
00222
00223
00224 void RandomSearch::set_reserve_potential_parameters_history(bool new_reserve_potential_parameters_history)
00225 {
00226 reserve_potential_parameters_history = new_reserve_potential_parameters_history;
00227 }
00228
00229
00230
00231
00232 void RandomSearch::set_reserve_potential_parameters_norm_history(bool new_reserve_potential_parameters_norm_history)
00233 {
00234 reserve_potential_parameters_norm_history = new_reserve_potential_parameters_norm_history;
00235 }
00236
00237
00238
00239
00240 void RandomSearch::set_reserve_potential_evaluation_history(bool new_reserve_potential_evaluation_history)
00241 {
00242 reserve_potential_evaluation_history = new_reserve_potential_evaluation_history;
00243 }
00244
00245
00246
00247
00248 void RandomSearch::set_potential_parameters_history(const Vector< Vector<double> >& new_potential_parameters_history)
00249 {
00250 potential_parameters_history = new_potential_parameters_history;
00251 }
00252
00253
00254
00255
00256 void RandomSearch::set_potential_parameters_norm_history(const Vector<double>& new_potential_parameters_norm_history)
00257 {
00258 potential_parameters_norm_history = new_potential_parameters_norm_history;
00259 }
00260
00261
00262
00263
00264 void RandomSearch::set_potential_evaluation_history(const Vector<double>& new_potential_evaluation_history)
00265 {
00266 potential_evaluation_history = new_potential_evaluation_history;
00267 }
00268
00269
00270
00271
00276
00277 void RandomSearch::set_reserve_all_training_history(bool new_reserve_all_training_history)
00278 {
00279
00280
00281 reserve_potential_parameters_history = new_reserve_all_training_history;
00282 reserve_parameters_history = new_reserve_all_training_history;
00283
00284 reserve_potential_parameters_norm_history = new_reserve_all_training_history;
00285 reserve_parameters_norm_history = new_reserve_all_training_history;
00286
00287
00288
00289 reserve_potential_evaluation_history = new_reserve_all_training_history;
00290 reserve_evaluation_history = new_reserve_all_training_history;
00291
00292
00293
00294 reserve_elapsed_time_history = new_reserve_all_training_history;
00295 }
00296
00297
00298
00299
00300 Vector<double> RandomSearch::calculate_training_direction(void)
00301 {
00302 MultilayerPerceptron* multilayer_perceptron_pointer = objective_functional_pointer->get_multilayer_perceptron_pointer();
00303
00304 int parameters_number = multilayer_perceptron_pointer->get_parameters_number();
00305
00306 Vector<double> random(parameters_number);
00307 double random_norm;
00308
00309 do
00310 {
00311 random.initialize_uniform();
00312 random_norm = random.calculate_norm();
00313 }while(random_norm > 1.0);
00314
00315 return(random/random_norm);
00316 }
00317
00318
00319
00320
00324
00325 void RandomSearch::train(void)
00326 {
00327
00328
00329 #ifdef _DEBUG
00330
00331 if(objective_functional_pointer == NULL)
00332 {
00333 std::cerr << "Flood Error: RandomSearch class." << std::endl
00334 << "void train(void) method." << std::endl
00335 << "Pointer to objective functional object cannot be NULL." << std::endl;
00336
00337 exit(1);
00338 }
00339
00340 #endif
00341
00342
00343
00344 if(display)
00345 {
00346 std::cout << "Training with random search..." << std::endl;
00347 }
00348
00349
00350
00351 time_t beginning_time, current_time;
00352 time(&beginning_time);
00353 double elapsed_time;
00354
00355
00356
00357 MultilayerPerceptron* multilayer_perceptron_pointer = objective_functional_pointer->get_multilayer_perceptron_pointer();
00358
00359 int parameters_number = multilayer_perceptron_pointer->get_parameters_number();
00360
00361 Vector<double> parameters(parameters_number);
00362 Vector<double> potential_parameters(parameters_number);
00363
00364 double parameters_norm = 0.0;
00365 double potential_parameters_norm = 0.0;
00366
00367
00368
00369 double evaluation = 0.0;
00370 double potential_evaluation = 0.0;
00371
00372
00373
00374 Vector<double> training_direction(parameters_number);
00375 double training_rate = 0.0;
00376
00377 Vector<double> parameters_increment(parameters_number);
00378
00379 bool stop_training = false;
00380
00381 resize_training_history(maximum_epochs_number+1);
00382
00383
00384
00385 for(int epoch = 0; epoch <= maximum_epochs_number; epoch++)
00386 {
00387 if(epoch == 0)
00388 {
00389 parameters = multilayer_perceptron_pointer->get_parameters();
00390 potential_parameters = parameters;
00391
00392 parameters_norm = potential_parameters.calculate_norm();
00393 potential_parameters_norm = parameters_norm;
00394 }
00395
00396
00397
00398 if(epoch == 0)
00399 {
00400 evaluation = objective_functional_pointer->calculate_evaluation();
00401 potential_evaluation = evaluation;
00402 }
00403 else
00404 {
00405 potential_evaluation = objective_functional_pointer->calculate_potential_evaluation(potential_parameters);
00406 }
00407
00408 if(potential_evaluation < evaluation)
00409 {
00410 parameters = potential_parameters;
00411
00412 multilayer_perceptron_pointer->set_parameters(potential_parameters);
00413
00414 evaluation = potential_evaluation;
00415 }
00416
00417
00418
00419 training_direction = calculate_training_direction();
00420
00421 if(epoch == 0)
00422 {
00423 training_rate = first_training_rate;
00424 }
00425 else if(epoch%training_rate_reduction_period == 0)
00426 {
00427 training_rate *= training_rate_reduction_factor;
00428 }
00429
00430 parameters_increment = training_direction*training_rate;
00431
00432
00433
00434 time(¤t_time);
00435 elapsed_time = difftime(current_time, beginning_time);
00436
00437
00438
00439 if(reserve_potential_parameters_history)
00440 {
00441 potential_parameters_history[epoch] = potential_parameters;
00442 }
00443
00444 if(reserve_parameters_history)
00445 {
00446 parameters_history[epoch] = parameters;
00447 }
00448
00449 if(reserve_potential_parameters_norm_history)
00450 {
00451 potential_parameters_norm_history[epoch] = potential_parameters_norm;
00452 } if(reserve_parameters_norm_history)
00453 {
00454 parameters_norm_history[epoch] = parameters_norm;
00455 }
00456
00457
00458
00459 if(reserve_potential_evaluation_history)
00460 {
00461 potential_evaluation_history[epoch] = potential_evaluation;
00462 }
00463
00464 if(reserve_evaluation_history)
00465 {
00466 evaluation_history[epoch] = evaluation;
00467 }
00468
00469
00470
00471 if(reserve_training_direction_history)
00472 {
00473 training_direction_history[epoch] = training_direction;
00474 }
00475
00476 if(reserve_training_rate_history)
00477 {
00478 training_rate_history[epoch] = training_rate;
00479 }
00480
00481 if(reserve_elapsed_time_history)
00482 {
00483 elapsed_time_history[epoch] = elapsed_time;
00484 }
00485
00486
00487
00488 if(potential_evaluation <= evaluation_goal)
00489 {
00490 if(display)
00491 {
00492 std::cout << "Epoch " << epoch << ": Evaluation goal reached." << std::endl;
00493 }
00494
00495 stop_training = true;
00496 }
00497
00498 else if(epoch == maximum_epochs_number)
00499 {
00500 if(display)
00501 {
00502 std::cout << "Epoch " << epoch << ": Maximum number of epochs reached." << std::endl;
00503 }
00504
00505 stop_training = true;
00506 }
00507
00508 else if(elapsed_time >= maximum_time)
00509 {
00510 if(display)
00511 {
00512 std::cout << "Epoch " << epoch << ": Maximum training time reached." << std::endl;
00513 }
00514
00515 stop_training = true;
00516 }
00517
00518 if(stop_training)
00519 {
00520 if(display)
00521 {
00522 std::cout << "Potential parameters norm: " << potential_parameters_norm << std::endl
00523 << "Parameters norm: " << parameters_norm << std::endl
00524 << "Potential evaluation: " << potential_evaluation << std::endl
00525 << "Evaluation: " << evaluation << std::endl
00526 << "Training rate: " << training_rate << std::endl
00527 << "Elapsed time: " << elapsed_time << std::endl;
00528
00529 objective_functional_pointer->print_information();
00530 }
00531
00532 break;
00533 }
00534
00535 else if(display && epoch % display_period == 0)
00536 {
00537 std::cout << "Epoch " << epoch << ";" << std::endl;
00538
00539 std::cout << "Potential parameters norm: " << potential_parameters_norm << std::endl
00540 << "Parameters norm: " << parameters_norm << std::endl
00541 << "Potential evaluation: " << potential_evaluation << std::endl
00542 << "Evaluation: " << evaluation << std::endl
00543 << "Training rate: " << training_rate << std::endl
00544 << "Elapsed time: " << elapsed_time << std::endl;
00545
00546 objective_functional_pointer->print_information();
00547 }
00548
00549
00550
00551 potential_parameters = parameters + parameters_increment;
00552 potential_parameters_norm = potential_parameters.calculate_norm();
00553 }
00554 }
00555
00556
00557
00558
00570
00571 void RandomSearch::resize_training_history(int new_size)
00572 {
00573
00574
00575 if(reserve_potential_parameters_history)
00576 {
00577 potential_parameters_history.resize(new_size);
00578 }
00579
00580
00581
00582 if(reserve_parameters_history)
00583 {
00584 parameters_history.resize(new_size);
00585 }
00586
00587
00588
00589 if(reserve_potential_parameters_norm_history)
00590 {
00591 potential_parameters_norm_history.resize(new_size);
00592 }
00593
00594
00595
00596 if(reserve_parameters_norm_history)
00597 {
00598 parameters_norm_history.resize(new_size);
00599 }
00600
00601
00602
00603 if(reserve_potential_evaluation_history)
00604 {
00605 potential_evaluation_history.resize(new_size);
00606 }
00607
00608
00609
00610 if(reserve_evaluation_history)
00611 {
00612 evaluation_history.resize(new_size);
00613 }
00614
00615
00616
00617 if(reserve_elapsed_time_history)
00618 {
00619 elapsed_time_history.resize(new_size);
00620 }
00621 }
00622
00623
00624
00625
00626 std::string RandomSearch::get_training_history_XML(bool show_declaration)
00627 {
00628 std::stringstream buffer;
00629
00630 if(show_declaration)
00631 {
00632 buffer << "<Flood version='3.0' class='RandomSearch' content='TrainingHistory'>" << std::endl;
00633 }
00634
00635 if(reserve_potential_parameters_history)
00636 {
00637 buffer << "<PotentialParametersHistory>" << std::endl
00638 << potential_parameters_history << std::endl
00639 << "</PotentialParametersHistory>" << std::endl;
00640 }
00641
00642 if(reserve_parameters_history)
00643 {
00644 buffer << "<ParametersHistory>" << std::endl
00645 << parameters_history << std::endl
00646 << "</ParametersHistory>" << std::endl;
00647 }
00648
00649 if(reserve_potential_parameters_norm_history)
00650 {
00651 buffer << "<PotentialParametersNormHistory>" << std::endl
00652 << potential_parameters_norm_history << std::endl
00653 << "</PotentialParametersNormHistory>" << std::endl;
00654 }
00655
00656 if(reserve_parameters_norm_history)
00657 {
00658 buffer << "<ParametersNormHistory>" << std::endl
00659 << parameters_norm_history << std::endl
00660 << "</ParametersNormHistory>" << std::endl;
00661 }
00662
00663 if(reserve_potential_evaluation_history)
00664 {
00665 buffer << "<PotentialEvaluationHistory>" << std::endl
00666 << potential_evaluation_history << std::endl
00667 << "</PotentialEvaluationHistory>" << std::endl;
00668 }
00669
00670 if(reserve_evaluation_history)
00671 {
00672 buffer << "<EvaluationHistory>" << std::endl
00673 << evaluation_history << std::endl
00674 << "</EvaluationHistory>" << std::endl;
00675 }
00676
00677 if(reserve_training_direction_history)
00678 {
00679 buffer << "<TrainingDirectionHistory>" << std::endl
00680 << training_direction_history << std::endl
00681 << "</TrainingDirectionHistory>" << std::endl;
00682 }
00683
00684 if(reserve_training_rate_history)
00685 {
00686 buffer << "<TrainingRateHistory>" << std::endl
00687 << training_rate_history << std::endl
00688 << "</TrainingRateHistory>" << std::endl;
00689 }
00690
00691 if(reserve_elapsed_time_history)
00692 {
00693 buffer << "<ElapsedTimeHistory>" << std::endl
00694 << elapsed_time_history << std::endl
00695 << "</ElapsedTimeHistory>" << std::endl;
00696 }
00697
00698 return(buffer.str());
00699 }
00700
00701
00702
00703
00707
00708 std::string RandomSearch::to_XML(bool show_declaration)
00709 {
00710 std::stringstream buffer;
00711
00712 if(show_declaration)
00713 {
00714 buffer << "<Flood version='3.0' class='RandomSearch'>" << std::endl;
00715 }
00716
00717
00718
00719 buffer << "<FirstTrainingRate>" << std::endl
00720 << first_training_rate << std::endl
00721 << "</FirstTrainingRate>" << std::endl;
00722
00723 buffer << "<TrainingRateReductionPeriod>" << std::endl
00724 << training_rate_reduction_period << std::endl
00725 << "</TrainingRateReductionPeriod>" << std::endl;
00726
00727 buffer << "<TrainingRateReductionFactor>" << std::endl
00728 << training_rate_reduction_factor << std::endl
00729 << "</TrainingRateReductionFactor>" << std::endl;
00730
00731 buffer << "<WarningParametersNorm>" << std::endl
00732 << warning_parameters_norm << std::endl
00733 << "</WarningParametersNorm>" << std::endl;
00734
00735 buffer << "<ErrorParametersNorm>" << std::endl
00736 << error_parameters_norm << std::endl
00737 << "</ErrorParametersNorm>" << std::endl;
00738
00739
00740
00741 buffer << "<EvaluationGoal>" << std::endl
00742 << evaluation_goal << std::endl
00743 << "</EvaluationGoal>" << std::endl;
00744
00745 buffer << "<MaximumEpochsNumber>" << std::endl
00746 << maximum_epochs_number << std::endl
00747 << "</MaximumEpochsNumber>" << std::endl;
00748
00749 buffer << "<MaximumTime>" << std::endl
00750 << maximum_time << std::endl
00751 << "</MaximumTime>" << std::endl;
00752
00753
00754
00755 buffer << "<ReservePotentialParametersHistory>" << std::endl
00756 << reserve_potential_parameters_history << std::endl
00757 << "</ReservePotentialParametersHistory>" << std::endl;
00758
00759 buffer << "<ReserveParametersHistory>" << std::endl
00760 << reserve_parameters_history << std::endl
00761 << "</ReserveParametersHistory>" << std::endl;
00762
00763 buffer << "<ReservePotentialParametersNormHistory>" << std::endl
00764 << reserve_potential_parameters_norm_history << std::endl
00765 << "</ReservePotentialParametersNormHistory>" << std::endl;
00766
00767 buffer << "<ReserveParametersNormHistory>" << std::endl
00768 << reserve_parameters_norm_history << std::endl
00769 << "</ReserveParametersNormHistory>" << std::endl;
00770
00771 buffer << "<ReservePotentialEvaluationHistory>" << std::endl
00772 << reserve_potential_evaluation_history << std::endl
00773 << "</ReservePotentialEvaluationHistory>" << std::endl;
00774
00775 buffer << "<ReserveEvaluationHistory>" << std::endl
00776 << reserve_evaluation_history << std::endl
00777 << "</ReserveEvaluationHistory>" << std::endl;
00778
00779 buffer << "<ReserveElapsedTimeHistory>" << std::endl
00780 << reserve_elapsed_time_history << std::endl
00781 << "</ReserveElapsedTimeHistory>" << std::endl;
00782
00783
00784
00785 buffer << "<DisplayPeriod>" << std::endl
00786 << display_period << std::endl
00787 << "</DisplayPeriod>" << std::endl;
00788
00789 buffer << "<Display>" << std::endl
00790 << display << std::endl
00791 << "</Display>" << std::endl;
00792
00793 return(buffer.str());
00794 }
00795
00796
00797
00798
00802
00803 void RandomSearch::load(const char* filename)
00804 {
00805
00806
00807 std::fstream file;
00808
00809 file.open(filename, std::ios::in);
00810
00811 if(!file.is_open())
00812 {
00813 std::cerr << "Flood Error: RandomSearch class." << std::endl
00814 << "void load(const char*) method." << std::endl
00815 << "Cannot open random search object data file." << std::endl;
00816
00817 exit(1);
00818 }
00819
00820 std::string word;
00821 std::string line;
00822
00823
00824
00825 getline(file, line);
00826
00827 if(line != "<Flood version='3.0' class='RandomSearch'>")
00828 {
00829
00830
00831
00832
00833
00834 }
00835
00836 while(!file.eof())
00837 {
00838 file >> word;
00839
00840
00841
00842 if(word == "<FirstTrainingRate>")
00843 {
00844 double new_first_training_rate;
00845
00846 file >> new_first_training_rate;
00847
00848 file >> word;
00849
00850 if(word != "</FirstTrainingRate>")
00851 {
00852 std::cerr << "Flood Error: RandomSearch class." << std::endl
00853 << "void load(const char*) method." << std::endl
00854 << "Unknown first training rate end tag: " << word << std::endl;
00855
00856 exit(1);
00857 }
00858
00859 set_first_training_rate(new_first_training_rate);
00860 }
00861
00862 if(word == "<TrainingRateReductionPeriod>")
00863 {
00864 int new_training_rate_reduction_period;
00865
00866 file >> new_training_rate_reduction_period;
00867
00868 file >> word;
00869
00870 if(word != "</TrainingRateReductionPeriod>")
00871 {
00872 std::cerr << "Flood Error: RandomSearch class." << std::endl
00873 << "void load(const char*) method." << std::endl
00874 << "Unknown training rate reduction period end tag: " << word << std::endl;
00875
00876 exit(1);
00877 }
00878
00879 set_training_rate_reduction_period(new_training_rate_reduction_period);
00880 }
00881
00882 if(word == "<TrainingRateReductionFactor>")
00883 {
00884 double new_training_rate_reduction_factor;
00885
00886 file >> new_training_rate_reduction_factor;
00887
00888 file >> word;
00889
00890 if(word != "</TrainingRateReductionFactor>")
00891 {
00892 std::cerr << "Flood Error: RandomSearch class." << std::endl
00893 << "void load(const char*) method." << std::endl
00894 << "Unknown training rate reduction factor end tag: " << word << std::endl;
00895
00896 exit(1);
00897 }
00898
00899 set_training_rate_reduction_factor(new_training_rate_reduction_factor);
00900 }
00901
00902 if(word == "<WarningParametersNorm>")
00903 {
00904 double new_warning_parameters_norm;
00905
00906 file >> new_warning_parameters_norm;
00907
00908 file >> word;
00909
00910 if(word != "</WarningParametersNorm>")
00911 {
00912 std::cerr << "Flood Error: RandomSearch class." << std::endl
00913 << "void load(const char*) method." << std::endl
00914 << "Unknown warning parameters norm end tag: " << word << std::endl;
00915
00916 exit(1);
00917 }
00918
00919 set_warning_parameters_norm(new_warning_parameters_norm);
00920 }
00921
00922 else if(word == "<ErrorParametersNorm>")
00923 {
00924 double new_error_parameters_norm;
00925
00926 file >> new_error_parameters_norm;
00927
00928 file >> word;
00929
00930 if(word != "</ErrorParametersNorm>")
00931 {
00932 std::cerr << "Flood Error: RandomSearch class." << std::endl
00933 << "void load(const char*) method." << std::endl
00934 << "Unknown error parameters norm end tag: " << word << std::endl;
00935
00936 exit(1);
00937 }
00938
00939 set_error_parameters_norm(new_error_parameters_norm);
00940 }
00941
00942
00943
00944 else if(word == "<EvaluationGoal>")
00945 {
00946 double new_evaluation_goal;
00947
00948 file >> new_evaluation_goal;
00949
00950 file >> word;
00951
00952 if(word != "</EvaluationGoal>")
00953 {
00954 std::cerr << "Flood Error: RandomSearch class." << std::endl
00955 << "void load(const char*) method." << std::endl
00956 << "Unknown evaluation goal end tag: " << word << std::endl;
00957
00958 exit(1);
00959 }
00960
00961 set_evaluation_goal(new_evaluation_goal);
00962 }
00963
00964 else if(word == "<MaximumEpochsNumber>")
00965 {
00966 int new_maximum_epochs_number;
00967
00968 file >> new_maximum_epochs_number;
00969
00970 file >> word;
00971
00972 if(word != "</MaximumEpochsNumber>")
00973 {
00974 std::cerr << "Flood Error: RandomSearch class." << std::endl
00975 << "void load(const char*) method." << std::endl
00976 << "Unknown maximum epochs number end tag: " << word << std::endl;
00977
00978 exit(1);
00979 }
00980
00981 set_maximum_epochs_number(new_maximum_epochs_number);
00982 }
00983
00984 else if(word == "<MaximumTime>")
00985 {
00986 double new_maximum_time;
00987
00988 file >> new_maximum_time;
00989
00990 file >> word;
00991
00992 if(word != "</MaximumTime>")
00993 {
00994 std::cerr << "Flood Error: RandomSearch class." << std::endl
00995 << "void load(const char*) method." << std::endl
00996 << "Unknown maximum time end tag: " << word << std::endl;
00997
00998 exit(1);
00999 }
01000
01001 set_maximum_time(new_maximum_time);
01002 }
01003
01004
01005
01006 else if(word == "<ReservePotentialParametersHistory>")
01007 {
01008 bool new_reserve_potential_parameters_history;
01009
01010 file >> new_reserve_potential_parameters_history;
01011
01012 file >> word;
01013
01014 if(word != "</ReservePotentialParametersHistory>")
01015 {
01016 std::cerr << "Flood Error: RandomSearch class." << std::endl
01017 << "void load(const char*) method." << std::endl
01018 << "Unknown reserve potential parameters history end tag: " << word << std::endl;
01019
01020 exit(1);
01021 }
01022
01023 set_reserve_potential_parameters_history(new_reserve_potential_parameters_history);
01024 }
01025
01026 else if(word == "<ReserveParametersHistory>")
01027 {
01028 bool new_reserve_parameters_history;
01029
01030 file >> new_reserve_parameters_history;
01031
01032 file >> word;
01033
01034 if(word != "</ReserveParametersHistory>")
01035 {
01036 std::cerr << "Flood Error: RandomSearch class." << std::endl
01037 << "void load(const char*) method." << std::endl
01038 << "Unknown reserve parameters history end tag: " << word << std::endl;
01039
01040 exit(1);
01041 }
01042
01043 set_reserve_parameters_history(new_reserve_parameters_history);
01044 }
01045
01046 else if(word == "<ReservePotentialParametersNormHistory>")
01047 {
01048 bool new_reserve_potential_parameters_norm_history;
01049
01050 file >> new_reserve_potential_parameters_norm_history;
01051
01052 file >> word;
01053
01054 if(word != "</ReservePotentialParametersNormHistory>")
01055 {
01056 std::cerr << "Flood Error: RandomSearch class." << std::endl
01057 << "void load(const char*) method." << std::endl
01058 << "Unknown reserve potential parameters norm history end tag: " << word << std::endl;
01059
01060 exit(1);
01061 }
01062
01063 set_reserve_potential_parameters_norm_history(new_reserve_potential_parameters_norm_history);
01064 }
01065
01066 else if(word == "<ReserveParametersNormHistory>")
01067 {
01068 bool new_reserve_parameters_norm_history;
01069
01070 file >> new_reserve_parameters_norm_history;
01071
01072 file >> word;
01073
01074 if(word != "</ReserveParametersNormHistory>")
01075 {
01076 std::cerr << "Flood Error: RandomSearch class." << std::endl
01077 << "void load(const char*) method." << std::endl
01078 << "Unknown reserve parameters norm history end tag: " << word << std::endl;
01079
01080 exit(1);
01081 }
01082
01083 set_reserve_parameters_norm_history(new_reserve_parameters_norm_history);
01084 }
01085
01086 else if(word == "<ReservePotentialEvaluationHistory>")
01087 {
01088 bool new_reserve_potential_evaluation_history;
01089
01090 file >> new_reserve_potential_evaluation_history;
01091
01092 file >> word;
01093
01094 if(word != "</ReservePotentialEvaluationHistory>")
01095 {
01096 std::cerr << "Flood Error: RandomSearch class." << std::endl
01097 << "void load(const char*) method." << std::endl
01098 << "Unknown reserve potential evaluation history end tag: " << word << std::endl;
01099
01100 exit(1);
01101 }
01102
01103 set_reserve_potential_evaluation_history(new_reserve_potential_evaluation_history);
01104 }
01105
01106 else if(word == "<ReserveEvaluationHistory>")
01107 {
01108 bool new_reserve_evaluation_history;
01109
01110 file >> new_reserve_evaluation_history;
01111
01112 file >> word;
01113
01114 if(word != "</ReserveEvaluationHistory>")
01115 {
01116 std::cerr << "Flood Error: RandomSearch class." << std::endl
01117 << "void load(const char*) method." << std::endl
01118 << "Unknown reserve evaluation history end tag: " << word << std::endl;
01119
01120 exit(1);
01121 }
01122
01123 set_reserve_evaluation_history(new_reserve_evaluation_history);
01124 }
01125
01126 else if(word == "<ReserveElapsedTimeHistory>")
01127 {
01128 bool new_reserve_elapsed_time_history;
01129
01130 file >> new_reserve_elapsed_time_history;
01131
01132 file >> word;
01133
01134 if(word != "</ReserveElapsedTimeHistory>")
01135 {
01136 std::cerr << "Flood Error: RandomSearch class." << std::endl
01137 << "void load(const char*) method." << std::endl
01138 << "Unknown reserve elapsed time history end tag: " << word << std::endl;
01139
01140 exit(1);
01141 }
01142
01143 set_reserve_elapsed_time_history(new_reserve_elapsed_time_history);
01144 }
01145
01146
01147
01148 else if(word == "<DisplayPeriod>")
01149 {
01150 int new_display_period;
01151
01152 file >> new_display_period;
01153
01154 file >> word;
01155
01156 if(word != "</DisplayPeriod>")
01157 {
01158 std::cerr << "Flood Error: RandomSearch class." << std::endl
01159 << "void load(const char*) method." << std::endl
01160 << "Unknown display period end tag: " << word << std::endl;
01161
01162 exit(1);
01163 }
01164
01165 set_display_period(new_display_period);
01166 }
01167
01168 else if(word == "<Display>")
01169 {
01170 bool new_display;
01171
01172 file >> new_display;
01173
01174 file >> word;
01175
01176 if(word != "</Display>")
01177 {
01178 std::cerr << "Flood Error: RandomSearch class." << std::endl
01179 << "void load(const char*) method." << std::endl
01180 << "Unknown display end tag: " << word << std::endl;
01181
01182 exit(1);
01183 }
01184
01185 set_display(new_display);
01186 }
01187
01188 else
01189 {
01190
01191
01192
01193
01194
01195 }
01196 }
01197
01198
01199
01200 file.close();
01201 }
01202
01203 }
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221