Skip to content

Commit

Permalink
Commented out assert-rich unused if structure in ipxSolutionToHighsSo…
Browse files Browse the repository at this point in the history
…lution and added printf of excesive primal values
  • Loading branch information
jajhall committed Apr 18, 2023
1 parent 868198b commit 1b0b9f2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/lp_data/HConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ const HighsInt kHighsIllegalErrorIndex = -1;
// Maximum upper bound on semi-variables
const double kMaxSemiVariableUpper = 1e5;

// Limit on primal values being realistic
const double kExcessivePrimalValue = 1e25;

// Tolerance values for highsDoubleToString
const double kModelValueToStringTolerance = 1e-15;
const double kRangingValueToStringTolerance = 1e-13;
Expand Down
52 changes: 32 additions & 20 deletions src/lp_data/HighsSolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ HighsStatus ipxSolutionToHighsSolution(
// of machine precision
const double primal_margin = 0; // primal_feasibility_tolerance;
const double dual_margin = 0; // dual_feasibility_tolerance;
double max_abs_primal_value = 0;
for (HighsInt var = 0; var < lp.num_col_ + lp.num_row_; var++) {
if (var == lp.num_col_) {
col_primal_truncation_norm = primal_truncation_norm;
Expand Down Expand Up @@ -780,28 +781,31 @@ HighsStatus ipxSolutionToHighsSolution(
}
// Continue if no dual infeasibility
if (dual_infeasibility <= dual_feasibility_tolerance) continue;

if (residual < dual_infeasibility && !force_dual_feasibility) {
// Residual is less than dual infeasibility, or not forcing
// dual feasibility, so truncate value
if (at_lower) {
assert(10 == 50);
} else if (at_upper) {
assert(11 == 50);
} else {
// Off bound
if (lower <= -kHighsInf) {
if (upper >= kHighsInf) {
// Free shouldn't be possible, as residual would be inf
assert(12 == 50);
} else {
// Upper bounded, so assume dual is negative
if (dual > 0) assert(13 == 50);
/*
// Residual is less than dual infeasibility, or not forcing
// dual feasibility, so truncate value
if (at_lower) {
assert(10 == 50);
} else if (at_upper) {
assert(11 == 50);
} else {
// Off bound
if (lower <= -kHighsInf) {
if (upper >= kHighsInf) {
// Free shouldn't be possible, as residual would be inf
assert(12 == 50);
} else {
// Upper bounded, so assume dual is negative
if (dual > 0) assert(13 == 50);
}
} else if (upper >= kHighsInf) {
// Lower bounded, so assume dual is positive
if (dual < 0) assert(14 == 50);
}
} else if (upper >= kHighsInf) {
// Lower bounded, so assume dual is positive
if (dual < 0) assert(14 == 50);
}
}
*/
num_primal_truncations++;
if (dual > 0) {
// Put closest to lower
Expand Down Expand Up @@ -851,6 +855,8 @@ HighsStatus ipxSolutionToHighsSolution(
upper, residual, new_value, primal_truncation, dual, new_dual,
dual_truncation);
*/
max_abs_primal_value =
std::max(std::abs(new_value), max_abs_primal_value);
if (is_col) {
highs_solution.col_value[col] = new_value;
highs_solution.col_dual[col] = new_dual;
Expand Down Expand Up @@ -909,8 +915,14 @@ HighsStatus ipxSolutionToHighsSolution(
"ipxSolutionToHighsSolution: Final norm of dual residual "
"values is %10.4g\n",
dual_residual_norm);
if (max_abs_primal_value > kExcessivePrimalValue) {
// highsLogUser(options.log_options, HighsLogType::kInfo,
printf(
"ipxSolutionToHighsSolution: "
"Excessive corrected |primal value| is %10.4g\n",
max_abs_primal_value);
}
}

assert(ipx_row == ipx_num_row);
assert(ipx_slack == ipx_num_col);
// Indicate that the primal and dual solution are known
Expand Down
2 changes: 0 additions & 2 deletions src/simplex/SimplexConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ const double kAcceptDseWeightThreshold = 0.25;

const double kMinDualSteepestEdgeWeight = 1e-4;

const double kExcessivePrimalValue = 1e25;

const HighsInt kNoRowSought = -2;
const HighsInt kNoRowChosen = -1;

Expand Down

0 comments on commit 1b0b9f2

Please sign in to comment.