Skip to content

Commit 2a2f242

Browse files
committed
Removed user_cost_scale_ and user_bound_scale_ from HighsLp
1 parent 92da3b1 commit 2a2f242

File tree

8 files changed

+29
-91
lines changed

8 files changed

+29
-91
lines changed

check/TestUserScale.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ void checkLpScaling(const HighsInt user_bound_scale,
167167
const double user_cost_scale_value = std::pow(2, user_cost_scale);
168168
REQUIRE(unscaled_lp.num_col_ == scaled_lp.num_col_);
169169
REQUIRE(unscaled_lp.num_row_ == scaled_lp.num_row_);
170-
REQUIRE(scaled_lp.user_cost_scale_ == user_cost_scale);
171-
REQUIRE(scaled_lp.user_bound_scale_ == user_bound_scale);
172170
const bool has_integrality = scaled_lp.integrality_.size() > 0;
173171
const HighsSparseMatrix& unscaled_matrix = unscaled_lp.a_matrix_;
174172
REQUIRE(unscaled_matrix.isColwise());

highs/lp_data/Highs.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,6 @@ HighsStatus Highs::passModel(HighsModel model) {
379379
// model object for this LP
380380
return_status = interpretCallStatus(options_.log_options, clearSolver(),
381381
return_status, "clearSolver");
382-
// Apply any user scaling in call to optionChangeAction
383-
return_status =
384-
interpretCallStatus(options_.log_options, optionChangeAction(),
385-
return_status, "optionChangeAction");
386382
return returnFromHighs(return_status);
387383
}
388384

@@ -536,20 +532,6 @@ HighsStatus Highs::passHessian(HighsHessian hessian_) {
536532
// number of columns in the model is completed
537533
if (hessian.dim_) completeHessian(this->model_.lp_.num_col_, hessian);
538534

539-
if (this->model_.lp_.user_cost_scale_) {
540-
// Assess and apply any user cost scaling
541-
if (!hessian.scaleOk(this->model_.lp_.user_cost_scale_,
542-
this->options_.small_matrix_value,
543-
this->options_.large_matrix_value)) {
544-
highsLogUser(
545-
options_.log_options, HighsLogType::kError,
546-
"User cost scaling yields zeroed or excessive Hessian values\n");
547-
return HighsStatus::kError;
548-
}
549-
double cost_scale_value = std::pow(2, this->model_.lp_.user_cost_scale_);
550-
for (HighsInt iEl = 0; iEl < hessian.numNz(); iEl++)
551-
hessian.value_[iEl] *= cost_scale_value;
552-
}
553535
return_status = interpretCallStatus(options_.log_options, clearSolver(),
554536
return_status, "clearSolver");
555537
return returnFromHighs(return_status);
@@ -1055,11 +1037,8 @@ HighsStatus Highs::optimizeModel() {
10551037
return HighsStatus::kError;
10561038
}
10571039

1058-
// Check whether model is consistent with any user bound/cost scaling
1059-
assert(this->model_.lp_.user_bound_scale_ == this->options_.user_bound_scale);
1060-
assert(this->model_.lp_.user_cost_scale_ == this->options_.user_cost_scale);
10611040
// Assess whether to warn the user about excessive bounds and costs
1062-
assessExcessiveBoundCost(options_.log_options, this->model_);
1041+
assessExcessiveBoundCost(this->options_, this->model_);
10631042

10641043
// HiGHS solvers require models with no infinite costs, and no semi-variables
10651044
//

highs/lp_data/HighsInterface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,7 @@ void Highs::restoreInfCost(HighsStatus& return_status) {
29872987
// Update model status, data and solution with respect to non-trivial
29882988
// user bound/cost scaling
29892989
HighsStatus Highs::optionChangeAction() {
2990+
/*
29902991
HighsModel& model = this->model_;
29912992
HighsLp& lp = model.lp_;
29922993
HighsInfo& info = this->info_;
@@ -3016,6 +3017,7 @@ HighsStatus Highs::optionChangeAction() {
30163017
lp.user_cost_scale_ = options.user_cost_scale;
30173018
lp.user_bound_scale_ = options.user_bound_scale;
30183019
}
3020+
*/
30193021
return HighsStatus::kOk;
30203022
}
30213023

highs/lp_data/HighsLp.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@ void HighsLp::clear() {
220220
this->col_hash_.clear();
221221
this->row_hash_.clear();
222222

223-
this->user_cost_scale_ = 0;
224-
this->user_bound_scale_ = 0;
225-
226223
this->clearScale();
227224
this->is_scaled_ = false;
228225
this->is_moved_ = false;

highs/lp_data/HighsLp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ class HighsLp {
5050
HighsNameHash col_hash_;
5151
HighsNameHash row_hash_;
5252

53-
HighsInt user_bound_scale_;
54-
HighsInt user_cost_scale_;
5553
HighsScale scale_;
5654
bool is_scaled_;
5755
bool is_moved_;

highs/lp_data/HighsLpUtils.cpp

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,31 +1734,11 @@ HighsStatus changeLpIntegrality(HighsLp& lp,
17341734
HighsInt lp_col;
17351735
HighsInt usr_col = -1;
17361736

1737-
HighsUserScaleData user_scale_data;
1738-
std::vector<HighsVarType> save_integrality;
1739-
if (lp.integrality_.size() == 0) {
1740-
// Changing integrality for a problem without an integrality
1741-
// vector (ie an LP), have to create it for the incumbent columns
1742-
// - which are naturally continuous
1737+
// If changing integrality for a problem without an integrality
1738+
// vector (ie an LP), have to create it for the incumbent columns -
1739+
// which are naturally continuous
1740+
if (lp.integrality_.size() == 0)
17431741
lp.integrality_.assign(lp.num_col_, HighsVarType::kContinuous);
1744-
} else if (lp.user_bound_scale_) {
1745-
// Save a copy of lp.integrality_ in case it needs to be reverted
1746-
// due to ultimate illegal scaling
1747-
save_integrality = lp.integrality_;
1748-
// Revert the user bound scaling to correspond to an LP...
1749-
//
1750-
// Use -lp.user_bound_scale_U to unscale the costs and matrix
1751-
// columns, and the continuous bounds
1752-
//
1753-
// Set up HighsUserScaleData, noting that any user cost scaling is
1754-
// unaffected
1755-
initialiseUserScaleData(lp, options, user_scale_data);
1756-
user_scale_data.user_cost_scale = 0;
1757-
user_scale_data.user_bound_scale = -lp.user_bound_scale_;
1758-
// Scale, forcing changes of value
1759-
const bool apply = true;
1760-
userScaleLp(lp, user_scale_data, apply);
1761-
}
17621742

17631743
assert(HighsInt(lp.integrality_.size()) == lp.num_col_);
17641744
for (HighsInt k = from_k; k < to_k + 1; k++) {
@@ -1778,23 +1758,7 @@ HighsStatus changeLpIntegrality(HighsLp& lp,
17781758
}
17791759
// If integrality_ contains only HighsVarType::kContinuous then
17801760
// clear it
1781-
if (!lp.isMip()) {
1782-
lp.integrality_.clear();
1783-
} else if (lp.user_bound_scale_) {
1784-
// ... and then reapply corresponding to the new integrality
1785-
//
1786-
// Use lp.user_bound_scale_ to scale the costs and matrix columns,
1787-
// and the continuous bounds
1788-
user_scale_data.user_bound_scale = lp.user_bound_scale_;
1789-
1790-
// Scale, first checking and reporting illegal values, then
1791-
// forcing changes of value if no illegal values
1792-
return_status = userScaleLp(lp, user_scale_data, options.log_options);
1793-
if (return_status == HighsStatus::kError) {
1794-
lp.integrality_ = save_integrality;
1795-
return HighsStatus::kError;
1796-
}
1797-
}
1761+
if (!lp.isMip()) lp.integrality_.clear();
17981762
return return_status;
17991763
}
18001764

@@ -3695,9 +3659,9 @@ void getSubVectorsTranspose(const HighsIndexCollection& index_collection,
36953659
}
36963660
}
36973661

3698-
void initialiseUserScaleData(const HighsLp& lp, const HighsOptions& options,
3662+
void initialiseUserScaleData(const HighsOptions& options,
36993663
HighsUserScaleData& user_scale_data) {
3700-
user_scale_data.initialise(lp.user_cost_scale_, lp.user_bound_scale_,
3664+
user_scale_data.initialise(options.user_cost_scale, options.user_bound_scale,
37013665
options.infinite_cost, options.infinite_bound,
37023666
options.small_matrix_value,
37033667
options.large_matrix_value);

highs/lp_data/HighsSolve.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ HighsStatus solveUnconstrainedLp(const HighsOptions& options, const HighsLp& lp,
341341
return HighsStatus::kOk;
342342
}
343343

344-
void assessExcessiveBoundCost(const HighsLogOptions log_options,
344+
void assessExcessiveBoundCost(const HighsOptions options,
345345
const HighsModel& model) {
346346
auto assessFiniteNonzero = [&](const double value, double& min_value,
347347
double& max_value) {
@@ -352,6 +352,7 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
352352
}
353353
};
354354
const HighsLp& lp = model.lp_;
355+
const HighsLogOptions& log_options = options.log_options;
355356
double min_finite_col_cost = kHighsInf;
356357
double max_finite_col_cost = -kHighsInf;
357358
double min_finite_col_bound = kHighsInf;
@@ -403,7 +404,7 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
403404
// max_finite_col_cost = 0
404405
assert(max_finite_col_cost >= 0);
405406
if (max_finite_col_cost > kExcessivelyLargeCostValue) {
406-
double user_cost_scale_value = std::pow(2, lp.user_cost_scale_);
407+
double user_cost_scale_value = std::pow(2, options.user_cost_scale);
407408
// Warn that costs are excessively large, and suggest scaling
408409
double ratio = kExcessivelyLargeCostValue /
409410
(max_finite_col_cost / user_cost_scale_value);
@@ -413,15 +414,15 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
413414
log_options, HighsLogType::kWarning,
414415
"%s has excessively large costs: consider scaling the costs "
415416
"by 1e%+1d or less, or setting option user_cost_scale to %d or less\n",
416-
lp.user_cost_scale_ ? "User-scaled problem" : "Problem",
417+
options.user_cost_scale ? "User-scaled problem" : "Problem",
417418
int(-suggested_cost_scale_exponent),
418419
int(suggested_user_cost_scale_setting));
419420
}
420421
// LPs with no columns or no finite nonzero bounds will have
421422
// max_finite_col_bound = 0
422423
assert(max_finite_col_bound >= 0);
423424
if (max_finite_col_bound > kExcessivelyLargeBoundValue) {
424-
double user_bound_scale_value = std::pow(2, lp.user_bound_scale_);
425+
double user_bound_scale_value = std::pow(2, options.user_bound_scale);
425426
// Warn that bounds are excessively large, and suggest scaling
426427
double ratio = kExcessivelyLargeBoundValue /
427428
(max_finite_col_bound / user_bound_scale_value);
@@ -432,15 +433,15 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
432433
log_options, HighsLogType::kWarning,
433434
"%s has excessively large bounds: consider scaling the bounds "
434435
"by 1e%+1d or less\n",
435-
lp.user_bound_scale_ ? "User-scaled problem" : "Problem",
436+
options.user_bound_scale ? "User-scaled problem" : "Problem",
436437
int(-suggested_bound_scale_exponent));
437438
} else {
438439
highsLogUser(
439440
log_options, HighsLogType::kWarning,
440441
"%s has excessively large bounds: consider scaling the bounds "
441442
"by 1e%+1d or less, "
442443
"or setting option user_bound_scale to %d or less\n",
443-
lp.user_bound_scale_ ? "User-scaled problem" : "Problem",
444+
options.user_bound_scale ? "User-scaled problem" : "Problem",
444445
int(-suggested_bound_scale_exponent),
445446
int(suggested_user_bound_scale));
446447
}
@@ -449,7 +450,7 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
449450
// max_finite_row_bound = 0
450451
assert(max_finite_row_bound >= 0);
451452
if (max_finite_row_bound > kExcessivelyLargeBoundValue) {
452-
double user_bound_scale_value = std::pow(2, lp.user_bound_scale_);
453+
double user_bound_scale_value = std::pow(2, options.user_bound_scale);
453454
// Warn that bounds are excessively large, and suggest scaling
454455
double ratio = kExcessivelyLargeBoundValue /
455456
(max_finite_row_bound / user_bound_scale_value);
@@ -460,23 +461,23 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
460461
log_options, HighsLogType::kWarning,
461462
"%s has excessively large bounds: consider scaling the bounds "
462463
"by 1e%+1d or less\n",
463-
lp.user_bound_scale_ ? "User-scaled problem" : "Problem",
464+
options.user_bound_scale ? "User-scaled problem" : "Problem",
464465
int(-suggested_bound_scale_exponent));
465466
} else {
466467
highsLogUser(
467468
log_options, HighsLogType::kWarning,
468469
"%s has excessively large bounds: consider scaling the bounds "
469470
"by 1e%+1d or less, "
470471
"or setting option user_bound_scale to %d or less\n",
471-
lp.user_bound_scale_ ? "User-scaled problem" : "Problem",
472+
options.user_bound_scale ? "User-scaled problem" : "Problem",
472473
int(-suggested_bound_scale_exponent),
473474
int(suggested_user_bound_scale));
474475
}
475476
}
476477
// Now consider warning relating to small maximum costs and bounds
477478
if (max_finite_col_cost > 0 &&
478479
max_finite_col_cost < kExcessivelySmallCostValue) {
479-
double user_cost_scale_value = std::pow(2, lp.user_cost_scale_);
480+
double user_cost_scale_value = std::pow(2, options.user_cost_scale);
480481
// Warn that costs are excessively small, and suggest scaling
481482
double ratio = kExcessivelySmallCostValue /
482483
(max_finite_col_cost / user_cost_scale_value);
@@ -487,13 +488,13 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
487488
"%s has excessively small costs: consider scaling the costs up "
488489
"by 1e%+1d or more, "
489490
"or setting option user_cost_scale to %d or more\n",
490-
lp.user_cost_scale_ ? "User-scaled problem" : "Problem",
491+
options.user_cost_scale ? "User-scaled problem" : "Problem",
491492
int(suggested_cost_scale_exponent),
492493
int(suggested_user_cost_scale_setting));
493494
}
494495
if (max_finite_col_bound > 0 &&
495496
max_finite_col_bound < kExcessivelySmallBoundValue) {
496-
double user_bound_scale_value = std::pow(2, lp.user_bound_scale_);
497+
double user_bound_scale_value = std::pow(2, options.user_bound_scale);
497498
// Warn that bounds are excessively small, and suggest scaling
498499
double ratio = kExcessivelySmallBoundValue /
499500
(max_finite_col_bound / user_bound_scale_value);
@@ -504,21 +505,21 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
504505
log_options, HighsLogType::kWarning,
505506
"%s has excessively small bounds: consider scaling the bounds "
506507
"by 1e%+1d or more\n",
507-
lp.user_bound_scale_ ? "User-scaled problem" : "Problem",
508+
options.user_bound_scale ? "User-scaled problem" : "Problem",
508509
int(suggested_bound_scale_exponent));
509510
} else {
510511
highsLogUser(
511512
log_options, HighsLogType::kWarning,
512513
"%s has excessively small bounds: consider scaling the bounds "
513514
"by 1e%+1d or more, "
514515
"or setting option user_bound_scale to %d or more\n",
515-
lp.user_bound_scale_ ? "User-scaled problem" : "Problem",
516+
options.user_bound_scale ? "User-scaled problem" : "Problem",
516517
int(suggested_bound_scale_exponent), int(suggested_user_bound_scale));
517518
}
518519
}
519520
if (max_finite_row_bound > 0 &&
520521
max_finite_row_bound < kExcessivelySmallBoundValue) {
521-
double user_bound_scale_value = std::pow(2, lp.user_bound_scale_);
522+
double user_bound_scale_value = std::pow(2, options.user_bound_scale);
522523
// Warn that bounds are excessively small, and suggest scaling
523524
double ratio = kExcessivelySmallBoundValue /
524525
(max_finite_row_bound / user_bound_scale_value);
@@ -529,15 +530,15 @@ void assessExcessiveBoundCost(const HighsLogOptions log_options,
529530
log_options, HighsLogType::kWarning,
530531
"%s has excessively small bounds: consider scaling the bounds "
531532
"by 1e%+1d or more\n",
532-
lp.user_bound_scale_ ? "User-scaled problem" : "Problem",
533+
options.user_bound_scale ? "User-scaled problem" : "Problem",
533534
int(suggested_bound_scale_exponent));
534535
} else {
535536
highsLogUser(
536537
log_options, HighsLogType::kWarning,
537538
"%s has excessively small bounds: consider scaling the bounds "
538539
"by 1e%+1d or more, "
539540
"or setting option user_bound_scale to %d or more\n",
540-
lp.user_bound_scale_ ? "User-scaled problem" : "Problem",
541+
options.user_bound_scale ? "User-scaled problem" : "Problem",
541542
int(suggested_bound_scale_exponent), int(suggested_user_bound_scale));
542543
}
543544
}

highs/lp_data/HighsSolve.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ HighsStatus solveUnconstrainedLp(const HighsOptions& options, const HighsLp& lp,
1818
HighsModelStatus& model_status,
1919
HighsInfo& highs_info, HighsSolution& solution,
2020
HighsBasis& basis);
21-
void assessExcessiveBoundCost(const HighsLogOptions log_options,
22-
const HighsModel& model);
21+
void assessExcessiveBoundCost(const HighsOptions options, const HighsModel& model);
2322
#endif // LP_DATA_HIGHSSOLVE_H_

0 commit comments

Comments
 (0)