00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* OpenNN: Open Neural Networks Library */ 00004 /* www.opennn.cimne.com */ 00005 /* */ 00006 /* B O U N D I N G L A Y E R 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 __BOUNDINGLAYER_H__ 00017 #define __BOUNDINGLAYER_H__ 00018 00019 // System includes 00020 00021 #include <string> 00022 00023 // OpenNN includes 00024 00025 #include "../utilities/vector.h" 00026 #include "../utilities/matrix.h" 00027 00028 // TinyXml includes 00029 00030 #include "../../parsers/tinyxml/tinyxml.h" 00031 00032 namespace OpenNN 00033 { 00034 00037 00038 class BoundingLayer 00039 { 00040 00041 public: 00042 00043 // DEFAULT CONSTRUCTOR 00044 00045 explicit BoundingLayer(void); 00046 00047 // BOUNDING NEURONS NUMBER CONSTRUCTOR 00048 00049 explicit BoundingLayer(const unsigned int&); 00050 00051 // XML CONSTRUCTOR 00052 00053 explicit BoundingLayer(TiXmlElement*); 00054 00055 // COPY CONSTRUCTOR 00056 00057 BoundingLayer(const BoundingLayer&); 00058 00059 // DESTRUCTOR 00060 00061 virtual ~BoundingLayer(void); 00062 00063 // ASSIGNMENT OPERATOR 00064 00065 BoundingLayer& operator = (const BoundingLayer&); 00066 00067 // EQUAL TO OPERATOR 00068 00069 bool operator == (const BoundingLayer&) const; 00070 00071 // METHODS 00072 00073 bool is_empty(void) const; 00074 00075 unsigned int count_bounding_neurons_number(void) const; 00076 00077 // Variables bounds 00078 00079 const Vector<double>& get_lower_bounds(void) const; 00080 double get_lower_bound(const unsigned int&) const; 00081 00082 const Vector<double>& get_upper_bounds(void) const; 00083 double get_upper_bound(const unsigned int&) const; 00084 00085 Vector< Vector<double>* > get_bounds(void); 00086 00087 // Variables bounds 00088 00089 void set(void); 00090 void set(const unsigned int&); 00091 void set(TiXmlElement*); 00092 void set(const BoundingLayer&); 00093 00094 void set_lower_bounds(const Vector<double>&); 00095 void set_lower_bound(const unsigned int&, const double&); 00096 00097 void set_upper_bounds(const Vector<double>&); 00098 void set_upper_bound(const unsigned int&, const double&); 00099 00100 void set_bounds(const Vector< Vector<double> >&); 00101 00102 void set_display(const bool&); 00103 00104 void set_default(void); 00105 00106 void initialize_random(void); 00107 00108 // Lower and upper bounds 00109 00110 Vector<double> calculate_outputs(const Vector<double>&) const; 00111 Vector<double> calculate_derivative(const Vector<double>&) const; 00112 Vector<double> calculate_second_derivative(const Vector<double>&) const; 00113 00114 Matrix<double> arrange_Jacobian(const Vector<double>&) const; 00115 Vector< Matrix<double> > arrange_Hessian_form(const Vector<double>&) const; 00116 00117 // Expression methods 00118 00119 std::string write_expression(const Vector<std::string>&, const Vector<std::string>&) const; 00120 00121 // Serialization methods 00122 00123 std::string to_string(void) const; 00124 00125 TiXmlElement* to_XML(void) const; 00126 void from_XML(TiXmlElement*); 00127 00128 protected: 00129 00130 // MEMBERS 00131 00133 00134 Vector<double> lower_bounds; 00135 00137 00138 Vector<double> upper_bounds; 00139 00141 00142 bool display; 00143 }; 00144 00145 } 00146 00147 #endif 00148 00149 00150 // OpenNN: Open Neural Networks Library. 00151 // Copyright (C) 2005-2012 Roberto Lopez 00152 // 00153 // This library is free software; you can redistribute it and/or 00154 // modify it under the terms of the GNU Lesser General Public 00155 // License as published by the Free Software Foundation; either 00156 // version 2.1 of the License, or any later version. 00157 // 00158 // This library is distributed in the hope that it will be useful, 00159 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00160 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00161 // Lesser General Public License for more details. 00162 00163 // You should have received a copy of the GNU Lesser General Public 00164 // License along with this library; if not, write to the Free Software 00165 00166 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00167