41 set(new_inputs_number);
86 if(
this != &other_inputs)
131 if(inputs_number == 0)
153 for(
size_t i = 0; i < inputs_number; i++)
155 names[i] =
items[i].name;
176 if(i >= inputs_number)
178 std::ostringstream buffer;
180 buffer <<
"OpenNN Exception: Inputs class.\n"
181 <<
"const std::string get_name(const size_t&) const method.\n"
182 <<
"Input variable index must be less than number of inputs.\n";
184 throw std::logic_error(buffer.str());
189 return(
items[i].name);
204 for(
size_t i = 0; i < inputs_number; i++)
206 units[i] =
items[i].units;
227 if(index >= inputs_number)
229 std::ostringstream buffer;
231 buffer <<
"OpenNN Exception: Inputs class.\n"
232 <<
"const std::string get_unit(const size_t&) const method.\n"
233 <<
"Index of input variable must be less than number of inputs.\n";
235 throw std::logic_error(buffer.str());
240 return(
items[index].units);
255 for(
size_t i = 0; i < inputs_number; i++)
257 descriptions[i] =
items[i].description;
260 return(descriptions);
278 if(index >= inputs_number)
280 std::ostringstream buffer;
282 buffer <<
"OpenNN Exception: Inputs class.\n"
283 <<
"const std::string& get_description(const size_t&) const method.\n"
284 <<
"Index of input variable must be less than number of inputs.\n";
286 throw std::logic_error(buffer.str());
291 return(
items[index].description);
308 for(
size_t i = 0; i < inputs_number; i++)
310 information(i,0) =
items[i].name;
311 information(i,1) =
items[i].units;
312 information(i,2) =
items[i].description;
386 const size_t new_inputs_information_size = new_inputs_information.size();
388 if(new_inputs_information_size != 3)
390 std::ostringstream buffer;
392 buffer <<
"OpenNN Exception: Inputs class.\n"
393 <<
"void set(const Vector< Vector<std::string> >&) method.\n"
394 <<
"Size of inputs information must be three.\n";
396 throw std::logic_error(buffer.str());
414 items.set(new_inputs_number);
424 std::ostringstream buffer;
428 for(
size_t i = 0; i < inputs_number; i++)
431 buffer <<
"input_" << i+1;
433 items[i].name = buffer.str();
435 items[i].description =
"";
456 const size_t size = new_names.size();
458 if(size != inputs_number)
460 std::ostringstream buffer;
462 buffer <<
"OpenNN Exception: Inputs class.\n"
463 <<
"void set_names(const Vector<std::string>&) method.\n"
464 <<
"Size of name of input variables vector must be equal to number of inputs.\n";
466 throw std::logic_error(buffer.str());
473 for(
size_t i = 0; i < inputs_number; i++)
475 items[i].name = new_names[i];
495 if(i >= inputs_number)
497 std::ostringstream buffer;
499 buffer <<
"OpenNN Exception: Inputs class.\n"
500 <<
"void set_name(const size_t&, const std::string&) method.\n"
501 <<
"Index of input variable must be less than number of inputs.\n";
503 throw std::logic_error(buffer.str());
510 items[i].name = new_name;
528 const size_t size = new_units.size();
530 if(size != inputs_number)
532 std::ostringstream buffer;
534 buffer <<
"OpenNN Exception: Inputs class.\n"
535 <<
"void set_units(const Vector<std::string>&) method.\n"
536 <<
"Size must be equal to number of input variables.\n";
538 throw std::logic_error(buffer.str());
545 for(
size_t i = 0; i < inputs_number; i++)
547 items[i].units = new_units[i];
567 if(index >= inputs_number)
569 std::ostringstream buffer;
571 buffer <<
"OpenNN Exception: Inputs class.\n"
572 <<
"void set_unit(const size_t&, const std::string&) method.\n"
573 <<
"Index of input must be less than number of inputs.\n";
575 throw std::logic_error(buffer.str());
582 items[index].units = new_unit;
600 const size_t size = new_descriptions.size();
602 if(size != inputs_number)
604 std::ostringstream buffer;
606 buffer <<
"OpenNN Exception: Inputs class.\n"
607 <<
"void set_descriptions(const Vector<std::string>&) method.\n"
608 <<
"Size must be equal to number of input variables.\n";
610 throw std::logic_error(buffer.str());
617 for(
size_t i = 0; i < inputs_number; i++)
619 items[i].description = new_descriptions[i];
640 if(index >= inputs_number)
642 std::ostringstream buffer;
644 buffer <<
"OpenNN Exception: Inputs class.\n"
645 <<
"void set_description(const size_t&, const std::string&) method.\n"
646 <<
"Index of input variable must be less than number of inputs.\n";
648 throw std::logic_error(buffer.str());
655 items[index].description = new_description;
678 if(columns_number != 3)
680 std::ostringstream buffer;
682 buffer <<
"OpenNN Exception: Inputs class.\n"
683 <<
"void set_information(const Matrix<std::string>&) method.\n"
684 <<
"Number of columns in matrix must be 3.\n";
686 throw std::logic_error(buffer.str());
695 for(
size_t i = 0; i < inputs_number; i++)
697 items[i].name = new_information(i,0);
698 items[i].units = new_information(i,1);
699 items[i].description = new_information(i,2);
724 items.push_back(item);
741 if(index >= inputs_number)
743 std::ostringstream buffer;
745 buffer <<
"OpenNN Exception: Inputs class.\n"
746 <<
"void prune_input(const size_t&) method.\n"
747 <<
"Index of input is equal or greater than number of inputs.\n";
749 throw std::logic_error(buffer.str());
773 std::ostringstream buffer;
775 for(
size_t i = 0; i < inputs_number; i++)
778 buffer <<
"input_" << i+1;
780 default_names[i] = buffer.str();
783 return(default_names);
793 std::ostringstream buffer;
797 buffer <<
"Inputs\n";
800 for(
size_t i = 0; i < inputs_number; i++)
802 buffer <<
"Item " << i+1 <<
":\n"
803 <<
"Name:" <<
items[i].name <<
"\n"
804 <<
"Units:" <<
items[i].units <<
"\n"
805 <<
"Description:" <<
items[i].description <<
"\n";
808 buffer <<
"Display:" <<
display <<
"\n";
810 return(buffer.str());
821 tinyxml2::XMLDocument* document =
new tinyxml2::XMLDocument;
825 std::ostringstream buffer;
829 tinyxml2::XMLElement* inputsElement = document->NewElement(
"Inputs");
830 document->InsertFirstChild(inputsElement);
832 tinyxml2::XMLElement* element = NULL;
833 tinyxml2::XMLText* text = NULL;
837 element = document->NewElement(
"InputsNumber");
838 inputsElement->LinkEndChild(element);
841 buffer << inputs_number;
843 text = document->NewText(buffer.str().c_str());
844 element->LinkEndChild(text);
847 for(
size_t i = 0; i < inputs_number; i++)
849 element = document->NewElement(
"Item");
850 element->SetAttribute(
"Index", (
unsigned)i+1);
851 inputsElement->LinkEndChild(element);
855 tinyxml2::XMLElement* name_element = document->NewElement(
"Name");
856 element->LinkEndChild(name_element);
858 tinyxml2::XMLText* name_text = document->NewText(
items[i].name.c_str());
859 name_element->LinkEndChild(name_text);
863 tinyxml2::XMLElement* units_element = document->NewElement(
"Units");
864 element->LinkEndChild(units_element);
866 tinyxml2::XMLText* units_text = document->NewText(
items[i].units.c_str());
867 units_element->LinkEndChild(units_text);
871 tinyxml2::XMLElement* description_element = document->NewElement(
"Description");
872 element->LinkEndChild(description_element);
874 tinyxml2::XMLText* descriptionText = document->NewText(
items[i].description.c_str());
875 description_element->LinkEndChild(descriptionText);
880 tinyxml2::XMLElement* display_element = document->NewElement(
"Display");
881 inputsElement->LinkEndChild(display_element);
886 tinyxml2::XMLText* display_text = document->NewText(buffer.str().c_str());
887 display_element->LinkEndChild(display_text);
901 std::ostringstream buffer;
903 const tinyxml2::XMLElement* inputsElement = document.FirstChildElement(
"Inputs");
907 buffer <<
"OpenNN Exception: Inputs class.\n"
908 <<
"void from_XML(const tinyxml2::XMLDocument&) method.\n"
909 <<
"Inputs element is NULL.\n";
911 throw std::logic_error(buffer.str());
916 const tinyxml2::XMLElement* inputs_number_element = inputsElement->FirstChildElement(
"InputsNumber");
918 if(!inputs_number_element)
920 buffer <<
"OpenNN Exception: Inputs class.\n"
921 <<
"void from_XML(const tinyxml2::XMLDocument&) method.\n"
922 <<
"Inputs number element is NULL.\n";
924 throw std::logic_error(buffer.str());
927 const size_t inputs_number = atoi(inputs_number_element->GetText());
933 const tinyxml2::XMLElement* start_element = inputs_number_element;
935 for(
size_t i = 0; i < inputs_number; i++)
937 const tinyxml2::XMLElement* item_element = start_element->NextSiblingElement(
"Item");
938 start_element = item_element;
942 buffer <<
"OpenNN Exception: Inputs class.\n"
943 <<
"void from_XML(const tinyxml2::XMLElement*) method.\n"
944 <<
"Item " << i+1 <<
" is NULL.\n";
946 throw std::logic_error(buffer.str());
949 item_element->QueryUnsignedAttribute(
"Index", &index);
953 buffer <<
"OpenNN Exception: Inputs class.\n"
954 <<
"void from_XML(const tinyxml2::XMLElement*) method.\n"
955 <<
"Index " << index <<
" is not correct.\n";
957 throw std::logic_error(buffer.str());
962 const tinyxml2::XMLElement* name_element = item_element->FirstChildElement(
"Name");
966 buffer <<
"OpenNN Exception: Inputs class.\n"
967 <<
"void from_XML(const tinyxml2::XMLElement*) method.\n"
968 <<
"Pointer to name element is NULL.\n";
970 throw std::logic_error(buffer.str());
973 if(name_element->GetText())
975 items[index-1].name = name_element->GetText();
980 const tinyxml2::XMLElement* units_element = item_element->FirstChildElement(
"Units");
984 buffer <<
"OpenNN Exception: Inputs class.\n"
985 <<
"void from_XML(const tinyxml2::XMLElement*) method.\n"
986 <<
"Pointer to units element is NULL.\n";
988 throw std::logic_error(buffer.str());
991 if(units_element->GetText())
993 items[index-1].units = units_element->GetText();
998 const tinyxml2::XMLElement* description_element = item_element->FirstChildElement(
"Description");
1000 if(!description_element)
1002 buffer <<
"OpenNN Exception: Inputs class.\n"
1003 <<
"void from_XML(const tinyxml2::XMLElement*) method.\n"
1004 <<
"Pointer to description element is NULL.\n";
1006 throw std::logic_error(buffer.str());
1009 if(description_element->GetText())
1011 items[index-1].description = description_element->GetText();
const size_t & get_columns_number(void) const
Returns the number of columns in the matrix.