OpenNN
2.2
Open Neural Networks Library
|
#include <ordinary_differential_equations.h>
Public Types | |
enum | SolutionMethod { RungeKutta, RungeKuttaFehlberg } |
Public Member Functions | |
OrdinaryDifferentialEquations (void) | |
OrdinaryDifferentialEquations (const tinyxml2::XMLDocument &) | |
OrdinaryDifferentialEquations (const std::string &) | |
OrdinaryDifferentialEquations (const OrdinaryDifferentialEquations &) | |
virtual | ~OrdinaryDifferentialEquations (void) |
OrdinaryDifferentialEquations & | operator= (const OrdinaryDifferentialEquations &) |
bool | operator== (const OrdinaryDifferentialEquations &) const |
const double & | get_initial_independent_variable (void) const |
const double & | get_final_independent_variable (void) const |
const Vector< double > & | get_initial_dependent_variables (void) const |
const double & | get_initial_dependent_variable (const size_t &) const |
const SolutionMethod & | get_solution_method (void) const |
std::string | write_solution_method (void) const |
const size_t & | get_points_number (void) const |
const double & | get_tolerance (void) const |
const size_t & | get_initial_size (void) const |
const size_t & | get_warning_size (void) const |
const size_t & | get_error_size (void) const |
void | set (const OrdinaryDifferentialEquations &) |
void | set_initial_independent_variable (const double &) |
void | set_final_independent_variable (const double &) |
void | set_initial_dependent_variables (const Vector< double > &) |
void | set_initial_dependent_variable (const size_t &, const double &) |
void | set_solution_method (const SolutionMethod &) |
void | set_solution_method (const std::string &) |
void | set_points_number (const size_t &) |
void | set_tolerance (const double &) |
void | set_initial_size (const size_t &) |
void | set_warning_size (const size_t &) |
void | set_error_size (const size_t &) |
virtual void | set_default (void) |
virtual Vector< double > | calculate_dependent_variables_dots (const NeuralNetwork &, const Vector< double > &) const =0 |
Matrix< double > | calculate_Runge_Kutta_solution (const NeuralNetwork &) const |
Vector< double > | calculate_Runge_Kutta_final_solution (const NeuralNetwork &) const |
Matrix< double > | calculate_Runge_Kutta_Fehlberg_solution (const NeuralNetwork &) const |
Vector< double > | calculate_Runge_Kutta_Fehlberg_final_solution (const NeuralNetwork &) const |
virtual Matrix< double > | calculate_solutions (const NeuralNetwork &) const |
virtual Vector< double > | calculate_final_solutions (const NeuralNetwork &) const |
std::string | to_string (void) const |
virtual tinyxml2::XMLDocument * | to_XML (void) const |
virtual void | from_XML (const tinyxml2::XMLDocument &) |
virtual void | save_data (const NeuralNetwork &, const std::string &) const |
Public Member Functions inherited from OpenNN::MathematicalModel | |
MathematicalModel (void) | |
MathematicalModel (const tinyxml2::XMLDocument &) | |
MathematicalModel (const std::string &) | |
MathematicalModel (const MathematicalModel &) | |
virtual | ~MathematicalModel (void) |
virtual MathematicalModel & | operator= (const MathematicalModel &) |
virtual bool | operator== (const MathematicalModel &) const |
const size_t & | get_independent_variables_number (void) const |
const size_t & | get_dependent_variables_number (void) const |
size_t | count_variables_number (void) const |
const bool & | get_display (void) const |
void | set (const MathematicalModel &) |
void | set_independent_variables_number (const size_t &) |
void | set_dependent_variables_number (const size_t &) |
void | set_display (const bool &) |
virtual Matrix< double > | calculate_dependent_variables (const NeuralNetwork &, const Matrix< double > &) const |
void | print (void) const |
void | save (const std::string &) const |
void | load (const std::string &) |
Protected Attributes | |
double | initial_independent_variable |
double | final_independent_variable |
Vector< double > | initial_dependent_variables |
SolutionMethod | solution_method |
size_t | points_number |
double | tolerance |
size_t | initial_size |
size_t | warning_size |
size_t | error_size |
Protected Attributes inherited from OpenNN::MathematicalModel | |
size_t | independent_variables_number |
size_t | dependent_variables_number |
bool | display |
This class represents the concept of a mathematical model defined by ordinary differential equations. A mathematical model is the base for learning in some types of problems, such as optimal control and inverse problems.
Definition at line 47 of file ordinary_differential_equations.h.
|
explicit |
Default constructor. It constructs a default ordinary differential equations object.
Definition at line 26 of file ordinary_differential_equations.cpp.
|
explicit |
XML constructor. It creates a ordinary differential equations mathematical modeel and loads its members from a TinyXML document.
ordinary_differential_equations_document | XML document containing the member data. |
Definition at line 38 of file ordinary_differential_equations.cpp.
|
explicit |
File constructor. It creates an ordinary differential equations mathematical model and loads its members from a XML file.
file_name | Name of XML file. |
Definition at line 51 of file ordinary_differential_equations.cpp.
OpenNN::OrdinaryDifferentialEquations::OrdinaryDifferentialEquations | ( | const OrdinaryDifferentialEquations & | other_ordinary_differential_equations | ) |
Copy constructor. It creates an ordinary differential equations mathematical model object and copies its members from another object.
other_ordinary_differential_equations | Ordinary differential equations object to be copied. |
Definition at line 64 of file ordinary_differential_equations.cpp.
|
virtual |
Destructor. It does not delete any object.
Definition at line 76 of file ordinary_differential_equations.cpp.
|
virtual |
This virtual method returns the final solutions of the mathematical model, which are given by the final independent and dependent variables. Needs to be derived, otherwise an exception is thrown.
Reimplemented from OpenNN::MathematicalModel.
Definition at line 1115 of file ordinary_differential_equations.cpp.
Vector< double > OpenNN::OrdinaryDifferentialEquations::calculate_Runge_Kutta_Fehlberg_final_solution | ( | const NeuralNetwork & | neural_network | ) | const |
This method calculate the numerical solution of the ordinary differential equations model using the Runge-Kutta-Fehlberg method.
neural_network | Neural network which represents the external inputs to the mathematical model. |
Definition at line 884 of file ordinary_differential_equations.cpp.
Matrix< double > OpenNN::OrdinaryDifferentialEquations::calculate_Runge_Kutta_Fehlberg_solution | ( | const NeuralNetwork & | neural_network | ) | const |
This method calculate the numerical solution of the ordinary differential equations model using the Runge-Kutta method.
neural_network | Neural network which represents the external inputs to the mathematical model. |
Definition at line 648 of file ordinary_differential_equations.cpp.
Vector< double > OpenNN::OrdinaryDifferentialEquations::calculate_Runge_Kutta_final_solution | ( | const NeuralNetwork & | neural_network | ) | const |
This method calculate the solution at the final independent variable of the ordinary differential equations model using the Runge-Kutta method.
neural_network | Neural network which represents the external inputs to the mathematical model. |
Definition at line 558 of file ordinary_differential_equations.cpp.
Matrix< double > OpenNN::OrdinaryDifferentialEquations::calculate_Runge_Kutta_solution | ( | const NeuralNetwork & | neural_network | ) | const |
This method calculate the numerical solution of the ordinary differential equations model using the Runge-Kutta method.
neural_network | Neural network which represents the external inputs to the mathematical model. |
Definition at line 466 of file ordinary_differential_equations.cpp.
|
virtual |
This virtual method returns the solutions to the mathematical model, which are given by the independent and the dependent variables. Needs to be derived, otherwise an exception is thrown.
Reimplemented from OpenNN::MathematicalModel.
Definition at line 1082 of file ordinary_differential_equations.cpp.
|
virtual |
Deserializes a TinyXML document into this ordinary differential equations object.
document | TinyXML document containing the member data. |
Reimplemented from OpenNN::MathematicalModel.
Definition at line 1337 of file ordinary_differential_equations.cpp.
const double & OpenNN::OrdinaryDifferentialEquations::get_initial_dependent_variable | ( | const size_t & | i | ) | const |
Returns the initial value of a single independent variable.
i | Index of dependent variable. |
Definition at line 163 of file ordinary_differential_equations.cpp.
OrdinaryDifferentialEquations & OpenNN::OrdinaryDifferentialEquations::operator= | ( | const OrdinaryDifferentialEquations & | other_ordinary_differential_equations | ) |
Assignment operator. It assigns to this object the members of an existing ordinary differential equations object.
other_ordinary_differential_equations | Ordinary differential equations object to be assigned. |
Definition at line 89 of file ordinary_differential_equations.cpp.
bool OpenNN::OrdinaryDifferentialEquations::operator== | ( | const OrdinaryDifferentialEquations & | other_ordinary_differential_equations | ) | const |
Equal to operator. It compares this object with another object of the same class. It returns true if the members of the two objects have the same values, and false otherwise.
other_ordinary_differential_equations | Object to be compared with. |
Definition at line 111 of file ordinary_differential_equations.cpp.
|
virtual |
Saves the solution data of an ordinary differential equation to a data file.
neural_network | Neural network which represents the external inputs to the mathematical model. |
file_name | Name of solution data file. |
Reimplemented from OpenNN::MathematicalModel.
Definition at line 1596 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set | ( | const OrdinaryDifferentialEquations & | other_ordinary_differential_equations | ) |
Sets the members of this object to be the members of another object of the same class.
other_ordinary_differential_equations | Object to be copied. |
Definition at line 261 of file ordinary_differential_equations.cpp.
|
virtual |
Sets the following default values:
Reimplemented from OpenNN::MathematicalModel.
Definition at line 441 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_error_size | ( | const size_t & | new_error_size | ) |
Sets the error size for the solution in the Runge-Kutta-Fehlberg method.
new_error_size | Error solution size. |
Definition at line 420 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_final_independent_variable | ( | const double & | new_final_independent_variable | ) |
Sets the final value for the independent variable.
new_final_independent_variable | Final value for the independent variable. |
Definition at line 301 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_initial_dependent_variable | ( | const size_t & | i, |
const double & | new_initial_dependent_variable | ||
) |
Sets the initial value for a single dependent variable.
i | Index of dependent variable. |
new_initial_dependent_variable | Initial value for the corresponding dependent variable. |
Definition at line 324 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_initial_dependent_variables | ( | const Vector< double > & | new_initial_dependent_variables | ) |
Sets the initial values for the dependent variables.
new_initial_dependent_variables | Initial values for the dependent variables. |
Definition at line 312 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_initial_independent_variable | ( | const double & | new_initial_independent_variable | ) |
Sets the initial value for the independent variable.
new_initial_independent_variable | Initial value for the independent variable. |
Definition at line 290 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_initial_size | ( | const size_t & | new_initial_size | ) |
Sets the initial size for the solution in the Runge-Kutta-Fehlberg method.
new_initial_size | Initial solution size. |
Definition at line 398 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_points_number | ( | const size_t & | new_points_number | ) |
Sets the number of points in the Runge-Kutta method.
new_points_number | Number of points. |
Definition at line 376 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_solution_method | ( | const SolutionMethod & | new_solution_method | ) |
Sets the numerical method for calculating the solution to the ordinary differential equations. Available methos include the Runge-Kutta and Runge-Kutta-Fehlber methods.
new_solution_method | Solution method. |
Definition at line 336 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_solution_method | ( | const std::string & | new_solution_method | ) |
Sets the numerical method for calculating the solution to the ordinary differential equations. Available methos include the Runge-Kutta and Runge-Kutta-Fehlber methods.
new_solution_method | String with the name of the solution method ("RungeKutta" or "RungeKuttaFehlberg"). |
Definition at line 348 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_tolerance | ( | const double & | new_tolerance | ) |
Sets the tolerance in the Runge-Kutta-Fehlberg method.
new_tolerance | Tolerance value. |
Definition at line 387 of file ordinary_differential_equations.cpp.
void OpenNN::OrdinaryDifferentialEquations::set_warning_size | ( | const size_t & | new_warning_size | ) |
Sets a warning size for the solution in the Runge-Kutta-Fehlberg method.
new_warning_size | Warning solution size. |
Definition at line 409 of file ordinary_differential_equations.cpp.
|
virtual |
Serializes the ordinary differential equations object into a XML document of the TinyXML library. See the OpenNN manual for more information about the format of this document.
Reimplemented from OpenNN::MathematicalModel.
Definition at line 1177 of file ordinary_differential_equations.cpp.