16 #include "mathematical_model.h"
42 from_XML(mathematical_model_document);
68 set(other_mathematical_model);
90 if(
this != &other_mathematical_model)
243 std::ostringstream buffer;
245 buffer <<
"OpenNN Exception: MathematicalModel class.\n"
246 <<
"Matrix<double> calculate_solutions(const NeuralNetwork&) const method.\n"
247 <<
"This method has not been derived.\n";
249 throw std::logic_error(buffer.str());
261 std::ostringstream buffer;
263 buffer <<
"OpenNN Exception: MathematicalModel class.\n"
264 <<
"Vector<double> calculate_final_solutions(const NeuralNetwork&) const method.\n"
265 <<
"This method has not been derived.\n";
267 throw std::logic_error(buffer.str());
278 std::ostringstream buffer;
280 buffer <<
"OpenNN Exception: MathematicalModel class.\n"
281 <<
"Matrix<double> calculate_dependent_variables(const NeuralNetwork&, const Matrix<double>&) const method.\n"
282 <<
"This method has not been derived.\n";
284 throw std::logic_error(buffer.str());
294 std::ostringstream buffer;
296 buffer <<
"Mathematical model\n"
299 <<
"Display: " <<
display <<
"\n";
301 return(buffer.str());
323 tinyxml2::XMLDocument* document =
new tinyxml2::XMLDocument;
325 std::ostringstream buffer;
327 tinyxml2::XMLElement* mathematical_model_element = document->NewElement(
"MathematicalModel");
329 document->InsertFirstChild(mathematical_model_element);
333 tinyxml2::XMLElement* independent_variables_number_element = document->NewElement(
"IndependentVariablesNumber");
334 mathematical_model_element->LinkEndChild(independent_variables_number_element);
339 tinyxml2::XMLText* independent_variables_number_text = document->NewText(buffer.str().c_str());
340 independent_variables_number_element->LinkEndChild(independent_variables_number_text);
345 tinyxml2::XMLElement* dependent_variables_number_element = document->NewElement(
"DependentVariablesNumber");
346 mathematical_model_element->LinkEndChild(dependent_variables_number_element);
351 tinyxml2::XMLText* dependent_variables_number_text = document->NewText(buffer.str().c_str());
352 dependent_variables_number_element->LinkEndChild(dependent_variables_number_text);
357 tinyxml2::XMLElement* display_element = document->NewElement(
"Display");
358 mathematical_model_element->LinkEndChild(display_element);
363 tinyxml2::XMLText* display_text = document->NewText(buffer.str().c_str());
364 display_element->LinkEndChild(display_text);
378 const tinyxml2::XMLElement* root_element = document.FirstChildElement(
"MathematicalModel");
380 std::ostringstream buffer;
384 buffer <<
"OpenNN Exception: MathematicalModel class.\n"
385 <<
"void from_XML(const tinyxml2::XMLDocument&) method.\n"
386 <<
"Unkown root element.\n";
388 throw std::logic_error(buffer.str());
393 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"IndependentVariablesNumber");
397 const char* text = element->GetText();
405 catch(
const std::logic_error& e)
407 std::cout << e.what() << std::endl;
415 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"DependentVariablesNumber");
419 const char* text = element->GetText();
427 catch(
const std::logic_error& e)
429 std::cout << e.what() << std::endl;
437 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"Display");
441 const char* text = element->GetText();
447 const std::string string(text);
451 catch(
const std::logic_error& e)
453 std::cout << e.what() << std::endl;
468 tinyxml2::XMLDocument* document =
to_XML();
470 document->SaveFile(file_name.c_str());
483 std::ostringstream buffer;
485 tinyxml2::XMLDocument document;
487 if(document.LoadFile(file_name.c_str()))
489 buffer <<
"OpenNN Exception: MathematicalModel class.\n"
490 <<
"void load(const std::string&) method.\n"
491 <<
"Cannot load XML file " << file_name <<
".\n";
493 throw std::logic_error(buffer.str());
506 std::ostringstream buffer;
508 buffer <<
"OpenNN Exception: MathematicalModel class.\n"
509 <<
"void save_data(const NeuralNetwork&, const std::string&) const method.\n"
510 <<
"This method has not been derived.\n";
512 throw std::logic_error(buffer.str());
virtual Matrix< double > calculate_solutions(const NeuralNetwork &) const
void print(void) const
This method outputs to the console the string representation of the mathematical model.
virtual void from_XML(const tinyxml2::XMLDocument &)
const size_t & get_independent_variables_number(void) const
Returns the number of independent variables in the mathematical model.
void set(const MathematicalModel &)
virtual bool operator==(const MathematicalModel &) const
const size_t & get_dependent_variables_number(void) const
Returns the number of dependent variables in the mathematical model.
size_t count_variables_number(void) const
virtual tinyxml2::XMLDocument * to_XML(void) const
const bool & get_display(void) const
virtual Vector< double > calculate_final_solutions(const NeuralNetwork &) const
void set_display(const bool &)
void save(const std::string &) const
virtual MathematicalModel & operator=(const MathematicalModel &)
virtual std::string to_string(void) const
Returns a string representation of the current mathematical model object.
virtual void set_default(void)
virtual void save_data(const NeuralNetwork &, const std::string &) const
size_t dependent_variables_number
Number of dependent variables defining the mathematical model.
bool display
Flag for displaying warnings.
void set_dependent_variables_number(const size_t &)
virtual Matrix< double > calculate_dependent_variables(const NeuralNetwork &, const Matrix< double > &) const
size_t independent_variables_number
Number of independent variables defining the mathematical model.
void load(const std::string &)
virtual ~MathematicalModel(void)
void set_independent_variables_number(const size_t &)