OpenNN  2.2
Open Neural Networks Library
inputs.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* I N P U T S 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 __INPUTS_H__
15 #define __INPUTS_H__
16 
17 // System includes
18 
19 #include <cmath>
20 #include <cstdlib>
21 #include <fstream>
22 #include <iostream>
23 #include <string>
24 #include <sstream>
25 
26 // OpenNN includes
27 
28 #include "vector.h"
29 #include "matrix.h"
30 
31 // TinyXml includes
32 
33 #include "../tinyxml2/tinyxml2.h"
34 
35 namespace OpenNN
36 {
37 
40 
41 class Inputs
42 {
43 
44 public:
45 
46  // DEFAULT CONSTRUCTOR
47 
48  explicit Inputs(void);
49 
50  // INPUTS NUMBER CONSTRUCTOR
51 
52  explicit Inputs(const size_t&);
53 
54  // XML CONSTRUCTOR
55 
56  explicit Inputs(const tinyxml2::XMLDocument&);
57 
58 
59  // COPY CONSTRUCTOR
60 
61  Inputs(const Inputs&);
62 
63  // DESTRUCTOR
64 
65  virtual ~Inputs(void);
66 
67  // ASSIGNMENT OPERATOR
68 
69  Inputs& operator = (const Inputs&);
70 
71  // EQUAL TO OPERATOR
72 
73  bool operator == (const Inputs&) const;
74 
78 
79  struct Item
80  {
82  std::string name;
83 
85 
86  std::string units;
87 
89 
90  std::string description;
91 
93 
94  Item(void) {}
95  };
96 
97  // METHOD
98 
99  bool is_empty(void) const;
100 
102 
103  inline size_t get_inputs_number(void) const
104  {
105  return(items.size());
106  }
107 
108  // Inputs information
109 
111  const std::string& get_name(const size_t&) const;
112 
114  const std::string& get_unit(const size_t&) const;
115 
117  const std::string& get_description(const size_t&) const;
118 
119  // Variables
120 
122 
123 
124  // Display messages
125 
126  const bool& get_display(void) const;
127 
128  // SET METHODS
129 
130  void set(void);
131  void set(const size_t&);
132  void set(const Vector< Vector<std::string> >&);
133  void set(const Inputs&);
134 
135  void set_inputs_number(const size_t&);
136 
137  virtual void set_default(void);
138 
139  // Input variables information
140 
141  void set_names(const Vector<std::string>&);
142  void set_name(const size_t&, const std::string&);
143 
144  void set_units(const Vector<std::string>&);
145  void set_unit(const size_t&, const std::string&);
146 
148  void set_description(const size_t&, const std::string&);
149 
150  // Variables
151 
153 
154  void set_display(const bool&);
155 
156  // Growing and pruning
157 
158  void grow_input(void);
159 
160  void prune_input(const size_t&);
161 
162  // Default names
163 
165 
166  // Serialization methods
167 
168  std::string to_string(void) const;
169 
170  virtual tinyxml2::XMLDocument* to_XML(void) const;
171  virtual void from_XML(const tinyxml2::XMLDocument&);
172 
173 protected:
174 
175  // MEMBERS
176 
178 
180 
182 
183  bool display;
184 };
185 
186 }
187 
188 #endif
189 
190 
191 // OpenNN: Open Neural Networks Library.
192 // Copyright (c) 2005-2015 Roberto Lopez.
193 //
194 // This library is free software; you can redistribute it and/or
195 // modify it under the terms of the GNU Lesser General Public
196 // License as published by the Free Software Foundation; either
197 // version 2.1 of the License, or any later version.
198 //
199 // This library is distributed in the hope that it will be useful,
200 // but WITHOUT ANY WARRANTY; without even the implied warranty of
201 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
202 // Lesser General Public License for more details.
203 
204 // You should have received a copy of the GNU Lesser General Public
205 // License along with this library; if not, write to the Free Software
206 
207 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
208 
void set_units(const Vector< std::string > &)
Definition: inputs.cpp:520
std::string description
Description of output variable.
Definition: inputs.h:90
void set_descriptions(const Vector< std::string > &)
Definition: inputs.cpp:592
const std::string & get_description(const size_t &) const
Definition: inputs.cpp:270
size_t get_inputs_number(void) const
Returns the number of inputs in the multilayer perceptron.
Definition: inputs.h:103
void set_names(const Vector< std::string > &)
Definition: inputs.cpp:448
virtual void set_default(void)
Sets the members of this object to their default values.
Definition: inputs.cpp:422
Matrix< std::string > arrange_information(void) const
Definition: inputs.cpp:302
virtual ~Inputs(void)
Destructor.
Definition: inputs.cpp:73
void set(void)
Definition: inputs.cpp:335
std::string units
Units of output variable.
Definition: inputs.h:86
Vector< std::string > arrange_descriptions(void) const
Definition: inputs.cpp:249
Vector< Item > items
Input variables.
Definition: inputs.h:179
void grow_input(void)
Appends a new item to the inputs.
Definition: inputs.cpp:720
void set_name(const size_t &, const std::string &)
Definition: inputs.cpp:487
Inputs(void)
Definition: inputs.cpp:26
std::string to_string(void) const
Returns a string representation of the current inputs object.
Definition: inputs.cpp:791
virtual void from_XML(const tinyxml2::XMLDocument &)
Definition: inputs.cpp:899
virtual tinyxml2::XMLDocument * to_XML(void) const
Definition: inputs.cpp:819
void set_information(const Matrix< std::string > &)
Definition: inputs.cpp:670
const std::string & get_unit(const size_t &) const
Definition: inputs.cpp:219
bool display
Display messages to screen.
Definition: inputs.h:183
const bool & get_display(void) const
Definition: inputs.cpp:324
std::string name
Name of output variable.
Definition: inputs.h:82
bool operator==(const Inputs &) const
Definition: inputs.cpp:109
Inputs & operator=(const Inputs &)
Definition: inputs.cpp:84
Vector< std::string > arrange_units(void) const
Definition: inputs.cpp:198
Vector< std::string > arrange_names(void) const
Definition: inputs.cpp:147
void set_display(const bool &)
Definition: inputs.cpp:710
void set_unit(const size_t &, const std::string &)
Definition: inputs.cpp:559
Item(void)
Default constructor.
Definition: inputs.h:94
void set_description(const size_t &, const std::string &)
Definition: inputs.cpp:632
void set_inputs_number(const size_t &)
Definition: inputs.cpp:412
bool is_empty(void) const
Returns true if the number of inputs is zero, and false otherwise.
Definition: inputs.cpp:127
void prune_input(const size_t &)
Definition: inputs.cpp:733
Vector< std::string > write_default_names(void) const
Definition: inputs.cpp:767
const std::string & get_name(const size_t &) const
Definition: inputs.cpp:168