Skip to content

Commit 0b890e3

Browse files
committed
kDualSimplexChuzcStrategyChoose speeds up fit2d
1 parent 5664751 commit 0b890e3

File tree

4 files changed

+44
-23
lines changed

4 files changed

+44
-23
lines changed

check/TestLpSolvers.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,21 @@ TEST_CASE("chuzc4", "[highs_lp_solver]") {
562562
Highs h;
563563
// h.setOptionValue("output_flag", dev_run);
564564
h.readModel(model_file);
565-
h.setOptionValue("highs_analysis_level", 8);
565+
h.setOptionValue("highs_analysis_level", 2+8);
566566
h.setOptionValue("presolve", kHighsOffString);
567567
h.setOptionValue("solve_relaxation", true);
568-
h.setOptionValue("simplex_price_strategy", kDualSimplexChuzcStrategyHeap);
569-
h.run();
570-
568+
for (HighsInt k = 0; k < 3; k++) {
569+
if (k == 0) {
570+
h.setOptionValue("dual_simplex_chuzc_strategy", kDualSimplexChuzcStrategyChoose);
571+
} else if (k == 1) {
572+
h.setOptionValue("dual_simplex_chuzc_strategy", kDualSimplexChuzcStrategyQuad);
573+
} else {
574+
h.setOptionValue("dual_simplex_chuzc_strategy", kDualSimplexChuzcStrategyHeap);
575+
}
576+
h.clearSolver();
577+
h.zeroAllClocks();
578+
h.run();
579+
}
571580
h.resetGlobalScheduler(true);
572581

573582
}

highs/simplex/HEkkDualRow.cpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ HighsInt HEkkDualRow::chooseFinal() {
128128
// 1. Reduce by large step BFRT
129129
analysis->simplexTimerStart(Chuzc3Clock);
130130
bool report_bfrt = false;
131-
const bool debug_bfrt_report_on = false;
131+
const bool report_debug_bfrt = false;
132132
if (ekk_instance_.debug_iteration_report_) {
133-
report_bfrt = debug_bfrt_report_on;
133+
report_bfrt = report_debug_bfrt;
134134
if (report_bfrt)
135135
printf("HEkkDualRow::chooseFinal Check iter = %d\n",
136136
(int)ekk_instance_.iteration_count_);
@@ -156,18 +156,23 @@ HighsInt HEkkDualRow::chooseFinal() {
156156
analysis->simplexTimerStop(Chuzc3Clock);
157157
// 2. Choose by small step BFRT
158158

159-
printf("HEkkDualRow::chooseFinal dual_simplex_chuzc_strategy = %d: workCount = %d / %d\n",
160-
int(ekk_instance_.info_.dual_simplex_chuzc_strategy),
161-
int(workCount),
162-
int(ekk_instance_.lp_.num_col_));
163-
164159
bool use_quad_sort = false;
165160
bool use_heap_sort = false;
166161
// Use the quadratic cost sort for smaller values of workCount,
167162
// otherwise use the heap-based sort
168-
use_quad_sort = true; // workCount < 100;
169-
use_heap_sort = !use_quad_sort;
170-
assert(use_heap_sort || use_quad_sort);
163+
if (ekk_instance_.info_.dual_simplex_chuzc_strategy ==
164+
kDualSimplexChuzcStrategyQuad) {
165+
use_quad_sort = true;
166+
} else if (ekk_instance_.info_.dual_simplex_chuzc_strategy ==
167+
kDualSimplexChuzcStrategyHeap) {
168+
use_heap_sort = true;
169+
} else {
170+
assert(ekk_instance_.info_.dual_simplex_chuzc_strategy ==
171+
kDualSimplexChuzcStrategyChoose);
172+
use_quad_sort = workCount < 10;
173+
use_heap_sort = !use_quad_sort;
174+
}
175+
assert(use_heap_sort != use_quad_sort);
171176
if (use_quad_sort) {
172177
analysis->num_quad_chuzc++;
173178
analysis->sum_quad_chuzc_size += workCount;
@@ -181,7 +186,6 @@ HighsInt HEkkDualRow::chooseFinal() {
181186
}
182187

183188
if (use_heap_sort) {
184-
printf("CHUZC: Using heap sort\n");
185189
// Take a copy of workData and workCount for the independent
186190
// heap-based code
187191
original_workData = workData;
@@ -275,13 +279,15 @@ HighsInt HEkkDualRow::chooseFinal() {
275279
for (HighsInt i = workGroup[breakGroup]; i < workGroup[breakGroup + 1]; i++)
276280
if (report_bfrt) debugReportBfrtVar(i, workData);
277281
} else {
278-
printf("DebugHeapSortCHUZC: Pivot = %4d; alpha = %11.4g; theta = %11.4g\n",
282+
if (report_debug_bfrt) printf("DebugHeapSortCHUZC: Pivot = %4d; alpha = %11.4g; theta = %11.4g\n",
279283
(int)workPivot, workAlpha, workTheta);
280-
debugReportBfrtVar(-1, sorted_workData);
284+
if (report_debug_bfrt)
285+
debugReportBfrtVar(-1, sorted_workData);
281286
for (HighsInt i = 0; i < alt_workGroup[breakGroup]; i++) {
282287
const HighsInt iCol = sorted_workData[i].first;
283288
const HighsInt move = workMove[iCol];
284-
debugReportBfrtVar(i, sorted_workData);
289+
if (report_debug_bfrt)
290+
debugReportBfrtVar(i, sorted_workData);
285291
workData[workCount++] = make_pair(iCol, move * workRange[iCol]);
286292
}
287293
// Look at all entries of final group to see what dual
@@ -292,7 +298,8 @@ HighsInt HEkkDualRow::chooseFinal() {
292298
// HighsInt num_infeasibility = 0;
293299
const double Td = ekk_instance_.options_->dual_feasibility_tolerance;
294300
for (HighsInt i = alt_workGroup[breakGroup]; i < to_i; i++) {
295-
debugReportBfrtVar(i, sorted_workData);
301+
if (report_debug_bfrt)
302+
debugReportBfrtVar(i, sorted_workData);
296303
const HighsInt iCol = sorted_workData[i].first;
297304
const double value = sorted_workData[i].second;
298305
const HighsInt move = workMove[iCol];
@@ -676,6 +683,7 @@ HighsInt HEkkDualRow::debugChooseColumnInfeasibilities() const {
676683
assert(!num_infeasibility);
677684
return num_infeasibility;
678685
}
686+
679687
void HEkkDualRow::debugReportBfrtVar(
680688
const HighsInt ix,
681689
const std::vector<std::pair<HighsInt, double>>& pass_workData) const {

highs/simplex/HighsSimplexAnalysis.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,12 @@ void HighsSimplexAnalysis::summaryReportFactor() const {
11661166
void HighsSimplexAnalysis::reportSimplexTimer() const {
11671167
assert(analyse_simplex_time);
11681168
SimplexTimer simplex_timer;
1169-
simplex_timer.reportDualSimplexOuterClock(thread_simplex_clocks[0]);
1169+
// simplex_timer.reportSimplexTotalClock(thread_simplex_clocks[0]);
1170+
// simplex_timer.reportSimplexPhasesClock(thread_simplex_clocks[0]);
1171+
// simplex_timer.reportDualSimplexIterateClock(thread_simplex_clocks[0]);
1172+
// simplex_timer.reportDualSimplexOuterClock(thread_simplex_clocks[0]);
11701173
simplex_timer.reportSimplexInnerClock(thread_simplex_clocks[0]);
1171-
simplex_timer.reportSimplexChuzc4Clock(thread_simplex_clocks[0]);
1174+
// simplex_timer.reportSimplexChuzc4Clock(thread_simplex_clocks[0]);
11721175
}
11731176

11741177
void HighsSimplexAnalysis::reportFactorTimer() {

highs/simplex/SimplexTimer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ class SimplexTimer {
234234
const double tolerance_percent_report =
235235
tolerance_percent_report_ >= 0 ? tolerance_percent_report_ : 1e-8;
236236
return timer_pointer->reportOnTolerance(
237-
grepStamp, clockList, ideal_sum_time, tolerance_percent_report);
237+
grepStamp, clockList, ideal_sum_time,
238+
1.0); //fix-2710
239+
// tolerance_percent_report);
238240
};
239241

240242
void reportChuzc4ClockList(const std::vector<HighsInt> simplex_clock_list,
@@ -248,7 +250,6 @@ class SimplexTimer {
248250
clockList[en] = clock[simplex_clock_list[en]];
249251
}
250252
const double ideal_sum_time = timer_pointer->read(clock[Chuzc4Clock]);
251-
printf("reportChuzc4ClockList: ideal_sum_time = %g\n", ideal_sum_time);
252253
timer_pointer->reportOnTolerance("CHUZC4:", clockList, ideal_sum_time,
253254
1e-8);
254255
};

0 commit comments

Comments
 (0)