Skip to content

Commit c739f41

Browse files
committed
Got rid of non-excessive cost/bound scaling suggestions
1 parent 8be5126 commit c739f41

File tree

4 files changed

+24
-34
lines changed

4 files changed

+24
-34
lines changed

highs/lp_data/HConst.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,13 @@ const double kHighsZero = 1e-50;
3131
const std::string kHighsOffString = "off";
3232
const std::string kHighsChooseString = "choose";
3333
const std::string kHighsOnString = "on";
34-
const HighsInt kHighsMaxStringLength = 512;
3534
const HighsInt kSimplexConcurrencyLimit = 8;
3635
const double kRunningAverageMultiplier = 0.05;
3736

3837
const double kExcessivelySmallCostValue = 1e-4;
3938
const double kExcessivelySmallBoundValue = 1e-4;
40-
const double kExcessivelyLargeCostValue = 1e10;
41-
const double kExcessivelyLargeBoundValue = 1e10;
42-
43-
const double kOkSmallCostValue = 0.5;
44-
const double kOkSmallBoundValue = 0.5;
45-
const double kOkLargeCostValue = 2.0;
46-
const double kOkLargeBoundValue = 2.0;
39+
const double kExcessivelyLargeCostValue = 1e6;
40+
const double kExcessivelyLargeBoundValue = 1e6;
4741

4842
const HighsInt kNoThreadInstance = -1;
4943
const bool kAllowDeveloperAssert = false;

highs/lp_data/Highs.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ HighsStatus Highs::run() {
959959
}
960960

961961
// Assess whether to warn the user about excessive bounds and costs
962-
assessCostBoundScaling(this->options_.log_options,
962+
assessExcessiveCostBoundScaling(this->options_.log_options,
963963
this->model_,
964964
user_scale_data);
965965

@@ -2015,8 +2015,7 @@ HighsStatus Highs::getCostBoundScaling(HighsInt& suggested_cost_scale,
20152015
this->logHeader();
20162016
HighsUserScaleData data;
20172017
initialiseUserScaleData(this->options_, data);
2018-
assessCostBoundScaling(this->options_.log_options, this->model_,
2019-
data, false);
2018+
assessExcessiveCostBoundScaling(this->options_.log_options, this->model_, data);
20202019
suggested_cost_scale = data.suggested_user_cost_scale;
20212020
suggested_bound_scale = data.suggested_user_bound_scale;
20222021
printf("Highs::getCostBoundScaling suggested cost / bound scale values of %d / %d\n",

highs/lp_data/HighsSolve.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,16 @@ HighsStatus solveUnconstrainedLp(const HighsOptions& options, const HighsLp& lp,
347347
// determine the model coefficient ranges, assess it for values
348348
// outside the [small, large] range, and give appropriate scaling
349349
// recommendations
350-
void assessCostBoundScaling(const HighsLogOptions log_options,
351-
const HighsModel& model,
352-
HighsUserScaleData& user_scale_data,
353-
const bool excessive) {
350+
void assessExcessiveCostBoundScaling(const HighsLogOptions log_options,
351+
const HighsModel& model,
352+
HighsUserScaleData& user_scale_data) {
353+
const HighsLp& lp = model.lp_;
354+
if (lp.num_col_ == 0 || lp.num_row_ == 0) return;
354355
const bool user_cost_or_bound_scale = user_scale_data.user_cost_scale || user_scale_data.user_bound_scale;
355-
const double small_cost = excessive ? kExcessivelySmallCostValue : kOkSmallCostValue;
356-
const double large_cost = excessive ? kExcessivelyLargeCostValue : kOkLargeCostValue;
357-
const double small_bound = excessive ? kExcessivelySmallBoundValue : kOkSmallBoundValue;
358-
const double large_bound = excessive ? kExcessivelyLargeBoundValue : kOkLargeBoundValue;
356+
const double small_cost = kExcessivelySmallCostValue;
357+
const double large_cost = kExcessivelyLargeCostValue;
358+
const double small_bound = kExcessivelySmallBoundValue;
359+
const double large_bound = kExcessivelyLargeBoundValue;
359360
std::stringstream message;
360361
if (user_cost_or_bound_scale) {
361362
if (user_scale_data.user_cost_scale)
@@ -367,7 +368,7 @@ void assessCostBoundScaling(const HighsLogOptions log_options,
367368
user_scale_data.user_bound_scale);
368369
}
369370
highsLogUser(log_options, HighsLogType::kInfo,
370-
"Assessing excessive costs or bounds after applying%s\n", message.str().c_str());
371+
"Assessing costs and bounds after applying%s\n", message.str().c_str());
371372
}
372373
// Lambda for assessing a finite nonzero
373374
auto assessFiniteNonzero = [&](const double value, double& min_value,
@@ -378,7 +379,6 @@ void assessCostBoundScaling(const HighsLogOptions log_options,
378379
max_value = std::max(abs_value, max_value);
379380
}
380381
};
381-
const HighsLp& lp = model.lp_;
382382
double min_continuous_col_cost = kHighsInf;
383383
double min_noncontinuous_col_cost = kHighsInf;
384384
double max_continuous_col_cost = -kHighsInf;
@@ -481,14 +481,12 @@ void assessCostBoundScaling(const HighsLogOptions log_options,
481481
if (max_col_cost > large_cost)
482482
highsLogUser(log_options, HighsLogType::kWarning,
483483
"%s has excessively large costs\n", problem.c_str());
484-
485484
if (0 < min_col_bound && min_col_bound < small_bound)
486485
highsLogUser(log_options, HighsLogType::kWarning,
487486
"%s has excessively small column bounds\n", problem.c_str());
488487
if (max_col_bound > large_bound)
489488
highsLogUser(log_options, HighsLogType::kWarning,
490489
"%s has excessively large column bounds\n", problem.c_str());
491-
492490
if (0 < min_row_bound && min_row_bound < small_bound)
493491
highsLogUser(log_options, HighsLogType::kWarning,
494492
"%s has excessively small row bounds\n", problem.c_str());
@@ -500,17 +498,17 @@ void assessCostBoundScaling(const HighsLogOptions log_options,
500498
auto suggestScaling = [&](double min_value, double max_value, double small_value, double large_value) {
501499
double ratio = 1;
502500
if (min_value > large_value) {
503-
// All scalable values are excessively large, so obviously suggest
501+
// All scalable values are large, so obviously suggest
504502
// scaling them down
505503
ratio = 1.0 / min_value;
506504
//assert(0 == 11);
507505
} else if (0 < max_value && max_value < small_value) {
508-
// All scalable values are excessively small, so obviously suggest
506+
// All scalable values are small, so obviously suggest
509507
// scaling them up
510508
ratio = 1.0 / max_value;
511509
} else {
512510
if (max_value > large_value) {
513-
// Max value is excessively large, so look to scale it down
511+
// Max value is large, so look to scale it down
514512
if (0 < min_value) {
515513
// Chance that small values may be scaled down below
516514
// small_value, so look for balance
@@ -525,7 +523,7 @@ void assessCostBoundScaling(const HighsLogOptions log_options,
525523
//assert(0 == 44);
526524
}
527525
} else if (0 < min_value && min_value < small_value) {
528-
// Min value is excessively small, so look to scale it up,
526+
// Min value is small, so look to scale it up,
529527
if (0 < max_value) {
530528
// Chance that large values may be scaled up above
531529
// large_value, so look for balance
@@ -594,15 +592,15 @@ void assessCostBoundScaling(const HighsLogOptions log_options,
594592
!user_scale_data.user_cost_scale;
595593
message.str(std::string());
596594
if (order_of_magnitude_message)
597-
message << highsFormatToString(" Consider scaling the costs by 1e%+1d",
595+
message << highsFormatToString(" Consider scaling the costs by 1e%+1d",
598596
int(suggested_cost_scale_order_of_magnitude));
599597
if (user_scale_data.suggested_user_cost_scale) {
600598
if (!order_of_magnitude_message) {
601599
message << " Consider";
602600
} else {
603601
message << ", or";
604602
}
605-
message << highsFormatToString(" setting the user_cost_scale option to %d\n",
603+
message << highsFormatToString(" setting the user_cost_scale option to %d",
606604
int(user_scale_data.suggested_user_cost_scale));
607605
}
608606
if (order_of_magnitude_message || user_scale_data.suggested_user_cost_scale)
@@ -622,7 +620,7 @@ void assessCostBoundScaling(const HighsLogOptions log_options,
622620
} else {
623621
message << ", or";
624622
}
625-
message << highsFormatToString(" setting the user_bound_scale option to %d\n",
623+
message << highsFormatToString(" setting the user_bound_scale option to %d",
626624
int(user_scale_data.suggested_user_bound_scale));
627625
}
628626
if (order_of_magnitude_message || user_scale_data.suggested_user_bound_scale)

highs/lp_data/HighsSolve.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ HighsStatus solveUnconstrainedLp(const HighsOptions& options, const HighsLp& lp,
1818
HighsModelStatus& model_status,
1919
HighsInfo& highs_info, HighsSolution& solution,
2020
HighsBasis& basis);
21-
void assessCostBoundScaling(const HighsLogOptions log_options,
22-
const HighsModel& model,
23-
HighsUserScaleData& user_scale_data,
24-
const bool excesive = true);
21+
void assessExcessiveCostBoundScaling(const HighsLogOptions log_options,
22+
const HighsModel& model,
23+
HighsUserScaleData& user_scale_data);
2524
#endif // LP_DATA_HIGHSSOLVE_H_

0 commit comments

Comments
 (0)