OpenNN  2.2
Open Neural Networks Library
Public Types | Public Member Functions | Protected Attributes | List of all members
OpenNN::OrdinaryDifferentialEquations Class Referenceabstract

#include <ordinary_differential_equations.h>

Inheritance diagram for OpenNN::OrdinaryDifferentialEquations:
OpenNN::MathematicalModel

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)
 
OrdinaryDifferentialEquationsoperator= (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 SolutionMethodget_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 MathematicalModeloperator= (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
 

Detailed Description

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.

Constructor & Destructor Documentation

OpenNN::OrdinaryDifferentialEquations::OrdinaryDifferentialEquations ( void  )
explicit

Default constructor. It constructs a default ordinary differential equations object.

Definition at line 26 of file ordinary_differential_equations.cpp.

OpenNN::OrdinaryDifferentialEquations::OrdinaryDifferentialEquations ( const tinyxml2::XMLDocument &  ordinary_differential_equations_document)
explicit

XML constructor. It creates a ordinary differential equations mathematical modeel and loads its members from a TinyXML document.

Parameters
ordinary_differential_equations_documentXML document containing the member data.

Definition at line 38 of file ordinary_differential_equations.cpp.

OpenNN::OrdinaryDifferentialEquations::OrdinaryDifferentialEquations ( const std::string &  file_name)
explicit

File constructor. It creates an ordinary differential equations mathematical model and loads its members from a XML file.

Parameters
file_nameName 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.

Parameters
other_ordinary_differential_equationsOrdinary differential equations object to be copied.

Definition at line 64 of file ordinary_differential_equations.cpp.

OpenNN::OrdinaryDifferentialEquations::~OrdinaryDifferentialEquations ( void  )
virtual

Destructor. It does not delete any object.

Definition at line 76 of file ordinary_differential_equations.cpp.

Member Function Documentation

Vector< double > OpenNN::OrdinaryDifferentialEquations::calculate_final_solutions ( const NeuralNetwork ) const
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.

Parameters
neural_networkNeural 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.

Parameters
neural_networkNeural 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.

Parameters
neural_networkNeural 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.

Parameters
neural_networkNeural network which represents the external inputs to the mathematical model.

Definition at line 466 of file ordinary_differential_equations.cpp.

Matrix< double > OpenNN::OrdinaryDifferentialEquations::calculate_solutions ( const NeuralNetwork ) const
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.

void OpenNN::OrdinaryDifferentialEquations::from_XML ( const tinyxml2::XMLDocument &  document)
virtual

Deserializes a TinyXML document into this ordinary differential equations object.

Parameters
documentTinyXML 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.

Parameters
iIndex 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.

Parameters
other_ordinary_differential_equationsOrdinary 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.

Parameters
other_ordinary_differential_equationsObject to be compared with.

Definition at line 111 of file ordinary_differential_equations.cpp.

void OpenNN::OrdinaryDifferentialEquations::save_data ( const NeuralNetwork neural_network,
const std::string &  file_name 
) const
virtual

Saves the solution data of an ordinary differential equation to a data file.

Parameters
neural_networkNeural network which represents the external inputs to the mathematical model.
file_nameName 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.

Parameters
other_ordinary_differential_equationsObject to be copied.

Definition at line 261 of file ordinary_differential_equations.cpp.

void OpenNN::OrdinaryDifferentialEquations::set_default ( void  )
virtual

Sets the following default values:

  • Independent variables number: 1.
  • Dependent variables number: 0.
  • Solution method: Runge-Kutta-Fehlberg.
  • Points number: 101.
  • Tolerance: 1e-6
  • Initial size: 1e3.
  • Warning size: 1e6.
  • Error size: 1e9.
  • Display: True.

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.

Parameters
new_error_sizeError 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.

Parameters
new_final_independent_variableFinal 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.

Parameters
iIndex of dependent variable.
new_initial_dependent_variableInitial 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.

Parameters
new_initial_dependent_variablesInitial 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.

Parameters
new_initial_independent_variableInitial 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.

Parameters
new_initial_sizeInitial 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.

Parameters
new_points_numberNumber 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.

Parameters
new_solution_methodSolution 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.

Parameters
new_solution_methodString 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.

Parameters
new_toleranceTolerance 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.

Parameters
new_warning_sizeWarning solution size.

Definition at line 409 of file ordinary_differential_equations.cpp.

tinyxml2::XMLDocument * OpenNN::OrdinaryDifferentialEquations::to_XML ( void  ) const
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.


The documentation for this class was generated from the following files: