00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* OpenNN: Open Neural Networks Library */ 00004 /* www.opennn.cimne.com */ 00005 /* */ 00006 /* P L U G - I N 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 __PLUGIN_H__ 00018 #define __PLUGIN_H__ 00019 00020 // OpenNN includes 00021 00022 #include "mathematical_model.h" 00023 #include "../neural_network/neural_network.h" 00024 00025 #include "../utilities/vector.h" 00026 #include "../utilities/matrix.h" 00027 00028 namespace OpenNN 00029 { 00030 00034 00035 class PlugIn : public MathematicalModel 00036 { 00037 00038 public: 00039 00040 // DEFAULT CONSTRUCTOR 00041 00042 explicit PlugIn(void); 00043 00044 // XML CONSTRUCTOR 00045 00046 explicit PlugIn(TiXmlElement*); 00047 00048 // DESTRUCTOR 00049 00050 virtual ~PlugIn(void); 00051 00052 // ENUMERATIONS 00053 00055 00056 enum InputMethod{IndependentParametersInput}; 00057 00058 // ASSIGNMENT OPERATOR 00059 00060 PlugIn& operator = (const PlugIn&); 00061 00062 // EQUAL TO OPERATOR 00063 00064 bool operator == (const PlugIn&) const; 00065 00066 // METHODS 00067 00068 // Get methods 00069 00070 const InputMethod& get_input_method(void) const; 00071 std::string write_input_method(void) const; 00072 00073 const std::string& get_template_filename(void) const; 00074 const std::string& get_input_filename(void) const; 00075 00076 const std::string& get_script_filename(void) const; 00077 00078 const std::string& get_output_filename(void) const; 00079 00080 const Vector<std::string>& get_input_flags(void) const; 00081 const std::string& get_input_flag(const unsigned int&) const; 00082 00083 // Set methods 00084 00085 void set_default(void); 00086 00087 void set_input_method(const InputMethod&); 00088 void set_input_method(const std::string&); 00089 00090 void set_template_filename(const std::string&); 00091 void set_input_filename(const std::string&); 00092 00093 void set_script_filename(const std::string&); 00094 00095 void set_output_filename(const std::string&); 00096 00097 void set_input_flags(const Vector<std::string>&); 00098 00099 // Plug-In methods 00100 00101 void write_input_file(const NeuralNetwork&) const; 00102 void write_input_file_independent_parameters(const NeuralNetwork&) const; 00103 00104 void run_script(void) const; 00105 00106 Matrix<double> read_output_file(void) const; 00107 00108 Matrix<double> read_output_file_header(void) const; 00109 00110 Matrix<double> calculate_solutions(const NeuralNetwork&) const; 00111 00112 // Serialization methods 00113 00114 std::string to_string(void) const; 00115 00116 TiXmlElement* to_XML(void) const; 00117 void from_XML(TiXmlElement*); 00118 00119 //TiXmlElement* get_output_data_XML(const Matrix<double>&) const; 00120 00121 00122 private: 00123 00125 00126 InputMethod input_method; 00127 00129 00130 std::string template_filename; 00131 00133 00134 std::string input_filename; 00135 00137 00138 std::string script_filename; 00139 00141 00142 std::string output_filename; 00143 00145 00146 Vector<std::string> input_flags; 00147 00149 00150 unsigned int output_rows_number; 00151 00153 00154 unsigned int output_columns_number; 00155 }; 00156 00157 } 00158 00159 #endif 00160 00161 00162 // OpenNN: Open Neural Networks Library. 00163 // Copyright (C) 2005-2012 Roberto Lopez 00164 // 00165 // This library is free software; you can redistribute it and/or 00166 // modify it under the terms of the GNU Lesser General Public 00167 // License as published by the Free Software Foundation; either 00168 // version 2.1 of the License, or any later version. 00169 // 00170 // This library is distributed in the hope that it will be useful, 00171 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00172 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00173 // Lesser General Public License for more details. 00174 00175 // You should have received a copy of the GNU Lesser General Public 00176 // License along with this library; if not, write to the Free Software 00177 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA