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

Method unitBtranIterativeRefinement

highs/simplex/HEkk.cpp:4281–4328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4279}
4280
4281void HEkk::unitBtranIterativeRefinement(const HighsInt row_out,
4282 HVector& row_ep) {
4283 // Perform an iteration of refinement
4284 HighsLp& lp = this->lp_;
4285 HVector residual;
4286 double residual_norm = 0;
4287 double correction_norm = 0;
4288 const double expected_density = 1;
4289 residual.setup(lp.num_row_);
4290 unitBtranResidual(row_out, row_ep, residual, residual_norm);
4291 const bool debug_iterative_refinement_report_on = false;
4292 bool debug_iterative_refinement_report = false;
4293 if (debug_iteration_report_) {
4294 debug_iterative_refinement_report = debug_iterative_refinement_report_on;
4295 }
4296 if (debug_iterative_refinement_report)
4297 printf(
4298 "HEkk::unitBtranIterativeRefinement: Residual has %6d / %6d nonzeros "
4299 "and norm of %g\n",
4300 (int)residual.count, (int)lp.num_row_, residual_norm);
4301 if (!residual_norm) return;
4302 // Normalise using nearest power of 2 to ||correction_rhs|| so kHighsTiny
4303 // isn't used adversely
4304 const double residual_scale = nearestPowerOfTwoScale(residual_norm);
4305 for (HighsInt iEl = 0; iEl < residual.count; iEl++)
4306 residual.array[residual.index[iEl]] *= residual_scale;
4307 btran(residual, expected_density);
4308 row_ep.count = 0;
4309 correction_norm = 0;
4310 // Adding two (possibly sparse) vectors, so have to loop over all rows
4311 for (HighsInt iRow = 0; iRow < lp.num_row_; iRow++) {
4312 if (residual.array[iRow]) {
4313 const double correction_value = residual.array[iRow] / residual_scale;
4314 correction_norm = max(fabs(correction_value), correction_norm);
4315 row_ep.array[iRow] -= correction_value;
4316 }
4317 if (fabs(row_ep.array[iRow]) < kHighsTiny) {
4318 row_ep.array[iRow] = 0;
4319 } else {
4320 row_ep.index[row_ep.count++] = iRow;
4321 }
4322 }
4323 if (debug_iterative_refinement_report)
4324 printf(
4325 "HEkk::unitBtranIterativeRefinement: Correction has %6d / %6d nonzeros "
4326 "and norm of %g\n",
4327 (int)residual.count, (int)lp.num_row_, correction_norm);
4328}
4329
4330void HEkk::unitBtranResidual(const HighsInt row_out, const HVector& row_ep,
4331 HVector& residual, double& residual_norm) {

Callers 1

Calls 2

nearestPowerOfTwoScaleFunction · 0.85
setupMethod · 0.45

Tested by

no test coverage detected