Skip to content

Commit 6074e6b

Browse files
committed
Cleaned up; formatted
1 parent a0f9a0b commit 6074e6b

4 files changed

Lines changed: 39 additions & 46 deletions

File tree

check/TestMipSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ TEST_CASE("issue-3118", "[highs_test_mip_solver]") {
14921492
// a, b binary
14931493
// Initial "solution" a = b = 1/M
14941494
Highs highs;
1495-
highs.setOptionValue("output_flag", dev_run);
1495+
// highs.setOptionValue("output_flag", dev_run);
14961496

14971497
HighsInt a = 0;
14981498
HighsInt b = 1;

highs/lp_data/Highs.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,9 +3703,8 @@ HighsStatus Highs::readSolution(const std::string& filename,
37033703

37043704
HighsStatus Highs::assessPrimalSolution(bool& valid, bool& integral,
37053705
bool& feasible) const {
3706-
const bool log_only_warning = false;
37073706
return assessLpPrimalSolution("", options_, model_.lp_, solution_, valid,
3708-
integral, feasible, log_only_warning);
3707+
integral, feasible);
37093708
}
37103709

37113710
std::string Highs::presolveStatusToString(

highs/lp_data/HighsLpUtils.cpp

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,8 +2627,7 @@ HighsStatus assessLpPrimalSolution(const std::string& message,
26272627
const HighsOptions& options,
26282628
const HighsLp& lp,
26292629
const HighsSolution& solution, bool& valid,
2630-
bool& integral, bool& feasible,
2631-
const bool log_only_warning) {
2630+
bool& integral, bool& feasible) {
26322631
valid = false;
26332632
integral = false;
26342633
feasible = false;
@@ -2650,14 +2649,14 @@ HighsStatus assessLpPrimalSolution(const std::string& message,
26502649
lp.isMip() ? options.mip_feasibility_tolerance
26512650
: options.primal_feasibility_tolerance;
26522651
// Warning logging is done if an infeasibility or row residual
2653-
// exceeding the tolerance is found. Ultimately, if
2654-
// log_only_warning is false and no warnings have been issued,
2655-
// warning is set to false, and a one-line OK logging message is
2656-
// issued.
2652+
// exceeding the tolerance is found. Ultimately, if no warnings
2653+
// have been issued, warning is set to false, and a one-line OK
2654+
// logging message is issued.
26572655
bool warning = true;
26582656
bool logged_header = false;
26592657

26602658
auto logHeader = [&]() {
2659+
if (logged_header) return;
26612660
highsLogUser(
26622661
options.log_options,
26632662
warning ? HighsLogType::kWarning : HighsLogType::kInfo,
@@ -2692,7 +2691,7 @@ HighsStatus assessLpPrimalSolution(const std::string& message,
26922691
if (col_infeasibility > 0) {
26932692
if (col_infeasibility > kPrimalFeasibilityTolerance) {
26942693
if (col_infeasibility > 2 * max_col_infeasibility) {
2695-
if (!logged_header) logHeader();
2694+
logHeader();
26962695
highsLogUser(options.log_options, HighsLogType::kWarning,
26972696
"Col %6d%s has infeasibility of %11.4g from "
26982697
"[lower, value, upper] = [%15.8g; %15.8g; %15.8g]\n",
@@ -2708,7 +2707,7 @@ HighsStatus assessLpPrimalSolution(const std::string& message,
27082707
if (integer_infeasibility > 0) {
27092708
if (integer_infeasibility > options.mip_feasibility_tolerance) {
27102709
if (integer_infeasibility > 2 * max_integer_infeasibility) {
2711-
if (!logged_header) logHeader();
2710+
logHeader();
27122711
highsLogUser(options.log_options, HighsLogType::kWarning,
27132712
"Col %6d%s has integer infeasibility of %11.4g\n",
27142713
(int)iCol, name_string.c_str(), integer_infeasibility);
@@ -2741,7 +2740,7 @@ HighsStatus assessLpPrimalSolution(const std::string& message,
27412740
if (row_infeasibility > 0) {
27422741
if (row_infeasibility > kPrimalFeasibilityTolerance) {
27432742
if (row_infeasibility > 2 * max_row_infeasibility) {
2744-
if (!logged_header) logHeader();
2743+
logHeader();
27452744
highsLogUser(options.log_options, HighsLogType::kWarning,
27462745
"Row %6d%s has infeasibility of %11.4g from "
27472746
"[lower, value, upper] = [%15.8g; %15.8g; %15.8g]\n",
@@ -2757,7 +2756,7 @@ HighsStatus assessLpPrimalSolution(const std::string& message,
27572756
double row_residual = fabs(primal - row_value[iRow]);
27582757
if (row_residual > kRowResidualTolerance) {
27592758
if (row_residual > 2 * max_row_residual) {
2760-
if (!logged_header) logHeader();
2759+
logHeader();
27612760
highsLogUser(options.log_options, HighsLogType::kWarning,
27622761
"Row %6d%s has residual of %11.4g\n",
27632762
int(iRow), name_string.c_str(), row_residual);
@@ -2774,38 +2773,34 @@ HighsStatus assessLpPrimalSolution(const std::string& message,
27742773
feasible = valid && num_col_infeasibilities == 0 &&
27752774
num_integer_infeasibilities == 0 && num_row_infeasibilities == 0;
27762775
warning = !(integral && feasible);
2777-
if (!log_only_warning || warning) {
2778-
// If log_only_warning and warning are both false, then the
2779-
// following line issues the "OK" logging message
2780-
if (!logged_header) logHeader();
2781-
if (warning) {
2782-
highsLogUser(
2783-
options.log_options, HighsLogType::kWarning,
2784-
"Solution has num max sum\n");
2785-
if (num_col_infeasibilities > 0)
2786-
highsLogUser(options.log_options, HighsLogType::kWarning,
2787-
"Col infeasibilities %6d %11.4g %11.4g\n",
2788-
int(num_col_infeasibilities), max_col_infeasibility,
2789-
sum_col_infeasibilities);
2790-
if (lp.isMip() && num_integer_infeasibilities > 0)
2791-
highsLogUser(options.log_options, HighsLogType::kWarning,
2792-
"Integer infeasibilities %6d %11.4g %11.4g\n",
2793-
int(num_integer_infeasibilities),
2794-
max_integer_infeasibility, sum_integer_infeasibilities);
2795-
if (num_row_infeasibilities > 0)
2796-
highsLogUser(options.log_options, HighsLogType::kWarning,
2797-
"Row infeasibilities %6d %11.4g %11.4g\n",
2798-
int(num_row_infeasibilities), max_row_infeasibility,
2799-
sum_row_infeasibilities);
2800-
if (num_row_residuals > 0)
2801-
highsLogUser(options.log_options, HighsLogType::kWarning,
2802-
"Row residuals %6d %11.4g %11.4g\n",
2803-
int(num_row_residuals), max_row_residual,
2804-
sum_row_residuals);
2805-
}
2776+
if (!warning) {
2777+
// Issue the "OK" logging message
2778+
logHeader();
2779+
return HighsStatus::kOk;
28062780
}
2807-
if (warning) return HighsStatus::kWarning;
2808-
return HighsStatus::kOk;
2781+
assert(logged_header);
2782+
highsLogUser(options.log_options, HighsLogType::kWarning,
2783+
"Solution has num max sum\n");
2784+
if (num_col_infeasibilities > 0)
2785+
highsLogUser(options.log_options, HighsLogType::kWarning,
2786+
"Col infeasibilities %6d %11.4g %11.4g\n",
2787+
int(num_col_infeasibilities), max_col_infeasibility,
2788+
sum_col_infeasibilities);
2789+
if (lp.isMip() && num_integer_infeasibilities > 0)
2790+
highsLogUser(options.log_options, HighsLogType::kWarning,
2791+
"Integer infeasibilities %6d %11.4g %11.4g\n",
2792+
int(num_integer_infeasibilities), max_integer_infeasibility,
2793+
sum_integer_infeasibilities);
2794+
if (num_row_infeasibilities > 0)
2795+
highsLogUser(options.log_options, HighsLogType::kWarning,
2796+
"Row infeasibilities %6d %11.4g %11.4g\n",
2797+
int(num_row_infeasibilities), max_row_infeasibility,
2798+
sum_row_infeasibilities);
2799+
if (num_row_residuals > 0)
2800+
highsLogUser(options.log_options, HighsLogType::kWarning,
2801+
"Row residuals %6d %11.4g %11.4g\n",
2802+
int(num_row_residuals), max_row_residual, sum_row_residuals);
2803+
return HighsStatus::kWarning;
28092804
}
28102805

28112806
void writeBasisFile(FILE*& file, const HighsOptions& options, const HighsLp& lp,

highs/lp_data/HighsLpUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ HighsStatus assessLpPrimalSolution(const std::string& message,
256256
const HighsOptions& options,
257257
const HighsLp& lp,
258258
const HighsSolution& solution, bool& valid,
259-
bool& integral, bool& feasible,
260-
const bool log_only_warning = true);
259+
bool& integral, bool& feasible);
261260

262261
HighsStatus calculateRowValuesQuad(const HighsLp& lp,
263262
const std::vector<double>& col_value,

0 commit comments

Comments
 (0)