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

Function checkPrimalRayValue

check/TestRays.cpp:182–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182bool checkPrimalRayValue(Highs& highs, const vector<double>& primal_ray_value) {
183 const HighsLp& lp = highs.getLp();
184 HighsInt numCol = lp.num_col_;
185 HighsInt numRow = lp.num_row_;
186 double ray_error_norm = 0;
187 const vector<double>& colLower = lp.col_lower_;
188 const vector<double>& colUpper = lp.col_upper_;
189 const vector<double>& rowLower = lp.row_lower_;
190 const vector<double>& rowUpper = lp.row_upper_;
191 double dual_feasibility_tolerance;
192 highs.getOptionValue("dual_feasibility_tolerance",
193 dual_feasibility_tolerance);
194 vector<double> row_ray_value;
195 row_ray_value.assign(numRow, 0.0);
196 for (HighsInt iCol = 0; iCol < numCol; iCol++) {
197 for (HighsInt iEl = lp.a_matrix_.start_[iCol];
198 iEl < lp.a_matrix_.start_[iCol + 1]; iEl++)
199 row_ray_value[lp.a_matrix_.index_[iEl]] +=
200 primal_ray_value[iCol] * lp.a_matrix_.value_[iEl];
201 }
202 for (HighsInt iCol = 0; iCol < numCol; iCol++) {
203 if (primal_ray_value[iCol] > 0) {
204 // Upper bound must be infinite
205 if (colUpper[iCol] < kHighsInf) {
206 ray_error_norm += fabs(primal_ray_value[iCol]);
207 if (primal_ray_value[iCol] > zero_ray_value_tolerance && dev_run)
208 printf("Column %" HIGHSINT_FORMAT
209 " has primal ray value %g and finite upper bound of "
210 "%g\n",
211 iCol, primal_ray_value[iCol], colUpper[iCol]);
212 }
213 } else if (primal_ray_value[iCol] < 0) {
214 // Lower bound must be infinite
215 if (colLower[iCol] > -kHighsInf) {
216 ray_error_norm += fabs(primal_ray_value[iCol]);
217 if (primal_ray_value[iCol] < -zero_ray_value_tolerance && dev_run)
218 printf("Column %" HIGHSINT_FORMAT
219 " has primal ray value %g and finite lower bound of "
220 "%g\n",
221 iCol, primal_ray_value[iCol], colLower[iCol]);
222 }
223 }
224 }
225 for (HighsInt iRow = 0; iRow < numRow; iRow++) {
226 if (row_ray_value[iRow] > 0) {
227 // Upper bound must be infinite
228 if (rowUpper[iRow] > kHighsInf) {
229 ray_error_norm += fabs(row_ray_value[iRow]);
230 if (row_ray_value[iRow] > zero_ray_value_tolerance && dev_run)
231 printf("Row %" HIGHSINT_FORMAT
232 " has primal ray value %g and finite upper bound of %g\n",
233 iRow, row_ray_value[iRow], rowUpper[iRow]);
234 }
235 } else if (row_ray_value[iRow] < -0) {
236 // Lower bound must be infinite
237 if (rowLower[iRow] > -kHighsInf) {
238 ray_error_norm += fabs(row_ray_value[iRow]);
239 if (row_ray_value[iRow] < -zero_ray_value_tolerance && dev_run)

Callers 2

testUnboundedMpsLpFunction · 0.85
TestRays.cppFile · 0.85

Calls 1

getOptionValueMethod · 0.80

Tested by

no test coverage detected