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

Function GetBasisSolvesSolutionNzOk

check/TestBasisSolves.cpp:12–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10const bool dev_run = false;
11
12bool GetBasisSolvesSolutionNzOk(HighsInt numRow,
13 const vector<double>& pass_solution_vector,
14 HighsInt* solution_num_nz,
15 vector<HighsInt>& solution_indices) {
16 if (solution_num_nz == NULL) return true;
17 vector<double> solution_vector;
18 solution_vector.resize(numRow);
19 bool solution_nz_ok = true;
20 for (HighsInt row = 0; row < numRow; row++)
21 solution_vector[row] = pass_solution_vector[row];
22 // Check that the indexed entries are nonzero
23 for (HighsInt ix = 0; ix < *solution_num_nz; ix++) {
24 HighsInt row = solution_indices[ix];
25 if (!solution_vector[row]) {
26 if (dev_run)
27 printf("SolutionNzOk: Indexed entry solution_vector[%2" HIGHSINT_FORMAT
28 "] = %11.4g\n",
29 row, solution_vector[row]);
30 solution_nz_ok = false;
31 } else {
32 solution_vector[row] = 0;
33 }
34 }
35 // Solution should now be zero
36 for (HighsInt row = 0; row < numRow; row++) {
37 if (solution_vector[row]) {
38 if (dev_run)
39 printf(
40 "SolutionNzOk: Non-indexed entry solution_vector[%2" HIGHSINT_FORMAT
41 "] = %11.4g\n",
42 row, solution_vector[row]);
43 solution_nz_ok = false;
44 }
45 }
46 return solution_nz_ok;
47}
48
49double GetBasisSolvesCheckSolution(const HighsLp& lp,
50 const vector<HighsInt>& basic_variables,

Callers 1

testBasisSolveFunction · 0.85

Calls 1

resizeMethod · 0.45

Tested by

no test coverage detected