00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* Flood: An Open Source Neural Networks C++ Library */ 00004 /* www.cimne.com/flood */ 00005 /* */ 00006 /* R A N D O M S E A R C H C L A S S H E A D E R */ 00007 /* */ 00008 /* Roberto Lopez */ 00009 /* International Center for Numerical Methods in Engineering (CIMNE) */ 00010 /* Technical University of Catalonia (UPC) */ 00011 /* Barcelona, Spain */ 00012 /* E-mail: rlopez@cimne.upc.edu */ 00013 /* */ 00014 /****************************************************************************************************************/ 00015 00016 #ifndef __RANDOMSEARCH_H__ 00017 #define __RANDOMSEARCH_H__ 00018 00019 #include "TrainingAlgorithm.h" 00020 #include "../ObjectiveFunctional/ObjectiveFunctional.h" 00021 00022 namespace Flood 00023 { 00024 00027 00028 class RandomSearch : public TrainingAlgorithm 00029 { 00030 00031 public: 00032 00033 // GENERAL CONSTRUCTOR 00034 00035 explicit RandomSearch(ObjectiveFunctional*); 00036 00037 00038 // DEFAULT CONSTRUCTOR 00039 00040 explicit RandomSearch(void); 00041 00042 00043 // DESTRUCTOR 00044 00045 virtual ~RandomSearch(void); 00046 00047 // METHODS 00048 00049 // Get methods 00050 00051 double get_training_rate_reduction_factor(void); 00052 int get_training_rate_reduction_period(void); 00053 00054 bool get_reserve_potential_parameters_history(void); 00055 bool get_reserve_potential_parameters_norm_history(void); 00056 00057 bool get_reserve_potential_evaluation_history(void); 00058 00059 Vector< Vector<double> > get_potential_parameters_history(void); 00060 Vector<double> get_potential_parameters_norm_history(void); 00061 00062 Vector<double> get_potential_evaluation_history(void); 00063 00064 // Set methods 00065 00066 void set_default(void); 00067 00068 void set_training_rate_reduction_factor(double); 00069 void set_training_rate_reduction_period(int); 00070 00071 void set_reserve_potential_parameters_history(bool); 00072 void set_reserve_potential_parameters_norm_history(bool); 00073 00074 void set_reserve_potential_evaluation_history(bool); 00075 00076 void set_potential_parameters_history(const Vector< Vector<double> >&); 00077 void set_potential_parameters_norm_history(const Vector<double>&); 00078 00079 void set_potential_evaluation_history(const Vector<double>&); 00080 00081 // Train methods 00082 00083 Vector<double> calculate_training_direction(void); 00084 00085 void train(void); 00086 00087 // Training history methods 00088 00089 void resize_training_history(int); 00090 void set_reserve_all_training_history(bool); 00091 00092 std::string get_training_history_XML(bool); 00093 00094 // Utiltity methods 00095 00096 std::string to_XML(bool); 00097 void load(const char*); 00098 00099 private: 00100 00101 // MEMBERS 00102 00103 double training_rate_reduction_factor; 00104 int training_rate_reduction_period; 00105 00106 bool reserve_potential_parameters_history; 00107 bool reserve_potential_parameters_norm_history; 00108 00109 bool reserve_potential_evaluation_history; 00110 00111 Vector< Vector<double> > potential_parameters_history; 00112 Vector<double> potential_parameters_norm_history; 00113 00114 Vector<double> potential_evaluation_history; 00115 }; 00116 00117 } 00118 00119 #endif 00120 00121 00122 // Flood: An Open Source Neural Networks C++ Library. 00123 // Copyright (C) 2005-2010 Roberto Lopez 00124 // 00125 // This library is free software; you can redistribute it and/or 00126 // modify it under the s of the GNU Lesser General Public 00127 // License as published by the Free Software Foundation; either 00128 // version 2.1 of the License, or any later version. 00129 // 00130 // This library is distributed in the hope that it will be useful, 00131 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00132 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00133 // Lesser General Public License for more details. 00134 00135 // You should have received a copy of the GNU Lesser General Public 00136 // License along with this library; if not, write to the Free Software 00137 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA