Skip to content

Commit 3b82c5d

Browse files
author
Julian Hall
committed
Added initialiseIterationInfo to HekkPrimal and HekkDual so iteration info is not unassigned
1 parent 54c75c9 commit 3b82c5d

File tree

11 files changed

+82212
-32
lines changed

11 files changed

+82212
-32
lines changed

check/TestLpSolvers.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,32 +553,32 @@ TEST_CASE("choose-lp-solver", "[highs_lp_solver]") {
553553

554554
h.resetGlobalScheduler(true);
555555
}
556-
/*
556+
557557
TEST_CASE("chuzc4", "[highs_lp_solver]") {
558558
std::string model_file =
559-
"/srv/mps_da/fit2d.mps.gz";
559+
std::string(HIGHS_DIR) + "/check/instances/fit2d.mps";
560560
// "/srv/miplib2017/irp.mps.gz";
561561
// "/srv/miplib2017/nw04.mps.gz";
562562
Highs h;
563563
// h.setOptionValue("output_flag", dev_run);
564564
h.readModel(model_file);
565-
h.setOptionValue("highs_analysis_level", 2+8);
565+
h.setOptionValue("highs_analysis_level", 2 + 8);
566566
h.setOptionValue("presolve", kHighsOffString);
567567
h.setOptionValue("solve_relaxation", true);
568568
for (HighsInt k = 0; k < 3; k++) {
569569
if (k == 0) {
570-
h.setOptionValue("dual_simplex_chuzc_strategy", kDualSimplexChuzcStrategyChoose);
570+
h.setOptionValue("dual_simplex_chuzc_strategy",
571+
kDualSimplexChuzcStrategyChoose);
571572
} else if (k == 1) {
572-
h.setOptionValue("dual_simplex_chuzc_strategy", kDualSimplexChuzcStrategyQuad);
573+
h.setOptionValue("dual_simplex_chuzc_strategy",
574+
kDualSimplexChuzcStrategyQuad);
573575
} else {
574-
h.setOptionValue("dual_simplex_chuzc_strategy", kDualSimplexChuzcStrategyHeap);
576+
h.setOptionValue("dual_simplex_chuzc_strategy",
577+
kDualSimplexChuzcStrategyHeap);
575578
}
576579
h.clearSolver();
577580
h.zeroAllClocks();
578581
h.run();
579582
}
580583
h.resetGlobalScheduler(true);
581-
582584
}
583-
584-
*/

check/instances/fit2d.mps

Lines changed: 82132 additions & 0 deletions
Large diffs are not rendered by default.

highs/lp_data/HConst.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ const double kHessianRegularizationValue = 1e-7;
332332
const HighsInt kDefaultAllowedMatrixPow2Scale = 20;
333333
const HighsInt kMaxAllowedMatrixPow2Scale = 30;
334334

335+
// Illegal values of simplex iteration information to check whether
336+
// they have been set
337+
const double kHighsIllegalSimplexInterationDoubleValue = -kHighsInf;
338+
const HighsInt kHighsIllegalSimplexInterationIntValue = -kHighsIInf;
339+
335340
// Illegal values of num/max/sum infeasibility - used to indicate that true
336341
// values aren't known
337342
const double kHighsIllegalInfeasibilityMeasure = kHighsInf;

highs/lp_data/HighsOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,8 @@ class HighsOptions : public HighsOptionsStruct {
14671467
records.push_back(record_int);
14681468

14691469
record_int = new OptionRecordInt(
1470-
"dual_simplex_chuzc_strategy", "Strategy for CHUZC in dual simplex", advanced,
1471-
&dual_simplex_chuzc_strategy, kDualSimplexChuzcStrategyMin,
1470+
"dual_simplex_chuzc_strategy", "Strategy for CHUZC in dual simplex",
1471+
advanced, &dual_simplex_chuzc_strategy, kDualSimplexChuzcStrategyMin,
14721472
kDualSimplexChuzcStrategyQuad, kDualSimplexChuzcStrategyMax);
14731473
records.push_back(record_int);
14741474

highs/simplex/HEkkDual.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,22 @@ void HEkkDual::solvePhase2() {
10131013
return;
10141014
}
10151015

1016+
void HEkkDual::initialiseIterationInfo() {
1017+
// integers
1018+
this->row_out = kHighsIllegalSimplexInterationIntValue;
1019+
this->variable_out = kHighsIllegalSimplexInterationIntValue;
1020+
this->move_out = kHighsIllegalSimplexInterationIntValue;
1021+
this->variable_in = kHighsIllegalSimplexInterationIntValue;
1022+
// doubles
1023+
this->delta_primal = kHighsIllegalSimplexInterationDoubleValue;
1024+
this->theta_dual = kHighsIllegalSimplexInterationDoubleValue;
1025+
this->theta_primal = kHighsIllegalSimplexInterationDoubleValue;
1026+
this->alpha_col = kHighsIllegalSimplexInterationDoubleValue;
1027+
this->alpha_row = kHighsIllegalSimplexInterationDoubleValue;
1028+
this->numericalTrouble = kHighsIllegalSimplexInterationDoubleValue;
1029+
this->computed_edge_weight = kHighsIllegalSimplexInterationDoubleValue;
1030+
}
1031+
10161032
void HEkkDual::rebuild() {
10171033
HighsSimplexInfo& info = ekk_instance_.info_;
10181034
HighsSimplexStatus& status = ekk_instance_.status_;
@@ -1204,6 +1220,8 @@ void HEkkDual::iterate() {
12041220
}
12051221
}
12061222

1223+
this->initialiseIterationInfo();
1224+
12071225
analysis->simplexTimerStart(IterateChuzrClock);
12081226
chooseRow();
12091227
analysis->simplexTimerStop(IterateChuzrClock);
@@ -1322,9 +1340,9 @@ void HEkkDual::iterationAnalysisData() {
13221340
analysis->leaving_variable = variable_out;
13231341
analysis->entering_variable = variable_in;
13241342
analysis->rebuild_reason = rebuild_reason;
1325-
analysis->reduced_rhs_value = 0;
1326-
analysis->reduced_cost_value = 0;
1327-
analysis->edge_weight = 0;
1343+
analysis->reduced_rhs_value = kHighsIllegalSimplexInterationDoubleValue;
1344+
analysis->reduced_cost_value = kHighsIllegalSimplexInterationDoubleValue;
1345+
analysis->edge_weight = kHighsIllegalSimplexInterationDoubleValue;
13281346
analysis->primal_delta = delta_primal;
13291347
analysis->primal_step = theta_primal;
13301348
analysis->dual_step = theta_dual * cost_scale_factor;

highs/simplex/HEkkDual.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ class HEkkDual {
9494
*/
9595
void solvePhase2();
9696

97+
/**
98+
* @brief Initialise iteration information
99+
*/
100+
void initialiseIterationInfo();
101+
97102
/**
98103
* @brief Reinvert if INVERT not fresh, then recompute dual and primal values
99104
*

highs/simplex/HEkkDualRow.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ HighsInt HEkkDualRow::chooseFinal() {
164164
kDualSimplexChuzcStrategyQuad) {
165165
use_quad_sort = true;
166166
} else if (ekk_instance_.info_.dual_simplex_chuzc_strategy ==
167-
kDualSimplexChuzcStrategyHeap) {
167+
kDualSimplexChuzcStrategyHeap) {
168168
use_heap_sort = true;
169169
} else {
170170
assert(ekk_instance_.info_.dual_simplex_chuzc_strategy ==
171-
kDualSimplexChuzcStrategyChoose);
171+
kDualSimplexChuzcStrategyChoose);
172172
use_quad_sort = workCount < 10;
173173
use_heap_sort = !use_quad_sort;
174174
}
@@ -279,15 +279,15 @@ HighsInt HEkkDualRow::chooseFinal() {
279279
for (HighsInt i = workGroup[breakGroup]; i < workGroup[breakGroup + 1]; i++)
280280
if (report_bfrt) debugReportBfrtVar(i, workData);
281281
} else {
282-
if (report_debug_bfrt) printf("DebugHeapSortCHUZC: Pivot = %4d; alpha = %11.4g; theta = %11.4g\n",
283-
(int)workPivot, workAlpha, workTheta);
284282
if (report_debug_bfrt)
285-
debugReportBfrtVar(-1, sorted_workData);
283+
printf(
284+
"DebugHeapSortCHUZC: Pivot = %4d; alpha = %11.4g; theta = %11.4g\n",
285+
(int)workPivot, workAlpha, workTheta);
286+
if (report_debug_bfrt) debugReportBfrtVar(-1, sorted_workData);
286287
for (HighsInt i = 0; i < alt_workGroup[breakGroup]; i++) {
287288
const HighsInt iCol = sorted_workData[i].first;
288289
const HighsInt move = workMove[iCol];
289-
if (report_debug_bfrt)
290-
debugReportBfrtVar(i, sorted_workData);
290+
if (report_debug_bfrt) debugReportBfrtVar(i, sorted_workData);
291291
workData[workCount++] = make_pair(iCol, move * workRange[iCol]);
292292
}
293293
// Look at all entries of final group to see what dual
@@ -298,8 +298,7 @@ HighsInt HEkkDualRow::chooseFinal() {
298298
// HighsInt num_infeasibility = 0;
299299
const double Td = ekk_instance_.options_->dual_feasibility_tolerance;
300300
for (HighsInt i = alt_workGroup[breakGroup]; i < to_i; i++) {
301-
if (report_debug_bfrt)
302-
debugReportBfrtVar(i, sorted_workData);
301+
if (report_debug_bfrt) debugReportBfrtVar(i, sorted_workData);
303302
const HighsInt iCol = sorted_workData[i].first;
304303
const double value = sorted_workData[i].second;
305304
const HighsInt move = workMove[iCol];

highs/simplex/HEkkPrimal.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,22 @@ void HEkkPrimal::solvePhase2() {
646646
}
647647
}
648648

649+
void HEkkPrimal::initialiseIterationInfo() {
650+
// integers
651+
this->variable_in = kHighsIllegalSimplexInterationIntValue;
652+
this->move_in = kHighsIllegalSimplexInterationIntValue;
653+
this->row_out = kHighsIllegalSimplexInterationIntValue;
654+
this->variable_out = kHighsIllegalSimplexInterationIntValue;
655+
this->move_out = kHighsIllegalSimplexInterationIntValue;
656+
// doubles
657+
this->theta_dual = kHighsIllegalSimplexInterationDoubleValue;
658+
this->theta_primal = kHighsIllegalSimplexInterationDoubleValue;
659+
this->value_in = kHighsIllegalSimplexInterationDoubleValue;
660+
this->alpha_col = kHighsIllegalSimplexInterationDoubleValue;
661+
this->alpha_row = kHighsIllegalSimplexInterationDoubleValue;
662+
this->numericalTrouble = kHighsIllegalSimplexInterationDoubleValue;
663+
}
664+
649665
void HEkkPrimal::cleanup() {
650666
HighsSimplexInfo& info = ekk_instance_.info_;
651667
if (!info.bounds_shifted && !info.bounds_perturbed) return;
@@ -825,6 +841,9 @@ void HEkkPrimal::iterate() {
825841
solve_phase = kSolvePhaseError;
826842
return;
827843
}
844+
845+
this->initialiseIterationInfo();
846+
828847
// Initialise row_out so that aborting iteration before CHUZR due to
829848
// numerical test of chosen reduced cost can be spotted - and
830849
// eliminates the unassigned read that can occur when the first
@@ -2588,10 +2607,10 @@ void HEkkPrimal::iterationAnalysisData() {
25882607
analysis->leaving_variable = variable_out;
25892608
analysis->entering_variable = variable_in;
25902609
analysis->rebuild_reason = rebuild_reason;
2591-
analysis->reduced_rhs_value = 0;
2592-
analysis->reduced_cost_value = 0;
2593-
analysis->edge_weight = 0;
2594-
analysis->primal_delta = 0;
2610+
analysis->reduced_rhs_value = kHighsIllegalSimplexInterationDoubleValue;
2611+
analysis->reduced_cost_value = kHighsIllegalSimplexInterationDoubleValue;
2612+
analysis->edge_weight = kHighsIllegalSimplexInterationDoubleValue;
2613+
analysis->primal_delta = kHighsIllegalSimplexInterationDoubleValue;
25952614
analysis->primal_step = theta_primal;
25962615
analysis->dual_step = theta_dual;
25972616
analysis->pivot_value_from_column = alpha_col;

highs/simplex/HEkkPrimal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class HEkkPrimal {
4343
void initialiseSolve();
4444
void solvePhase1();
4545
void solvePhase2();
46+
void initialiseIterationInfo();
4647
void cleanup();
4748
void rebuild();
4849

highs/simplex/SimplexTimer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ class SimplexTimer {
233233
timer_pointer->clock_time[clock[SimplexTotalClock]];
234234
const double tolerance_percent_report =
235235
tolerance_percent_report_ >= 0 ? tolerance_percent_report_ : 1e-8;
236-
return timer_pointer->reportOnTolerance(
237-
grepStamp, clockList, ideal_sum_time,
238-
1.0); //fix-2710
239-
// tolerance_percent_report);
236+
return timer_pointer->reportOnTolerance(grepStamp, clockList,
237+
ideal_sum_time,
238+
1.0); // fix-2710
239+
// tolerance_percent_report);
240240
};
241241

242242
void reportChuzc4ClockList(const std::vector<HighsInt> simplex_clock_list,

0 commit comments

Comments
 (0)