16 #include "final_solutions_error.h"
77 :
PerformanceTerm(new_neural_network_pointer, new_mathematical_model_pointer)
99 from_XML(final_state_error_document);
151 if(
this != &other_final_solutions_error)
391 std::ostringstream buffer;
397 buffer <<
"OpenNN Exception: FinalSolutionsError class.\n"
398 <<
"void check(void) const method.\n"
399 <<
"Pointer to neural network is NULL.\n";
401 throw std::logic_error(buffer.str());
406 if(!multilayer_perceptron_pointer)
408 buffer <<
"OpenNN Exception: FinalSolutionsError class.\n"
409 <<
"void check(void) const method.\n"
410 <<
"Pointer to multilayer perceptron is NULL.\n";
412 throw std::logic_error(buffer.str());
418 if(inputs_number == 0)
420 buffer <<
"OpenNN Exception: FinalSolutionsError class.\n"
421 <<
"void check(void) const method.\n"
422 <<
"Number of inputs in multilayer perceptron object is zero.\n";
424 throw std::logic_error(buffer.str());
427 if(outputs_number == 0)
429 buffer <<
"OpenNN Exception: FinalSolutionsError class.\n"
430 <<
"void check(void) const method.\n"
431 <<
"Number of outputs in multilayer perceptron object is zero.\n";
433 throw std::logic_error(buffer.str());
440 buffer <<
"OpenNN Exception: FinalSolutionsError class.\n"
441 <<
"void check(void) const method.\n"
442 <<
"Pointer to mathematical model is NULL.\n";
444 throw std::logic_error(buffer.str());
453 if(target_final_solutions_size != dependent_variables_number)
455 std::ostringstream buffer;
457 buffer <<
"OpenNN Exception: FinalSolutionsError class." << std::endl
458 <<
"double calculate_performance(void) const method." << std::endl
459 <<
"Size of target final solutions must be equal to number of dependent variables." << std::endl;
461 throw std::logic_error(buffer.str());
486 const Vector<double> dependent_variables_final_solutions = final_solutions.
take_out(independent_variables_number, dependent_variables_number);
508 return(
"FINAL_SOLUTIONS_ERROR");
516 std::ostringstream buffer;
523 const Vector<double> dependent_variables_final_solutions = final_solutions.
take_out(independent_variables_number, dependent_variables_number);
529 buffer <<
"Final solutions error\n"
530 <<
"Target final solutions: " << target_final_solutions <<
"\n"
531 <<
"Final solutions: " << dependent_variables_final_solutions <<
"\n"
532 <<
"performance: " << performance <<
"\n";
534 return(buffer.str());
544 std::ostringstream buffer;
546 tinyxml2::XMLDocument* document =
new tinyxml2::XMLDocument;
550 tinyxml2::XMLElement* final_solutions_error_element = document->NewElement(
"FinalSolutionsError");
552 document->InsertFirstChild(final_solutions_error_element);
562 final_solutions_error_element->LinkEndChild(element);
569 tinyxml2::XMLElement* element = document->NewElement(
"FinalSolutionsErrorsWeights");
570 final_solutions_error_element->LinkEndChild(element);
575 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
576 element->LinkEndChild(text);
581 tinyxml2::XMLElement* element = document->NewElement(
"TargetFinalSolution");
582 final_solutions_error_element->LinkEndChild(element);
587 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
588 element->LinkEndChild(text);
593 tinyxml2::XMLElement* display_element = document->NewElement(
"Display");
594 final_solutions_error_element->LinkEndChild(display_element);
599 tinyxml2::XMLText* display_text = document->NewText(buffer.str().c_str());
600 display_element->LinkEndChild(display_text);
614 const tinyxml2::XMLElement* root_element = document.FirstChildElement(
"FinalSolutionsError");
618 std::ostringstream buffer;
620 buffer <<
"OpenNN Exception: FinalSolutionsError class.\n"
621 <<
"void from_XML(const tinyxml2::XMLDocument&) method.\n"
622 <<
"Final solutions error element is NULL.\n";
624 throw std::logic_error(buffer.str());
629 const tinyxml2::XMLElement* display_element = root_element->FirstChildElement(
"Display");
633 const std::string new_display_string = display_element->GetText();
639 catch(
const std::logic_error& e)
641 std::cout << e.what() << std::endl;
void set_final_solution_error_weight(const size_t &, const double &)
const Vector< double > & get_target_final_solutions(void) const
Returns the desired final state of each dependent variable.
virtual ~FinalSolutionsError(void)
Destructor.
Vector< T > take_out(const size_t &, const size_t &) const
double calculate_performance(void) const
Returns the performance value of the performance term.
size_t get_inputs_number(void) const
Returns the number of inputs to the multilayer perceptron.
void set(void)
Sets the size of a vector to zero.
Vector< double > target_final_solutions
size_t get_outputs_number(void) const
Returns the number of outputs neurons in the multilayer perceptron.
const size_t & get_independent_variables_number(void) const
Returns the number of independent variables in the mathematical model.
Vector< double > final_solutions_errors_weights
FinalSolutionsError(void)
const size_t & get_dependent_variables_number(void) const
Returns the number of dependent variables in the mathematical model.
std::string write_performance_term_type(void) const
Returns a string with the name of the final solutions error performance type, "FINAL_SOLUTIONS_ERROR"...
const Vector< double > & get_final_solutions_errors_weights(void) const
Returns the weight values for each error in the final solutions.
MultilayerPerceptron * get_multilayer_perceptron_pointer(void) const
Returns a pointer to the multilayer perceptron composing this neural network.
virtual Vector< double > calculate_final_solutions(const NeuralNetwork &) const
void set_mathematical_model_pointer(MathematicalModel *)
void set_target_final_solutions(const Vector< double > &)
FinalSolutionsError & operator=(const FinalSolutionsError &)
Assignment operator.
void set_target_final_solution(const size_t &, const double &)
void from_XML(const tinyxml2::XMLDocument &)
bool operator==(const FinalSolutionsError &) const
tinyxml2::XMLDocument * to_XML(void) const
Returns a representation of the sum squared error object, in XML format.
std::string write_information(void) const
tinyxml2::XMLDocument * to_XML(void) const
Serializes this numerical differentiation object into a XML document->
void set_final_solutions_errors_weights(const Vector< double > &)