@@ -414,6 +414,9 @@ void HEkk::moveLp(HighsLpSolverObject& solver_object) {
414414 // The simplex algorithm runs in the same space as the LP that has
415415 // just been moved in. This is a scaled space if the LP is scaled.
416416 this ->simplex_in_scaled_space_ = this ->lp_ .is_scaled_ ;
417+ // Set the cost scale value so internal primal and dual objectives
418+ // are computed using the unscaled costs
419+ this ->cost_scale_ = this ->lp_ .is_scaled_ ? this ->lp_ .scale_ .cost : 1.0 ;
417420 //
418421 // Update other EKK pointers. Currently just pointers to the
419422 // HighsOptions and HighsTimer members of the Highs class that are
@@ -1297,16 +1300,21 @@ void HEkk::deleteRows(const HighsIndexCollection& index_collection) {
12971300
12981301void HEkk::unscaleSimplex (const HighsLp& incumbent_lp) {
12991302 if (!this ->simplex_in_scaled_space_ ) return ;
1300- assert (incumbent_lp.scale_ .has_scaling );
1303+ const HighsScale& scale = incumbent_lp.scale_ ;
1304+ assert (scale.has_scaling );
1305+ const bool has_cost_scaling = scale.cost > 1.0 ;
1306+ const bool has_matrix_scaling = scale.col .size () && scale.row .size ();
1307+ assert (has_cost_scaling || has_matrix_scaling);
1308+ assert (scale.cost );
13011309 const HighsInt num_col = incumbent_lp.num_col_ ;
13021310 const HighsInt num_row = incumbent_lp.num_row_ ;
1303- const vector<double >& col_scale = incumbent_lp. scale_ .col ;
1304- const vector<double >& row_scale = incumbent_lp. scale_ .row ;
1311+ const vector<double >& col_scale = scale .col ;
1312+ const vector<double >& row_scale = scale .row ;
13051313 for (HighsInt iCol = 0 ; iCol < num_col; iCol++) {
13061314 const HighsInt iVar = iCol;
1307- const double factor = col_scale[iCol];
1308- this ->info_ .workCost_ [iVar] /= factor;
1309- this ->info_ .workDual_ [iVar] /= factor;
1315+ const double factor = has_matrix_scaling ? col_scale[iCol] : 1.0 ;
1316+ this ->info_ .workCost_ [iVar] /= ( factor / scale. cost ) ;
1317+ this ->info_ .workDual_ [iVar] /= ( factor / scale. cost ) ;
13101318 this ->info_ .workShift_ [iVar] /= factor;
13111319 this ->info_ .workLower_ [iVar] *= factor;
13121320 this ->info_ .workUpper_ [iVar] *= factor;
@@ -1317,9 +1325,9 @@ void HEkk::unscaleSimplex(const HighsLp& incumbent_lp) {
13171325 }
13181326 for (HighsInt iRow = 0 ; iRow < num_row; iRow++) {
13191327 const HighsInt iVar = num_col + iRow;
1320- const double factor = row_scale[iRow];
1321- this ->info_ .workCost_ [iVar] *= factor;
1322- this ->info_ .workDual_ [iVar] *= factor;
1328+ const double factor = has_matrix_scaling ? row_scale[iRow] : 1.0 ;
1329+ this ->info_ .workCost_ [iVar] *= ( factor * scale. cost ) ;
1330+ this ->info_ .workDual_ [iVar] *= ( factor * scale. cost ) ;
13231331 this ->info_ .workShift_ [iVar] *= factor;
13241332 this ->info_ .workLower_ [iVar] /= factor;
13251333 this ->info_ .workUpper_ [iVar] /= factor;
@@ -1328,17 +1336,19 @@ void HEkk::unscaleSimplex(const HighsLp& incumbent_lp) {
13281336 this ->info_ .workLowerShift_ [iVar] /= factor;
13291337 this ->info_ .workUpperShift_ [iVar] /= factor;
13301338 }
1331- for (HighsInt iRow = 0 ; iRow < num_row; iRow++) {
1332- double factor;
1333- const HighsInt iVar = this ->basis_ .basicIndex_ [iRow];
1334- if (iVar < num_col) {
1335- factor = col_scale[iVar];
1336- } else {
1337- factor = 1.0 / row_scale[iVar - num_col];
1339+ if (has_matrix_scaling) {
1340+ for (HighsInt iRow = 0 ; iRow < num_row; iRow++) {
1341+ double factor;
1342+ const HighsInt iVar = this ->basis_ .basicIndex_ [iRow];
1343+ if (iVar < num_col) {
1344+ factor = col_scale[iVar];
1345+ } else {
1346+ factor = 1.0 / row_scale[iVar - num_col];
1347+ }
1348+ this ->info_ .baseLower_ [iRow] *= factor;
1349+ this ->info_ .baseUpper_ [iRow] *= factor;
1350+ this ->info_ .baseValue_ [iRow] *= factor;
13381351 }
1339- this ->info_ .baseLower_ [iRow] *= factor;
1340- this ->info_ .baseUpper_ [iRow] *= factor;
1341- this ->info_ .baseValue_ [iRow] *= factor;
13421352 }
13431353 this ->simplex_in_scaled_space_ = false ;
13441354}
0 commit comments