OpenNN  2.2
Open Neural Networks Library
independent_parameters.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* I N D E P E N D E N T P A R A M E T E R 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 __INDEPENDENTPARAMETERS_H__
15 #define __INDEPENDENTPARAMETERS_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 
36 namespace OpenNN
37 {
38 
42 
44 {
45 
46 public:
47 
48  // DEFAULT CONSTRUCTOR
49 
50  explicit IndependentParameters(void);
51 
52  // INDEPENDENT PARAMETERS NUMBER CONSTRUCTOR
53 
54  explicit IndependentParameters(const size_t&);
55 
56  // INDEPENDENT PARAMETERS CONSTRUCTOR
57 
58  //explicit IndependentParameters(const Vector<double>&);
59 
60  // COPY CONSTRUCTOR
61 
63 
64  // DESTRUCTOR
65 
66  virtual ~IndependentParameters(void);
67 
68  // ASSIGNMENT OPERATOR
69 
71 
72  // EQUAL TO OPERATOR
73 
74  bool operator == (const IndependentParameters&) const;
75 
76  // ENUMERATIONS
77 
79 
80  enum ScalingMethod{NoScaling, MeanStandardDeviation, MinimumMaximum};
81 
83 
84  enum BoundingMethod{NoBounding, Bounding};
85 
86  // GET METHODS
87 
88  // Independent parameters
89 
92 
93  inline size_t get_parameters_number(void) const
94  {
95  return(parameters.size());
96  }
97 
98  const Vector<double>& get_parameters(void) const;
99  double get_parameter(const size_t&) const;
100 
101  // Independent parameters information
102 
103  const Vector<std::string>& get_names(void) const;
104  const std::string& get_name(const size_t&) const;
105 
106  const Vector<std::string>& get_units(void) const;
107  const std::string& get_unit(const size_t&) const;
108 
109  const Vector<std::string>& get_descriptions(void) const;
110  const std::string& get_description(const size_t&) const;
111 
112  // Independent parameters statistics
113 
114  const Vector<double>& get_minimums(void) const;
115  double get_minimum(const size_t&) const;
116 
117  const Vector<double>& get_maximums(void) const;
118  double get_maximum(const size_t&) const;
119 
120  const Vector<double>& get_means(void) const;
121  double get_mean(const size_t&) const;
122 
123  const Vector<double>& get_standard_deviations(void) const;
124  double get_standard_deviation(const size_t&) const;
125 
126  // Independent parameters scaling and unscaling
127 
128  const ScalingMethod& get_scaling_method(void) const;
129  std::string write_scaling_method(void) const;
130 
131  // Independent parameters bounds
132 
133  const Vector<double>& get_lower_bounds(void) const;
134  double get_lower_bound(const size_t&) const;
135 
136  const Vector<double>& get_upper_bounds(void) const;
137  double get_upper_bound(const size_t&) const;
138 
140 
141  const BoundingMethod& get_bounding_method(void) const;
142  std::string write_bounding_method(void) const;
143 
144  // Display messages
145 
146  const bool& get_display(void) const;
147 
148  // SET METHODS
149 
150  void set(void);
151  void set(const size_t&);
152  void set(const Vector<double>&);
153  void set(const IndependentParameters&);
154 
155  virtual void set_default(void);
156 
157  // Independent parameters
158 
159  void set_parameters_number(const size_t&);
160 
161  void set_parameters(const Vector<double>&);
162  void set_parameter(const size_t&, const double&);
163 
164  // Independent parameters information
165 
166  void set_names(const Vector<std::string>&);
167  void set_name(const size_t&, const std::string&);
168 
169  void set_units(const Vector<std::string>&);
170  void set_unit(const size_t&, const std::string&);
171 
173  void set_description(const size_t&, const std::string&);
174 
175  // Independent parameters statistics
176 
177  void set_minimums(const Vector<double>&);
178  void set_minimum(const size_t&, const double&);
179 
180  void set_maximums(const Vector<double>&);
181  void set_maximum(const size_t&, const double&);
182 
183  void set_means(const Vector<double>&);
184  void set_mean(const size_t&, const double&);
185 
187  void set_standard_deviation(const size_t&, const double&);
188 
189  // Independent parameters scaling and unscaling
190 
191  void set_scaling_method(const ScalingMethod&);
192  void set_scaling_method(const std::string&);
193 
194  // Independent parameters bounds
195 
196  void set_lower_bounds(void);
197  void set_lower_bounds(const Vector<double>&);
198  void set_lower_bound(const size_t&, const double&);
199 
200  void set_upper_bounds(void);
201  void set_upper_bounds(const Vector<double>&);
202  void set_upper_bound(const size_t&, const double&);
203 
204  void set_bounds(void);
205  void set_bounds(const Vector< Vector<double> >&);
206 
207  void set_bounding_method(const BoundingMethod&);
208  void set_bounding_method(const std::string&);
209 
210  // Display messages
211 
212  void set_display(const bool&);
213 
214  // Check methods
215 
216  bool is_empty(void) const;
217 
218  // Independent parameters initialization methods
219 
220  void initialize_random(void);
221 
222  void initialize_parameters(const double&);
223 
224  void randomize_parameters_uniform(void);
225  void randomize_parameters_uniform(const double&, const double&);
228 
229  void randomize_parameters_normal(void);
230  void randomize_parameters_normal(const double&, const double&);
233 
234  // Parameters norm
235 
236  //double calculate_parameters_norm(void) const;
237 
238  // Independent parameters
239 
241  void unscale_parameters(const Vector<double>&);
242 
243  void bound_parameters(void);
244  void bound_parameter(const size_t&);
245 
246  // Information
247 
249 
250  //void set_information(const Vector< Vector<std::string> >&);
251 
252  // Statistics
253 
255 
258 
259  void set_statistics(const Vector< Vector<double> >&);
262 
263  // Serialization methods
264 
265  std::string to_string(void) const;
266 
267  tinyxml2::XMLDocument* to_XML(void) const;
268  void from_XML(const tinyxml2::XMLDocument&);
269 
270 protected:
271 
272  // MEMBERS
273 
275 
277 
279 
281 
283 
285 
287 
289 
291 
293 
295 
297 
299 
301 
303 
305 
307 
309 
311 
313 
315 
317 
319 
321 
323 
325 
327 
328  bool display;
329 };
330 
331 }
332 
333 #endif
334 
335 
336 // OpenNN: Open Neural Networks Library.
337 // Copyright (c) 2005-2015 Roberto Lopez.
338 //
339 // This library is free software; you can redistribute it and/or
340 // modify it under the terms of the GNU Lesser General Public
341 // License as published by the Free Software Foundation; either
342 // version 2.1 of the License, or any later version.
343 //
344 // This library is distributed in the hope that it will be useful,
345 // but WITHOUT ANY WARRANTY; without even the implied warranty of
346 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
347 // Lesser General Public License for more details.
348 
349 // You should have received a copy of the GNU Lesser General Public
350 // License along with this library; if not, write to the Free Software
351 
352 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
353 
double get_maximum(const size_t &) const
void set_means_standard_deviations(const Vector< Vector< double > > &)
void set_means(const Vector< double > &)
const std::string & get_description(const size_t &) const
const Vector< double > & get_lower_bounds(void) const
const bool & get_display(void) const
const ScalingMethod & get_scaling_method(void) const
Returns the method used for scaling and unscaling the independent parameters.
Vector< std::string > units
Units of independent parameters.
void set_minimums_maximums(const Vector< Vector< double > > &)
ScalingMethod
Enumeration of available methods for scaling and unscaling the independent parameters.
double get_upper_bound(const size_t &) const
void set_maximum(const size_t &, const double &)
void from_XML(const tinyxml2::XMLDocument &)
size_t get_parameters_number(void) const
Vector< double > means
Mean of independent parameters.
bool display
Display messages to screen.
void set_units(const Vector< std::string > &)
const Vector< double > & get_parameters(void) const
Returns the values of the independent parameters.
void set_scaling_method(const ScalingMethod &)
const Vector< double > & get_maximums(void) const
Vector< double > minimums
Minimum of independent parameters.
Vector< Vector< double > * > get_bounds(void)
bool display_range_warning
Display warnings when the the independent parameters fall outside their minimum-maximum range...
void set_lower_bound(const size_t &, const double &)
Vector< double > standard_deviations
Standard deviation of independent parameters.
Vector< Vector< std::string > > arrange_information(void)
Vector< double > upper_bounds
Upper bound of independent parameters.
virtual void set_default(void)
Sets the members of this object to their default values.
const Vector< std::string > & get_names(void) const
BoundingMethod
Enumeration of available methods for bounding the independent parameters.
void set_upper_bounds(void)
Sets the vector of upper bounds for the independent parameters to have size zero. ...
void set_descriptions(const Vector< std::string > &)
void set_bounding_method(const BoundingMethod &)
std::string write_scaling_method(void) const
Returns a string with the method used for scaling and unscaling the independent parameters.
void set_standard_deviation(const size_t &, const double &)
void set_unit(const size_t &, const std::string &)
double get_lower_bound(const size_t &) const
void unscale_parameters(const Vector< double > &)
const std::string & get_unit(const size_t &) const
tinyxml2::XMLDocument * to_XML(void) const
double get_minimum(const size_t &) const
Vector< double > maximums
Maximum of independent parameters.
void set_minimum(const size_t &, const double &)
const Vector< std::string > & get_units(void) const
const Vector< double > & get_means(void) const
const BoundingMethod & get_bounding_method(void) const
Returns the method used for bounding the independent parameters.
void set_minimums(const Vector< double > &)
Vector< Vector< double > > arrange_means_standard_deviations(void)
void set_upper_bound(const size_t &, const double &)
std::string write_bounding_method(void) const
Returns a string with the method used for bounding the independent parameters.
void set_bounds(void)
Sets the vectors of lower and upper bounds for the independent parameters to have size zero...
void randomize_parameters_uniform(void)
Initializes the independent parameters with values comprised between -1 and +1.
double get_parameter(const size_t &) const
void set_parameters(const Vector< double > &)
bool is_empty(void) const
Returns true if the number of parameters is zero, and false otherwise.
void set_name(const size_t &, const std::string &)
const Vector< double > & get_standard_deviations(void) const
BoundingMethod bounding_method
Independent parameters bounding method.
void set_statistics(const Vector< Vector< double > > &)
Vector< Vector< double > > arrange_statistics(void)
void set_maximums(const Vector< double > &)
double get_mean(const size_t &) const
void set_parameter(const size_t &, const double &)
void set_names(const Vector< std::string > &)
void set_mean(const size_t &, const double &)
Vector< double > parameters
Independent parameters.
const std::string & get_name(const size_t &) const
std::string to_string(void) const
Returns a string representation of the current independent parameters object.
ScalingMethod scaling_method
Independent parameters scaling and unscaling method.
Vector< Vector< double > > arrange_minimums_maximums(void)
Vector< double > lower_bounds
Lower bound of independent parameters.
void set_lower_bounds(void)
Sets the lower bound of the independent parameters to an empty vector.
Vector< std::string > descriptions
Description of independent parameters.
bool operator==(const IndependentParameters &) const
Vector< double > calculate_scaled_parameters(void) const
double get_standard_deviation(const size_t &) const
void bound_parameters(void)
Makes the independent parameters to fall in the range defined by their lower and the upper bounds...
const Vector< std::string > & get_descriptions(void) const
const Vector< double > & get_upper_bounds(void) const
Vector< std::string > names
Name of independent parameters.
void set_description(const size_t &, const std::string &)
const Vector< double > & get_minimums(void) const
void set_standard_deviations(const Vector< double > &)
IndependentParameters & operator=(const IndependentParameters &)