OpenNN  2.2
Open Neural Networks Library
plug_in.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* P L U G - I N C L A S S H E A D E R */
7 /* */
8 /* Roberto Lopez */
9 /* Artelnics - Making intelligent use of data */
11 /* */
12 /****************************************************************************************************************/
13 
14 #ifndef __PLUGIN_H__
15 #define __PLUGIN_H__
16 
17 // System includes
18 
19 #include<fstream>
20 #include<iostream>
21 #include<string>
22 #include<sstream>
23 #include <time.h>
24 
25 // OpenNN includes
26 
27 #include "vector.h"
28 #include "matrix.h"
29 
30 #include "mathematical_model.h"
31 #include "neural_network.h"
32 
33 namespace OpenNN
34 {
35 
39 
40 class PlugIn : public MathematicalModel
41 {
42 
43 public:
44 
45  // DEFAULT CONSTRUCTOR
46 
47  explicit PlugIn(void);
48 
49  // XML CONSTRUCTOR
50 
51  explicit PlugIn(const tinyxml2::XMLDocument&);
52 
53  // DESTRUCTOR
54 
55  virtual ~PlugIn(void);
56 
57  // ENUMERATIONS
58 
60 
61  enum InputMethod{IndependentParametersInput};
62 
63  // ASSIGNMENT OPERATOR
64 
65  PlugIn& operator = (const PlugIn&);
66 
67  // EQUAL TO OPERATOR
68 
69  bool operator == (const PlugIn&) const;
70 
71  // METHODS
72 
73  // Get methods
74 
75  const InputMethod& get_input_method(void) const;
76  std::string write_input_method(void) const;
77 
78  const std::string& get_template_file_name(void) const;
79  const std::string& get_input_file_name(void) const;
80 
81  const std::string& get_script_file_name(void) const;
82 
83  const std::string& get_output_file_name(void) const;
84 
85  const Vector<std::string>& get_input_flags(void) const;
86  const std::string& get_input_flag(const size_t&) const;
87 
88  // Set methods
89 
90  void set_default(void);
91 
92  void set_input_method(const InputMethod&);
93  void set_input_method(const std::string&);
94 
95  void set_template_file_name(const std::string&);
96  void set_input_file_name(const std::string&);
97 
98  void set_script_file_name(const std::string&);
99 
100  void set_output_file_name(const std::string&);
101 
103 
104  // Plug-In methods
105 
106  void write_input_file(const NeuralNetwork&) const;
108 
109  void run_script(void) const;
110 
111  Matrix<double> read_output_file(void) const;
112 
114 
116 
117  // Serialization methods
118 
119  std::string to_string(void) const;
120 
121  tinyxml2::XMLDocument* to_XML(void) const;
122  void from_XML(const tinyxml2::XMLDocument&);
123 
124  //tinyxml2::XMLElement* get_output_data_XML(const Matrix<double>&) const;
125 
126 
127 private:
128 
130 
132 
134 
135  std::string template_file_name;
136 
138 
139  std::string input_file_name;
140 
142 
143  std::string script_file_name;
144 
146 
147  std::string output_file_name;
148 
150 
152 
154 
156 
158 
160 };
161 
162 }
163 
164 #endif
165 
166 
167 // OpenNN: Open Neural Networks Library.
168 // Copyright (c) 2005-2015 Roberto Lopez.
169 //
170 // This library is free software; you can redistribute it and/or
171 // modify it under the terms of the GNU Lesser General Public
172 // License as published by the Free Software Foundation; either
173 // version 2.1 of the License, or any later version.
174 //
175 // This library is distributed in the hope that it will be useful,
176 // but WITHOUT ANY WARRANTY; without even the implied warranty of
177 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
178 // Lesser General Public License for more details.
179 
180 // You should have received a copy of the GNU Lesser General Public
181 // License along with this library; if not, write to the Free Software
182 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
void set_script_file_name(const std::string &)
Definition: plug_in.cpp:304
void set_input_file_name(const std::string &)
Definition: plug_in.cpp:293
const std::string & get_output_file_name(void) const
Returns the name of the output file.
Definition: plug_in.cpp:189
const std::string & get_input_file_name(void) const
Returns the name of the input file.
Definition: plug_in.cpp:169
InputMethod input_method
Type of data to be entered in the mathematical model.
Definition: plug_in.h:131
size_t output_columns_number
Number of columns in the output file.
Definition: plug_in.h:159
const InputMethod & get_input_method(void) const
Returns the method for including the information into the input file.
Definition: plug_in.cpp:120
const std::string & get_input_flag(const size_t &) const
Definition: plug_in.cpp:210
InputMethod
Enumeration of available methods for introducing neural network data into the input file...
Definition: plug_in.h:61
void set_input_flags(const Vector< std::string > &)
Definition: plug_in.cpp:326
const std::string & get_script_file_name(void) const
Returns the name of the script file.
Definition: plug_in.cpp:179
void write_input_file(const NeuralNetwork &) const
Definition: plug_in.cpp:337
const std::string & get_template_file_name(void) const
Returns the name of the template file.
Definition: plug_in.cpp:159
bool operator==(const PlugIn &) const
Definition: plug_in.cpp:94
Matrix< double > read_output_file_header(void) const
Definition: plug_in.cpp:510
void write_input_file_independent_parameters(const NeuralNetwork &) const
Definition: plug_in.cpp:366
virtual ~PlugIn(void)
Definition: plug_in.cpp:49
PlugIn(void)
Definition: plug_in.cpp:26
std::string write_input_method(void) const
Returns a string with the name of the method for including the information into the input file...
Definition: plug_in.cpp:130
std::string output_file_name
Name of output file.
Definition: plug_in.h:147
std::string script_file_name
Name of script file.
Definition: plug_in.h:143
std::string template_file_name
Name of template file.
Definition: plug_in.h:135
void set_output_file_name(const std::string &)
Definition: plug_in.cpp:315
Matrix< double > calculate_solutions(const NeuralNetwork &) const
Definition: plug_in.cpp:551
Vector< std::string > input_flags
Vector of flags in the input file.
Definition: plug_in.h:151
const Vector< std::string > & get_input_flags(void) const
Returns the vector of input file flags.
Definition: plug_in.cpp:199
void set_input_method(const InputMethod &)
Definition: plug_in.cpp:247
std::string to_string(void) const
Returns a string representation of the current plug-in object.
Definition: plug_in.cpp:565
std::string input_file_name
Name of input file.
Definition: plug_in.h:139
Matrix< double > read_output_file(void) const
Definition: plug_in.cpp:497
size_t output_rows_number
Number of rows in the output file.
Definition: plug_in.h:155
PlugIn & operator=(const PlugIn &)
Definition: plug_in.cpp:62
void set_default(void)
Definition: plug_in.cpp:227
tinyxml2::XMLDocument * to_XML(void) const
Definition: plug_in.cpp:591
void from_XML(const tinyxml2::XMLDocument &)
Definition: plug_in.cpp:741
void set_template_file_name(const std::string &)
Definition: plug_in.cpp:282
void run_script(void) const
This method runs the script needed for executing the mathematical model.
Definition: plug_in.cpp:468