MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / computeScatterDataRegressionError

Function computeScatterDataRegressionError

highs/util/HighsUtils.cpp:1106–1154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1104}
1105
1106bool computeScatterDataRegressionError(HighsScatterData& scatter_data,
1107 const bool print) {
1108 if (!scatter_data.have_regression_coeff_) return false;
1109 if (scatter_data.num_point_ < scatter_data.max_num_point_) return false;
1110 double sum_log_error = 0;
1111 if (print)
1112 printf(
1113 "Log regression\nPoint Value0 Value1 PredValue1 Error\n");
1114 for (HighsInt point = 0; point < scatter_data.max_num_point_; point++) {
1115 double value0 = scatter_data.value0_[point];
1116 double value1 = scatter_data.value1_[point];
1117 double predicted_value1;
1118 if (predictFromScatterData(scatter_data, value0, predicted_value1, true)) {
1119 double error = fabs(predicted_value1 - value1); // / fabs(value1);
1120 if (
1121 // 10*error > awful_regression_error &&
1122 print)
1123 printf("%5" HIGHSINT_FORMAT " %10.4g %10.4g %10.4g %10.4g\n", point,
1124 value0, value1, predicted_value1, error);
1125 sum_log_error += error;
1126 }
1127 }
1128 if (print)
1129 printf(" %10.4g\n", sum_log_error);
1130 double sum_linear_error = 0;
1131 if (print)
1132 printf(
1133 "Linear regression\nPoint Value0 Value1 PredValue1 "
1134 "Error\n");
1135 for (HighsInt point = 0; point < scatter_data.max_num_point_; point++) {
1136 double value0 = scatter_data.value0_[point];
1137 double value1 = scatter_data.value1_[point];
1138 double predicted_value1;
1139 if (predictFromScatterData(scatter_data, value0, predicted_value1)) {
1140 double error = fabs(predicted_value1 - value1); // / fabs(value1);
1141 if (
1142 // 10*error > awful_regression_error &&
1143 print)
1144 printf("%5" HIGHSINT_FORMAT " %10.4g %10.4g %10.4g %10.4g\n", point,
1145 value0, value1, predicted_value1, error);
1146 sum_linear_error += error;
1147 }
1148 }
1149 if (print)
1150 printf(" %10.4g\n", sum_linear_error);
1151 scatter_data.log_regression_error_ = sum_log_error;
1152 scatter_data.linear_regression_error_ = sum_linear_error;
1153 return true;
1154}
1155
1156bool printScatterData(const std::string& name,
1157 const HighsScatterData& scatter_data) {

Callers 1

regressScatterDataFunction · 0.85

Calls 1

predictFromScatterDataFunction · 0.85

Tested by

no test coverage detected