16 #include "independent_parameters.h"
43 set(new_parameters_number);
56 set(other_independent_parameters);
78 if(
this != &other_independent_parameters)
111 &&
names == other_independent_parameters.
names
112 &&
units == other_independent_parameters.
units
116 &&
means == other_independent_parameters.
means
158 if(index >= parameters_number)
160 std::ostringstream buffer;
162 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
163 <<
"double get_parameter(const size_t&) const method.\n"
164 <<
"Index of independent parameter must be less than number of parameters.\n";
166 throw std::logic_error(buffer.str());
200 if(index >= parameters_number)
202 std::ostringstream buffer;
204 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
205 <<
"const std::string& get_name(const size_t&) const method.\n"
206 <<
"Index of independent parameter must be less than number of parameters.\n";
208 throw std::logic_error(buffer.str());
213 return(
names[index]);
242 if(index >= parameters_number)
244 std::ostringstream buffer;
246 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
247 <<
"const std::string get_units(const size_t&) const method.\n"
248 <<
"Index of independent parameter must be less than number of parameters.\n";
250 throw std::logic_error(buffer.str());
255 return(
units[index]);
284 if(index >= parameters_number)
286 std::ostringstream buffer;
288 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
289 <<
"const std::string get_description(const size_t&) const method.\n"
290 <<
"Index of independent parameter must be less than number of parameters.\n";
292 throw std::logic_error(buffer.str());
315 information[0] =
names;
316 information[1] =
units;
348 if(index >= parameters_number)
350 std::ostringstream buffer;
352 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
353 <<
"double get_minimum(const size_t&) const method.\n"
354 <<
"Index of independent parameter must be less than number of parameters.\n";
356 throw std::logic_error(buffer.str());
391 if(index >= parameters_number)
393 std::ostringstream buffer;
395 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
396 <<
"double get_maximum(const size_t&) const method.\n"
397 <<
"Index must be less than number of parameters.\n";
399 throw std::logic_error(buffer.str());
433 if(index >= parameters_number)
435 std::ostringstream buffer;
437 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
438 <<
"double get_mean(const size_t&) const method.\n"
439 <<
"Index must be less than number of parameters.\n";
441 throw std::logic_error(buffer.str());
446 return(
means[index]);
475 if(index >= parameters_number)
477 std::ostringstream buffer;
479 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
480 <<
"double get_standard_deviation(const size_t&) const method.\n"
481 <<
"Index must be less than number of parameters.\n";
483 throw std::logic_error(buffer.str());
507 return(minimums_maximums);
522 means_standard_deviations[0] =
means;
525 return(means_standard_deviations);
540 statistics[2] =
means;
569 return(
"MinimumMaximum");
573 return(
"MeanStandardDeviation");
577 std::ostringstream buffer;
579 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
580 <<
"std::string write_scaling_method(void) const method.\n"
581 <<
"Unknown scaling and unscaling method.\n";
583 throw std::logic_error(buffer.str());
613 if(index >= parameters_number)
615 std::ostringstream buffer;
617 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
618 <<
"double get_lower_bound(const size_t&) const method.\n"
619 <<
"Index must be less than number of parameters.\n";
621 throw std::logic_error(buffer.str());
655 if(index >= parameters_number)
657 std::ostringstream buffer;
659 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
660 <<
"double get_upper_bound(const size_t&) const method.\n"
661 <<
"Index must be less than number of parameters.\n";
663 throw std::logic_error(buffer.str());
710 return(
"NoBounding");
718 std::ostringstream buffer;
720 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
721 <<
"std::string write_bounding_method(void) const method.\n"
722 <<
"Unknown bounding method.\n";
724 throw std::logic_error(buffer.str());
775 const size_t new_parameters_number = new_parameters.size();
853 means.
set(new_parameters_number, 0.0);
876 if(new_parameters.size() != parameters_number)
878 std::ostringstream buffer;
880 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
881 <<
"void set_parameters(const Vector<double>&) method.\n"
882 <<
"Parameters size must be equal to number of parameters.\n";
884 throw std::logic_error(buffer.str());
909 if(index >= parameters_number)
911 std::ostringstream buffer;
913 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
914 <<
"void set_parameter(const size_t&, const double&) method.\n"
915 <<
"Index must be less than number of parameters.\n";
917 throw std::logic_error(buffer.str());
942 if(new_names.size() != parameters_number)
944 std::ostringstream buffer;
946 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
947 <<
"void set_name(const Vector<std::string>&) method.\n"
948 <<
"Size of names must be equal to number of parameters.\n";
950 throw std::logic_error(buffer.str());
976 if(index >= parameters_number)
978 std::ostringstream buffer;
980 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
981 <<
"void set_name(const size_t&, const std::string&) method.\n"
982 <<
"Index must be less than number of parameters.\n";
984 throw std::logic_error(buffer.str());
989 if(
names.size() != parameters_number)
996 names[index] = new_name;
1014 if(new_units.size() != parameters_number)
1016 std::ostringstream buffer;
1018 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1019 <<
"void set_units(const Vector<std::string>&) method.\n"
1020 <<
"Size must be equal to number of parameters.\n";
1022 throw std::logic_error(buffer.str());
1048 if(index >= parameters_number)
1050 std::ostringstream buffer;
1052 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1053 <<
"void set_unit(const size_t&, const std::string&) method.\n"
1054 <<
"Index of independent parameter must be less than number of parameters.\n";
1056 throw std::logic_error(buffer.str());
1061 if(
units.size() == 0)
1068 units[index] = new_unit;
1086 if(new_descriptions.size() != parameters_number)
1088 std::ostringstream buffer;
1090 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1091 <<
"void set_descriptions(const Vector<std::string>&) method.\n"
1092 <<
"Size of descriptions must be equal to number of parameters.\n";
1094 throw std::logic_error(buffer.str());
1118 if(index >= parameters_number)
1120 std::ostringstream buffer;
1122 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1123 <<
"void set_description(const size_t&, const std::string&) method.\n"
1124 <<
"Index must be less than number of parameters.\n";
1126 throw std::logic_error(buffer.str());
1156 if(new_minimums.size() != parameters_number)
1158 std::ostringstream buffer;
1160 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1161 <<
"void set_minimums(const Vector<double>&) method.\n"
1162 <<
"Size of minimums must be equal to number of parameters.\n";
1164 throw std::logic_error(buffer.str());
1190 if(index >= parameters_number)
1192 std::ostringstream buffer;
1194 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1195 <<
"void set_minimum(const size_t&, const double&) method.\n"
1196 <<
"Index of independent parameter must be less than number of parameters.\n";
1198 throw std::logic_error(buffer.str());
1203 if(
minimums.size() != parameters_number)
1228 if(new_maximums.size() != parameters_number)
1230 std::ostringstream buffer;
1232 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1233 <<
"void set_maximum(const Vector<double>&) method.\n"
1234 <<
"Size of maximums must be equal to number of parameters.\n";
1236 throw std::logic_error(buffer.str());
1262 if(index >= parameters_number)
1264 std::ostringstream buffer;
1266 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1267 <<
"void set_maximum(const size_t&, const double&) method.\n"
1268 <<
"Index must be less than number of parameters.\n";
1270 throw std::logic_error(buffer.str());
1277 if(
maximums.size() != parameters_number)
1302 if(new_means.size() != parameters_number)
1304 std::ostringstream buffer;
1306 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1307 <<
"void set_means(const Vector<double>&) method.\n"
1308 <<
"Size must be equal to number of parameters.\n";
1310 throw std::logic_error(buffer.str());
1336 if(index >= parameters_number)
1338 std::ostringstream buffer;
1340 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1341 <<
"void set_mean(const size_t&, const double&) method.\n"
1342 <<
"Index of must be less than number of parameters.\n";
1344 throw std::logic_error(buffer.str());
1351 const size_t size =
means.size();
1353 if(size != parameters_number)
1360 means[index] = new_mean;
1378 if(new_standard_deviations.size() != parameters_number)
1380 std::ostringstream buffer;
1382 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1383 <<
"void set_standard_deviations(const Vector<double>&) method.\n"
1384 <<
"Size must be equal to number of parameters.\n";
1386 throw std::logic_error(buffer.str());
1412 if(index >= parameters_number)
1414 std::ostringstream buffer;
1416 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1417 <<
"void set_standard_deviation(const size_t&, const double&) method.\n"
1418 <<
"Index must be less than number of parameters.\n";
1420 throw std::logic_error(buffer.str());
1429 if(size != parameters_number)
1457 if(new_minimums_maximums.size() != 2)
1459 std::ostringstream buffer;
1461 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1462 <<
"void set_minimum_maximum(const Vector< Vector<double> >&) method.\n"
1463 <<
"Number of rows must be 2.\n";
1465 throw std::logic_error(buffer.str());
1467 else if(new_minimums_maximums[0].size() != parameters_number
1468 && new_minimums_maximums[1].size() != parameters_number)
1470 std::ostringstream buffer;
1472 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1473 <<
"void set_minimum_maximum(const Vector< Vector<double> >&) method.\n"
1474 <<
"Number of columns must be equal to number of parameters.\n";
1476 throw std::logic_error(buffer.str());
1481 for(
size_t i = 0; i < parameters_number; i++)
1483 if(new_minimums_maximums[0][i] >= new_minimums_maximums[1][i])
1485 std::ostringstream buffer;
1487 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1488 <<
"void set_minimums_maximums(const Vector< Vector<double> >&) method.\n"
1489 <<
"Minimum of parameter "<< i <<
" is equal or greater than maximum of that parameter.\n";
1491 throw std::logic_error(buffer.str());
1499 minimums = new_minimums_maximums[0];
1500 maximums = new_minimums_maximums[1];
1519 std::ostringstream buffer;
1523 const size_t size = new_means_standard_deviations.size();
1527 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1528 <<
"void set_means_standard_deviations(const Vector< Vector<double> >& ) method.\n"
1529 <<
"Number of rows must be 2.\n";
1531 throw std::logic_error(buffer.str());
1533 else if(new_means_standard_deviations[0].size() != parameters_number
1534 && new_means_standard_deviations[1].size() != parameters_number)
1536 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1537 <<
"void set_means_standard_deviations(const Vector< Vector<double> >& ) method.\n"
1538 <<
"Number of columns must be equal to number of parameters.\n";
1540 throw std::logic_error(buffer.str());
1547 for(
size_t i = 0; i < parameters_number; i++)
1549 if(new_means_standard_deviations[1][i] < 1.0e-99)
1551 std::ostringstream buffer;
1553 buffer <<
"OpenNN Exception: IndependentParameters class: \n"
1554 <<
"void set_means_standard_deviations(const Vector< Vector<double> >& ) method.\n"
1555 <<
"Standard deviation of independent parameter " << i <<
" is zero.\n";
1564 means = new_means_standard_deviations[0];
1587 if(new_statistics.size() != 4)
1589 std::ostringstream buffer;
1591 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1592 <<
"void set_statistics(const Vector< Vector<double> >&) method.\n"
1593 <<
"Size must be 6.\n";
1595 throw std::logic_error(buffer.str());
1619 scaling_method = new_scaling_method;
1631 if(new_scaling_method ==
"NoScaling")
1635 else if(new_scaling_method ==
"MeanStandardDeviation")
1639 else if(new_scaling_method ==
"MinimumMaximum")
1645 std::ostringstream buffer;
1647 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1648 <<
"void set_scaling_method(const std::string&) method.\n"
1649 <<
"Unknown independent parameters scaling method: " << new_scaling_method <<
".\n";
1651 throw std::logic_error(buffer.str());
1682 if(new_lower_bounds.size() != parameters_number)
1684 std::ostringstream buffer;
1686 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1687 <<
"void set_lower_bounds(const Vector<double>&) method.\n"
1688 <<
"Size must be equal to number of parameters.\n";
1690 throw std::logic_error(buffer.str());
1716 if(index >= parameters_number)
1718 std::ostringstream buffer;
1720 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1721 <<
"void set_lower_bound(const size_t&, const double&) method.\n"
1722 <<
"Index must be less than number of parameters.\n";
1724 throw std::logic_error(buffer.str());
1769 if(new_upper_bounds.size() != parameters_number)
1771 std::ostringstream buffer;
1773 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1774 <<
"void set_upper_bound(const Vector<double>&) method.\n"
1775 <<
"Size of upper bounds must be equal to number of parameters.\n";
1777 throw std::logic_error(buffer.str());
1801 if(index >= parameters_number)
1803 std::ostringstream buffer;
1805 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1806 <<
"void set_upper_bound(const size_t&, const double&) method.\n"
1807 <<
"Index must be less than number of parameters.\n";
1809 throw std::logic_error(buffer.str());
1847 if(new_bounds.size() != 2)
1849 std::ostringstream buffer;
1851 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1852 <<
"void set_bounds(const Vector< Vector<double> >&) method.\n"
1853 <<
"Number of rows must be 2.\n";
1855 throw std::logic_error(buffer.str());
1858 if(new_bounds[0].size() != parameters_number && new_bounds[1].size() != parameters_number)
1860 std::ostringstream buffer;
1862 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1863 <<
"void set_bounds(const Vector< Vector<double> >&) method.\n"
1864 <<
"Number of columns must be equal to number of parameters.\n";
1866 throw std::logic_error(buffer.str());
1886 bounding_method = new_bounding_method;
1898 if(new_bounding_method ==
"NoBounding")
1902 else if(new_bounding_method ==
"Bounding")
1908 std::ostringstream buffer;
1910 buffer <<
"OpenNN Exception: IndependentParameters class.\n"
1911 <<
"void set_bounding_method(const std::string&) method.\n"
1912 <<
"Unknown bounding method: " << new_bounding_method <<
".\n";
1914 throw std::logic_error(buffer.str());
2088 const size_t parameters_number = rand()%10 + 1;
2090 set(parameters_number);
2172 case MinimumMaximum:
2176 for(
size_t i = 0; i < parameters_number; i++)
2182 std::cout <<
"OpenNN Warning: IndependentParameters class.\n"
2183 <<
"Vector<double> calculate_scaled_parameters(void) const method.\n"
2184 <<
"Maximum and minimum of parameter " << i <<
" are equal.\n"
2185 <<
"That parameter won't be scaled.\n";
2196 return(scaled_parameters);
2200 case MeanStandardDeviation:
2204 for(
size_t i = 0; i < parameters_number; i++)
2210 std::cout <<
"OpenNN Warning: IndependentParameters class.\n"
2211 <<
"Vector<double> calculate_scaled_parameters(void) method.\n"
2212 <<
"Standard deviation of parameter " << i <<
" is zero.\n"
2213 <<
"That won't be unscaled.\n";
2224 return(scaled_parameters);
2230 std::ostringstream buffer;
2232 buffer <<
"OpenNN Exception: IndependentParameters class\n"
2233 <<
"Vector<double> calculate_scaled_parameters(void) method.\n"
2234 <<
"Unknown independent parameters scaling and unscaling method.\n";
2236 throw std::logic_error(buffer.str());
2260 case MeanStandardDeviation:
2262 for(
size_t i = 0; i < parameters_number; i++)
2268 std::cout <<
"OpenNN Warning: IndependentParameters class\n"
2269 <<
"void unscale_parameters(void) method.\n"
2270 <<
"Standard deviation of parameter " << i <<
" is zero.\n"
2271 <<
"That parameter won't be scaled.\n";
2284 case MinimumMaximum:
2286 for(
size_t i = 0; i < parameters_number; i++)
2292 std::cout <<
"OpenNN Warning: IndependentParameters class\n"
2293 <<
"void unscale_parameters(void) method.\n"
2294 <<
"Maximum and minimum of parameter " << i <<
" are equal.\n"
2295 <<
"That parameter won't be scaled.\n";
2310 std::ostringstream buffer;
2312 buffer <<
"OpenNN Exception: IndependentParameters class\n"
2313 <<
"void unscale_parameters(void) method.\n"
2314 <<
"Unknown scaling and unscaling method.\n";
2316 throw std::logic_error(buffer.str());
2336 if(lower_bounds_size == parameters_number && upper_bounds_size == parameters_number)
2340 else if(lower_bounds_size == parameters_number)
2344 else if(upper_bounds_size == parameters_number)
2392 std::ostringstream buffer;
2394 buffer <<
"Independent parameters\n"
2396 <<
"Names: " <<
names <<
"\n"
2397 <<
"Units: " <<
units <<
"\n"
2399 <<
"Minimums: " <<
minimums <<
"\n"
2400 <<
"Maximums: " <<
maximums <<
"\n"
2401 <<
"Means: " <<
means <<
"\n"
2408 <<
"Display: " <<
display <<
"\n";
2410 return(buffer.str());
2421 std::ostringstream buffer;
2423 tinyxml2::XMLDocument* document =
new tinyxml2::XMLDocument;
2425 tinyxml2::XMLElement* independent_parameters_element = document->NewElement(
"IndependentParameters");
2427 document->InsertFirstChild(independent_parameters_element);
2433 tinyxml2::XMLElement* parameters_element = document->NewElement(
"Parameters");
2434 independent_parameters_element->LinkEndChild(parameters_element);
2439 tinyxml2::XMLText* parameters_text = document->NewText(buffer.str().c_str());
2440 parameters_element->LinkEndChild(parameters_text);
2444 tinyxml2::XMLElement* names_element = document->NewElement(
"Names");
2445 independent_parameters_element->LinkEndChild(names_element);
2450 for(
size_t i = 0; i < parameters_number; i++)
2452 elements[i] = document->NewElement(
"Name");
2453 elements[i]->SetAttribute(
"Index", (
unsigned)i+1);
2454 names_element->LinkEndChild(elements[i]);
2456 texts[i] = document->NewText(
names[i].c_str());
2457 elements[i]->LinkEndChild(texts[i]);
2464 tinyxml2::XMLElement* units_element = document->NewElement(
"Units");
2465 independent_parameters_element->LinkEndChild(units_element);
2470 for(
size_t i = 0; i < parameters_number; i++)
2472 elements[i] = document->NewElement(
"Unit");
2473 elements[i]->SetAttribute(
"Index", (
unsigned)i+1);
2474 units_element->LinkEndChild(elements[i]);
2476 texts[i] = document->NewText(
units[i].c_str());
2477 elements[i]->LinkEndChild(texts[i]);
2483 tinyxml2::XMLElement* descriptions_element = document->NewElement(
"Descriptions");
2484 independent_parameters_element->LinkEndChild(descriptions_element);
2489 for(
size_t i = 0; i < parameters_number; i++)
2491 elements[i] = document->NewElement(
"Description");
2492 elements[i]->SetAttribute(
"Index", (
unsigned)i+1);
2493 descriptions_element->LinkEndChild(elements[i]);
2496 elements[i]->LinkEndChild(texts[i]);
2502 tinyxml2::XMLElement* element = document->NewElement(
"Minimums");
2503 independent_parameters_element->LinkEndChild(element);
2508 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
2509 element->LinkEndChild(text);
2515 tinyxml2::XMLElement* element = document->NewElement(
"Maximums");
2516 independent_parameters_element->LinkEndChild(element);
2521 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
2522 element->LinkEndChild(text);
2527 tinyxml2::XMLElement* element = document->NewElement(
"Means");
2528 independent_parameters_element->LinkEndChild(element);
2533 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
2534 element->LinkEndChild(text);
2540 tinyxml2::XMLElement* element = document->NewElement(
"StandardDeviations");
2541 independent_parameters_element->LinkEndChild(element);
2546 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
2547 element->LinkEndChild(text);
2552 tinyxml2::XMLElement* element = document->NewElement(
"LowerBounds");
2553 independent_parameters_element->LinkEndChild(element);
2558 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
2559 element->LinkEndChild(text);
2564 tinyxml2::XMLElement* element = document->NewElement(
"UpperBounds");
2565 independent_parameters_element->LinkEndChild(element);
2570 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
2571 element->LinkEndChild(text);
2576 tinyxml2::XMLElement* element = document->NewElement(
"ScalingMethod");
2577 independent_parameters_element->LinkEndChild(element);
2580 element->LinkEndChild(text);
2586 tinyxml2::XMLElement* element = document->NewElement(
"BoundingMethod");
2587 independent_parameters_element->LinkEndChild(element);
2590 element->LinkEndChild(text);
2595 tinyxml2::XMLElement* element = document->NewElement(
"DisplayRangeWarning");
2596 independent_parameters_element->LinkEndChild(element);
2601 tinyxml2::XMLText* text = document->NewText(buffer.str().c_str());
2602 element->LinkEndChild(text);
2607 tinyxml2::XMLElement* display_element = document->NewElement(
"Display");
2608 independent_parameters_element->LinkEndChild(display_element);
2613 tinyxml2::XMLText* display_text = document->NewText(buffer.str().c_str());
2614 display_element->LinkEndChild(display_text);
2634 const tinyxml2::XMLElement* parameters_element = document.FirstChildElement(
"Parameters");
2636 if(parameters_element)
2647 const tinyxml2::XMLElement* names_element = document.FirstChildElement(
"Names");
2653 const tinyxml2::XMLElement* name_element = names_element->FirstChildElement(
"Name");
2657 name_element->QueryIntAttribute(
"Index", &index);
2659 if(name_element->GetText())
2661 new_names[index-1] = name_element->GetText();
2664 for( ; name_element; name_element=name_element->NextSiblingElement())
2666 name_element->QueryIntAttribute(
"Index", &index);
2668 if(name_element->GetText())
2670 new_names[index-1] = name_element->GetText();
2679 catch(
const std::logic_error& e)
2681 std::cout << e.what() << std::endl;
2688 const tinyxml2::XMLElement* units_element = document.FirstChildElement(
"VariablesUnits");
2694 const tinyxml2::XMLElement* variable_units_element = units_element->FirstChildElement(
"VariableUnits");
2696 if(variable_units_element)
2698 variable_units_element->QueryIntAttribute(
"Index", &index);
2700 if(variable_units_element->GetText())
2702 new_units[index-1] = variable_units_element->GetText();
2705 for( ; variable_units_element; variable_units_element=variable_units_element->NextSiblingElement())
2707 variable_units_element->QueryIntAttribute(
"Index", &index);
2709 if(variable_units_element->GetText())
2711 new_units[index-1] = variable_units_element->GetText();
2720 catch(
const std::logic_error& e)
2722 std::cout << e.what() << std::endl;
2729 const tinyxml2::XMLElement* descriptions_element = document.FirstChildElement(
"Descriptions");
2731 if(descriptions_element)
2735 const tinyxml2::XMLElement* variable_description_element = descriptions_element->FirstChildElement(
"Description");
2737 if(variable_description_element)
2739 variable_description_element->QueryIntAttribute(
"Index", &index);
2741 if(variable_description_element->GetText())
2743 new_descriptions[index-1] = variable_description_element->GetText();
2746 for( ; variable_description_element; variable_description_element=variable_description_element->NextSiblingElement())
2748 variable_description_element->QueryIntAttribute(
"Index", &index);
2750 if(variable_description_element->GetText())
2752 new_descriptions[index-1] = variable_description_element->GetText();
2761 catch(
const std::logic_error& e)
2763 std::cout << e.what() << std::endl;
2770 const tinyxml2::XMLElement* minimums_element = document.FirstChildElement(
"Minimums");
2772 if(minimums_element)
2774 const char* minimums_text = minimums_element->GetText();
2779 new_minimums.
parse(minimums_text);
2785 catch(
const std::logic_error& e)
2787 std::cout << e.what() << std::endl;
2795 const tinyxml2::XMLElement* maximums_element = document.FirstChildElement(
"Maximums");
2797 if(maximums_element)
2799 const char* maximums_text = maximums_element->GetText();
2804 new_maximums.
parse(maximums_text);
2810 catch(
const std::logic_error& e)
2812 std::cout << e.what() << std::endl;
2820 const tinyxml2::XMLElement* means_element = document.FirstChildElement(
"Means");
2824 const char* means_text = means_element->GetText();
2829 new_means.
parse(means_text);
2835 catch(
const std::logic_error& e)
2837 std::cout << e.what() << std::endl;
2845 const tinyxml2::XMLElement* standard_deviations_element = document.FirstChildElement(
"StandardDeviations");
2847 if(standard_deviations_element)
2849 const char* standard_deviations_text = standard_deviations_element->GetText();
2851 if(standard_deviations_text)
2854 new_standard_deviations.
parse(standard_deviations_text);
2860 catch(
const std::logic_error& e)
2862 std::cout << e.what() << std::endl;
2870 const tinyxml2::XMLElement* lower_bounds_element = document.FirstChildElement(
"LowerBounds");
2872 if(lower_bounds_element)
2874 const char* lower_bounds_text = lower_bounds_element->GetText();
2876 if(lower_bounds_text)
2879 new_lower_bounds.
parse(lower_bounds_text);
2885 catch(
const std::logic_error& e)
2887 std::cout << e.what() << std::endl;
2895 const tinyxml2::XMLElement* upper_bounds_element = document.FirstChildElement(
"UpperBounds");
2897 if(upper_bounds_element)
2899 const char* upper_bounds_text = upper_bounds_element->GetText();
2901 if(upper_bounds_text)
2904 new_upper_bounds.
parse(upper_bounds_text);
2910 catch(
const std::logic_error& e)
2912 std::cout << e.what() << std::endl;
2920 const tinyxml2::XMLElement* display_element = document.FirstChildElement(
"Display");
2924 const std::string new_display_string = display_element->GetText();
2930 catch(
const std::logic_error& e)
2932 std::cout << e.what() << std::endl;
void parse(const std::string &)
double get_maximum(const size_t &) const
void set_means_standard_deviations(const Vector< Vector< double > > &)
void randomize_uniform(const double &=-1.0, const double &=1.0)
void set_means(const Vector< double > &)
const std::string & get_description(const size_t &) const
const Vector< double > & get_lower_bounds(void) const
const bool & get_display(void) const
const ScalingMethod & get_scaling_method(void) const
Returns the method used for scaling and unscaling the independent parameters.
Vector< std::string > units
Units of independent parameters.
void set_minimums_maximums(const Vector< Vector< double > > &)
void initialize(const T &)
void randomize_parameters_normal(void)
ScalingMethod
Enumeration of available methods for scaling and unscaling the independent parameters.
double get_upper_bound(const size_t &) const
void set_maximum(const size_t &, const double &)
void from_XML(const tinyxml2::XMLDocument &)
size_t get_parameters_number(void) const
Vector< double > means
Mean of independent parameters.
bool display
Display messages to screen.
void set_units(const Vector< std::string > &)
const Vector< double > & get_parameters(void) const
Returns the values of the independent parameters.
void set_scaling_method(const ScalingMethod &)
const Vector< double > & get_maximums(void) const
Vector< double > minimums
Minimum of independent parameters.
void set(void)
Sets the size of a vector to zero.
Vector< Vector< double > * > get_bounds(void)
bool display_range_warning
Display warnings when the the independent parameters fall outside their minimum-maximum range...
void set_lower_bound(const size_t &, const double &)
Vector< double > standard_deviations
Standard deviation of independent parameters.
Vector< Vector< std::string > > arrange_information(void)
Vector< double > upper_bounds
Upper bound of independent parameters.
virtual void set_default(void)
Sets the members of this object to their default values.
const Vector< std::string > & get_names(void) const
void set_parameters_number(const size_t &)
BoundingMethod
Enumeration of available methods for bounding the independent parameters.
void set_upper_bounds(void)
Sets the vector of upper bounds for the independent parameters to have size zero. ...
void set_descriptions(const Vector< std::string > &)
void set_bounding_method(const BoundingMethod &)
std::string write_scaling_method(void) const
Returns a string with the method used for scaling and unscaling the independent parameters.
void set_standard_deviation(const size_t &, const double &)
void apply_lower_bound(const T &)
void set_unit(const size_t &, const std::string &)
double get_lower_bound(const size_t &) const
void unscale_parameters(const Vector< double > &)
const std::string & get_unit(const size_t &) const
tinyxml2::XMLDocument * to_XML(void) const
double get_minimum(const size_t &) const
Vector< double > maximums
Maximum of independent parameters.
void set_minimum(const size_t &, const double &)
const Vector< std::string > & get_units(void) const
const Vector< double > & get_means(void) const
const BoundingMethod & get_bounding_method(void) const
Returns the method used for bounding the independent parameters.
void set_minimums(const Vector< double > &)
Vector< Vector< double > > arrange_means_standard_deviations(void)
void bound_parameter(const size_t &)
void set_upper_bound(const size_t &, const double &)
std::string write_bounding_method(void) const
Returns a string with the method used for bounding the independent parameters.
void set_bounds(void)
Sets the vectors of lower and upper bounds for the independent parameters to have size zero...
void randomize_parameters_uniform(void)
Initializes the independent parameters with values comprised between -1 and +1.
double get_parameter(const size_t &) const
void set_parameters(const Vector< double > &)
bool is_empty(void) const
Returns true if the number of parameters is zero, and false otherwise.
void set_name(const size_t &, const std::string &)
const Vector< double > & get_standard_deviations(void) const
BoundingMethod bounding_method
Independent parameters bounding method.
void set_statistics(const Vector< Vector< double > > &)
Vector< Vector< double > > arrange_statistics(void)
void set_maximums(const Vector< double > &)
double get_mean(const size_t &) const
void randomize_normal(const double &=0.0, const double &=1.0)
void set_parameter(const size_t &, const double &)
void set_names(const Vector< std::string > &)
void set_mean(const size_t &, const double &)
virtual ~IndependentParameters(void)
Vector< double > parameters
Independent parameters.
const std::string & get_name(const size_t &) const
std::string to_string(void) const
Returns a string representation of the current independent parameters object.
void apply_upper_bound(const T &)
void initialize_random(void)
ScalingMethod scaling_method
Independent parameters scaling and unscaling method.
IndependentParameters(void)
Vector< Vector< double > > arrange_minimums_maximums(void)
Vector< double > lower_bounds
Lower bound of independent parameters.
void set_lower_bounds(void)
Sets the lower bound of the independent parameters to an empty vector.
Vector< std::string > descriptions
Description of independent parameters.
bool operator==(const IndependentParameters &) const
Vector< double > calculate_scaled_parameters(void) const
double get_standard_deviation(const size_t &) const
void bound_parameters(void)
Makes the independent parameters to fall in the range defined by their lower and the upper bounds...
const Vector< std::string > & get_descriptions(void) const
const Vector< double > & get_upper_bounds(void) const
void set_display(const bool &)
Vector< std::string > names
Name of independent parameters.
void apply_lower_upper_bounds(const T &, const T &)
void initialize_parameters(const double &)
void set_description(const size_t &, const std::string &)
const Vector< double > & get_minimums(void) const
void set_standard_deviations(const Vector< double > &)
IndependentParameters & operator=(const IndependentParameters &)