Skip to content

Commit 98a0df2

Browse files
committed
Added code so VScode breakpoint can be used before solving the LP relaxation that yields nonbasic variable off its bound
1 parent e64b554 commit 98a0df2

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

highs/lp_data/HighsInterface.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2897,13 +2897,15 @@ HighsStatus Highs::lpKktCheck(const HighsLp& lp, const std::string& message) {
28972897
info.max_relative_dual_residual_error, dual_residual_tolerance);
28982898
}
28992899
if (info.num_complementarity_violations) {
2900-
if (!this->options_.output_flag) {
2901-
printf("Highs::lpKktCheck With basis num_complementarity_violations = %d\n",
2902-
int(info.num_complementarity_violations));
2903-
this->options_.output_flag = true;
2904-
this->writeSolution("", 1);
2905-
this->lpKktCheck(lp, message);
2906-
}
2900+
if (!this->options_.output_flag) {
2901+
printf(
2902+
"Highs::lpKktCheck With basis num_complementarity_violations = "
2903+
"%d\n",
2904+
int(info.num_complementarity_violations));
2905+
this->options_.output_flag = true;
2906+
this->writeSolution("", 1);
2907+
this->lpKktCheck(lp, message);
2908+
}
29072909
}
29082910
assert(info.num_complementarity_violations == 0);
29092911
assert(info.primal_dual_objective_error <= optimality_tolerance);

highs/lp_data/HighsSolution.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ void getLpKktFailures(const HighsOptions& options, const HighsLp& lp,
5454
const HighsSolution& solution, const HighsBasis& basis,
5555
HighsInfo& highs_info) {
5656
HighsPrimalDualErrors primal_dual_errors;
57-
getLpKktFailures(options, lp, solution, basis, highs_info,
58-
primal_dual_errors, false);
57+
getLpKktFailures(options, lp, solution, basis, highs_info, primal_dual_errors,
58+
false);
5959
}
6060

6161
void getLpKktFailures(const HighsOptions& options, const HighsLp& lp,
@@ -73,8 +73,7 @@ void getLpKktFailures(const HighsOptions& options, const HighsLp& lp,
7373
void getKktFailures(const HighsOptions& options, const bool is_qp,
7474
const HighsLp& lp, const std::vector<double>& gradient,
7575
const HighsSolution& solution, HighsInfo& highs_info,
76-
const bool get_residuals,
77-
const bool basic_solution) {
76+
const bool get_residuals, const bool basic_solution) {
7877
double primal_feasibility_tolerance = options.primal_feasibility_tolerance;
7978
double dual_feasibility_tolerance = options.dual_feasibility_tolerance;
8079
double primal_residual_tolerance = options.primal_residual_tolerance;
@@ -957,7 +956,7 @@ bool getComplementarityViolations(const HighsLp& lp,
957956
const double optimality_tolerance,
958957
HighsInt& num_complementarity_violation,
959958
double& max_complementarity_violation,
960-
const bool basic_solution) {
959+
const bool basic_solution) {
961960
num_complementarity_violation = kHighsIllegalComplementarityCount;
962961
max_complementarity_violation = kHighsIllegalComplementarityViolation;
963962
if (!solution.dual_valid) return false;
@@ -986,11 +985,11 @@ bool getComplementarityViolations(const HighsLp& lp,
986985
const double complementarity_violation = primal_residual * dual_residual;
987986
if (complementarity_violation > optimality_tolerance) {
988987
if (basic_solution) {
989-
printf("getComplementarityViolations: %s %d has (primal / dual) residual (%g / %g) violation = %g\n",
990-
is_col ? "column" : "row",
991-
is_col ? int(iVar) : int(iRow),
992-
primal_residual, dual_residual,
993-
complementarity_violation);
988+
printf(
989+
"getComplementarityViolations: %s %d has (primal / dual) residual "
990+
"(%g / %g) violation = %g\n",
991+
is_col ? "column" : "row", is_col ? int(iVar) : int(iRow),
992+
primal_residual, dual_residual, complementarity_violation);
994993
}
995994
num_complementarity_violation++;
996995
}

highs/lp_data/HighsSolution.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ void getLpKktFailures(const HighsOptions& options, const HighsLp& lp,
8282
void getKktFailures(const HighsOptions& options, const bool is_qp,
8383
const HighsLp& lp, const std::vector<double>& gradient,
8484
const HighsSolution& solution, HighsInfo& highs_info,
85-
const bool get_residuals,// = false,
86-
const bool basic_solution = false);
85+
const bool get_residuals, // = false,
86+
const bool basic_solution = false);
8787

8888
void getVariableKktFailures(const double primal_feasibility_tolerance,
8989
const double dual_feasibility_tolerance,
@@ -109,7 +109,7 @@ bool getComplementarityViolations(const HighsLp& lp,
109109
const double optimality_tolerance,
110110
HighsInt& num_complementarity_violations,
111111
double& max_complementarity_violation,
112-
const bool basic_solution = false);
112+
const bool basic_solution = false);
113113

114114
bool computeDualObjectiveValue(const HighsModel& model,
115115
const HighsSolution& solution,

highs/mip/HighsLpRelaxation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,18 +1153,19 @@ HighsLpRelaxation::Status HighsLpRelaxation::run(bool resolve_on_error) {
11531153
}
11541154
if (use_simplex) {
11551155
const HighsLp& lp = lpsolver.getLp();
1156-
const bool check_lp = lp.num_col_ == 9 && lp.num_row_ == 23 && lp.a_matrix_.numNz() == 200;
1156+
const bool check_lp = this->numSolved == 8 && lp.num_col_ == 9 &&
1157+
lp.num_row_ == 23 && lp.a_matrix_.numNz() == 200;
11571158
if (check_lp) {
11581159
printf("HighsLpRelaxation::run Checking solution of LP\n");
11591160
lpsolver.setOptionValue("output_flag", true);
1160-
lpsolver.setOptionValue("log_dev_level", 3);
1161-
lpsolver.setOptionValue("highs_analysis_level", 4);
1162-
}
1161+
lpsolver.setOptionValue("log_dev_level", 1); // 3);
1162+
// lpsolver.setOptionValue("highs_analysis_level", 4);
1163+
}
11631164
callstatus = lpsolver.run();
11641165
if (check_lp) {
11651166
lpsolver.setOptionValue("output_flag", false);
11661167
lpsolver.setOptionValue("log_dev_level", 0);
1167-
}
1168+
}
11681169
}
11691170
// Revert the value of lpsolver.options_.solver
11701171
lpsolver.setOptionValue("solver", solver);

0 commit comments

Comments
 (0)