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

Function scale_rows

highs/qpsolver/scaling.cpp:19–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19static void scale_rows(Runtime& rt) {
20 if (!rt.settings.rowscaling) {
21 return;
22 }
23
24 std::map<HighsInt, double> maxabscoefperrow;
25 for (HighsInt row = 0; row < rt.scaled.num_con; row++) {
26 maxabscoefperrow[row] = 0.0;
27 }
28
29 for (HighsInt var = 0; var < rt.scaled.num_var; var++) {
30 for (HighsInt index = rt.scaled.A.mat.start[var];
31 index < rt.scaled.A.mat.start[var + 1]; index++) {
32 if (fabs(rt.scaled.A.mat.value[index]) >
33 maxabscoefperrow[rt.scaled.A.mat.index[index]]) {
34 maxabscoefperrow[rt.scaled.A.mat.index[index]] =
35 fabs(rt.scaled.A.mat.value[index]);
36 }
37 }
38 }
39
40 for (HighsInt var = 0; var < rt.scaled.num_var; var++) {
41 for (HighsInt index = rt.scaled.A.mat.start[var];
42 index < rt.scaled.A.mat.start[var + 1]; index++) {
43 double factor =
44 largestpoweroftwo(maxabscoefperrow[rt.scaled.A.mat.index[index]]);
45 rt.scaled.A.mat.value[index] /= factor;
46 }
47 }
48
49 for (HighsInt row = 0; row < rt.scaled.num_con; row++) {
50 double factor = largestpoweroftwo(maxabscoefperrow[row]);
51 if (rt.scaled.con_lo[row] > -std::numeric_limits<double>::infinity()) {
52 rt.scaled.con_lo[row] /= factor;
53 }
54 if (rt.scaled.con_up[row] < std::numeric_limits<double>::infinity()) {
55 rt.scaled.con_up[row] /= factor;
56 }
57 }
58}
59
60static void scale_cols(Runtime& rt) {
61 if (!rt.settings.varscaling) {

Callers 1

scaleFunction · 0.85

Calls 1

largestpoweroftwoFunction · 0.85

Tested by

no test coverage detected