00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* OpenNN: Open Neural Networks Library */ 00004 /* www.opennn.cimne.com */ 00005 /* */ 00006 /* M A T H E M A T I C A L M O D E L 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 00017 #ifndef __MATHEMATICALMODEL_H__ 00018 #define __MATHEMATICALMODEL_H__ 00019 00020 // OpenNN includes 00021 00022 #include "../neural_network/neural_network.h" 00023 00024 #include "../utilities/vector.h" 00025 #include "../utilities/matrix.h" 00026 00027 namespace OpenNN 00028 { 00029 00034 00035 class MathematicalModel 00036 { 00037 00038 public: 00039 00040 // DEFAULT CONSTRUCTOR 00041 00042 explicit MathematicalModel(void); 00043 00044 // XML CONSTRUCTOR 00045 00046 explicit MathematicalModel(TiXmlElement*); 00047 00048 // FILE CONSTRUCTOR 00049 00050 explicit MathematicalModel(const std::string&); 00051 00052 // COPY CONSTRUCTOR 00053 00054 MathematicalModel(const MathematicalModel&); 00055 00056 // DESTRUCTOR 00057 00058 virtual ~MathematicalModel(void); 00059 00060 // ASSIGNMENT OPERATOR 00061 00062 virtual MathematicalModel& operator = (const MathematicalModel&); 00063 00064 // EQUAL TO OPERATOR 00065 00066 virtual bool operator == (const MathematicalModel&) const; 00067 00068 // METHODS 00069 00070 // Get methods 00071 00072 const unsigned int& get_independent_variables_number(void) const; 00073 const unsigned int& get_dependent_variables_number(void) const; 00074 00075 unsigned int count_variables_number(void) const; 00076 00077 const bool& get_display(void) const; 00078 00079 // Set methods 00080 00081 virtual void set(const MathematicalModel&); 00082 00083 void set_independent_variables_number(const unsigned int&); 00084 void set_dependent_variables_number(const unsigned int&); 00085 00086 void set_display(const bool&); 00087 00088 virtual void set_default(void); 00089 00090 // Mathematical model 00091 00092 virtual Matrix<double> calculate_solutions(const NeuralNetwork&) const; 00093 00094 virtual Vector<double> calculate_final_solutions(const NeuralNetwork&) const; 00095 00096 virtual Matrix<double> calculate_dependent_variables(const NeuralNetwork&, const Matrix<double>&) const; 00097 00098 00099 // Serialization methods 00100 00101 virtual std::string to_string(void) const; 00102 00103 void print(void) const; 00104 00105 virtual TiXmlElement* to_XML(void) const; 00106 virtual void from_XML(TiXmlElement*); 00107 00108 void save(const std::string&) const; 00109 void load(const std::string&); 00110 00111 virtual void save_data(const NeuralNetwork&, const std::string&) const; 00112 00113 protected: 00114 00116 00117 unsigned int independent_variables_number; 00118 00120 00121 unsigned int dependent_variables_number; 00122 00124 00125 bool display; 00126 }; 00127 00128 } 00129 00130 #endif 00131 00132 00133 // OpenNN: Open Neural Networks Library. 00134 // Copyright (C) 2005-2012 Roberto Lopez 00135 // 00136 // This library is free software; you can redistribute it and/or 00137 // modify it under the terms of the GNU Lesser General Public 00138 // License as published by the Free Software Foundation; either 00139 // version 2.1 of the License, or any later version. 00140 // 00141 // This library is distributed in the hope that it will be useful, 00142 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00143 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00144 // Lesser General Public License for more details. 00145 00146 // You should have received a copy of the GNU Lesser General Public 00147 // License along with this library; if not, write to the Free Software 00148 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA