Skip to content

Commit b9acb3a

Browse files
committed
mip
2 parents ef38ea5 + 9ba4534 commit b9acb3a

File tree

9 files changed

+147
-27
lines changed

9 files changed

+147
-27
lines changed

check/TestPdlp.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,23 @@ TEST_CASE("hi-pdlp", "[pdlp]") {
390390
}
391391
h.resetGlobalScheduler(true);
392392
}
393+
394+
TEST_CASE("hi-pdlp-timer", "[pdlp]") {
395+
std::string model = "adlittle";
396+
std::string model_file =
397+
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
398+
Highs h;
399+
// h.setOptionValue("output_flag", dev_run);
400+
REQUIRE(h.readModel(model_file) == HighsStatus::kOk);
401+
REQUIRE(h.setOptionValue("solver", kHiPdlpString) == HighsStatus::kOk);
402+
HighsInt pdlp_features_off =
403+
//kPdlpScalingOff +
404+
//kPdlpRestartOff
405+
kPdlpAdaptiveStepSizeOff
406+
;
407+
h.setOptionValue("pdlp_features_off", pdlp_features_off);
408+
HighsStatus run_status = h.run();
409+
h.resetGlobalScheduler(true);
410+
411+
}
412+

cmake/sources.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ set(highs_headers
459459
parallel/HighsTask.h
460460
parallel/HighsTaskExecutor.h
461461
pdlp/CupdlpWrapper.h
462+
pdlp/HiPdlpTimer.h
462463
pdlp/HiPdlpWrapper.h
463464
pdlp/hipdlp/defs.hpp
464465
pdlp/hipdlp/linalg.hpp

highs/lp_data/HighsOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ class HighsOptions : public HighsOptionsStruct {
13011301
"Restart strategy for PDLP solver: 0 => off; "
13021302
"1 => fixed; 2 => adaptive",
13031303
advanced, &pdlp_restart_strategy, kPdlpRestartStrategyMin,
1304-
kPdlpRestartStrategyOff, kPdlpRestartStrategyMax);
1304+
kPdlpRestartStrategyAdaptive, kPdlpRestartStrategyMax);
13051305
records.push_back(record_int);
13061306

13071307
record_int =
@@ -1316,7 +1316,7 @@ class HighsOptions : public HighsOptionsStruct {
13161316
"Step size strategy for PDLP solver: 0 => fixed; "
13171317
"1 => adaptive; 2 => Malitsky-Pock",
13181318
advanced, &pdlp_step_size_strategy, kPdlpStepSizeStrategyMin,
1319-
kPdlpStepSizeStrategyFixed, kPdlpRestartStrategyMax);
1319+
kPdlpStepSizeStrategyAdaptive, kPdlpRestartStrategyMax);
13201320
records.push_back(record_int);
13211321

13221322
record_double = new OptionRecordDouble(

highs/pdlp/HiPdlpWrapper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
6060
pdlp.solve(x, y);
6161
auto solve_end = std::chrono::high_resolution_clock::now();
6262
pdlp.timings_.total_time = std::chrono::duration<double>(solve_end - solve_start).count();
63-
pdlp.timings_.print("HiPdlp :");
63+
pdlp.timings_.print("HiPdlp :", options.log_options);
6464

6565
// 5. Unscale with HiPdlp
6666
pdlp.unscaleSolution(x, y);
@@ -77,6 +77,8 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
7777
debugPdlpFinalSolutionLog(pdlp.debug_pdlp_log_file_,
7878
pdlp_solution.col_value.data(), lp.num_col_,
7979
pdlp_solution.row_dual.data(), lp.num_row_);
80+
pdlp.reportHipdlpTimer();
81+
8082
pdlp.solveReturn();
8183
// --- Print Summary ---
8284
pdlp.logSummary();

highs/pdlp/cupdlp/cupdlp_restart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ PDHG_restart_choice PDHG_Check_Restart_GPU(CUPDLPwork *work) {
8080
resobj->dDualFeasLastCandidate = resobj->dDualFeasAverage;
8181
resobj->dDualityGapLastCandidate = resobj->dDualityGapAverage;
8282
}
83-
83+
// work->settings->nLogLevel = 2;
8484
if (restart_choice != PDHG_NO_RESTART) {
8585
if (muCurrent < muAverage) {
8686
if (work->settings->nLogLevel > 1)

highs/pdlp/cupdlp/cupdlp_solver.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ void PDHG_Init_Variables(const cupdlp_int* has_variables, CUPDLPwork *work) {
548548
PDHG_Project_Bounds(work, x->data);
549549
double x_norm;
550550
cupdlp_twoNorm(work, lp->nCols, x->data, &x_norm);
551-
cupdlp_printf("||x0||_2 = %e\n", x_norm);
551+
if (work->settings->nLogLevel>0)
552+
cupdlp_printf("||x0||_2 = %e\n", x_norm);
552553

553554
// cupdlp_zero(iterates->y, cupdlp_float, lp->nRows);
554555
if (!*has_variables)
@@ -559,7 +560,8 @@ void PDHG_Init_Variables(const cupdlp_int* has_variables, CUPDLPwork *work) {
559560
Ax(work, ax, x);
560561
double ax_norm;
561562
cupdlp_twoNorm(work, lp->nRows, ax->data, &ax_norm);
562-
cupdlp_printf("||Ax0||_2 = %e\n", ax_norm);
563+
if (work->settings->nLogLevel>0)
564+
cupdlp_printf("||Ax0||_2 = %e\n", ax_norm);
563565
work->debug_pdlp_data_.ax_norm = ax_norm;
564566
ATy(work, aty, y);
565567
double aty_norm;

highs/pdlp/hipdlp/defs.hpp

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,45 @@ struct DetailedTimings {
173173
double step_size_adjustment_time = 0.0;
174174
double other_time = 0.0;
175175

176-
void print(const std::string& solver_name) const {
177-
std::cout << "\n=== " << solver_name << " Detailed Timings ===" << std::endl;
178-
std::cout << "Total time: " << total_time << " s" << std::endl;
179-
std::cout << "Iterate update: " << iterate_update_time
180-
<< " s (" << (iterate_update_time/total_time*100) << "%)" << std::endl;
181-
std::cout << " - Matrix multiply: " << matrix_multiply_time
182-
<< " s (" << (matrix_multiply_time/total_time*100) << "%)" << std::endl;
183-
std::cout << " - Projection: " << projection_time
184-
<< " s (" << (projection_time/total_time*100) << "%)" << std::endl;
185-
std::cout << " - Step size adjust: " << step_size_adjustment_time
186-
<< " s (" << (step_size_adjustment_time/total_time*100) << "%)" << std::endl;
187-
std::cout << "Convergence check: " << convergence_check_time
188-
<< " s (" << (convergence_check_time/total_time*100) << "%)" << std::endl;
189-
std::cout << "Restart check: " << restart_check_time
190-
<< " s (" << (restart_check_time/total_time*100) << "%)" << std::endl;
191-
std::cout << "Average iterate comp: " << average_iterate_time
192-
<< " s (" << (average_iterate_time/total_time*100) << "%)" << std::endl;
193-
std::cout << "Other: " << other_time
194-
<< " s (" << (other_time/total_time*100) << "%)" << std::endl;
176+
void print(const std::string& solver_name,
177+
const HighsLogOptions log_options) const {
178+
highsLogUser(log_options, HighsLogType::kInfo,
179+
"\n=== %s Detailed Timings ===\n",
180+
solver_name.c_str());
181+
highsLogUser(log_options, HighsLogType::kInfo,
182+
"Total time: %6.2f s\n", total_time);
183+
highsLogUser(log_options, HighsLogType::kInfo,
184+
"Iterate update: %6.2f s (%3.0f \%)\n",
185+
iterate_update_time,
186+
iterate_update_time/total_time*100);
187+
highsLogUser(log_options, HighsLogType::kInfo,
188+
" - Matrix multiply: %6.2f s (%3.0f \%)\n",
189+
matrix_multiply_time,
190+
matrix_multiply_time/total_time*100);
191+
highsLogUser(log_options, HighsLogType::kInfo,
192+
" - Projection: %6.2f s (%3.0f \%)\n",
193+
projection_time,
194+
projection_time/total_time*100);
195+
highsLogUser(log_options, HighsLogType::kInfo,
196+
" - Step size adjust: %6.2f s (%3.0f \%)\n",
197+
step_size_adjustment_time,
198+
step_size_adjustment_time/total_time*100);
199+
highsLogUser(log_options, HighsLogType::kInfo,
200+
"Convergence check: %6.2f s (%3.0f \%)\n",
201+
convergence_check_time,
202+
convergence_check_time/total_time*100);
203+
highsLogUser(log_options, HighsLogType::kInfo,
204+
"Restart check: %6.2f s (%3.0f \%)\n",
205+
restart_check_time,
206+
restart_check_time/total_time*100);
207+
highsLogUser(log_options, HighsLogType::kInfo,
208+
"Average iterate comp: %6.2f s (%3.0f \%)\n",
209+
average_iterate_time,
210+
average_iterate_time/total_time*100);
211+
highsLogUser(log_options, HighsLogType::kInfo,
212+
"Other: %6.2f s (%3.0f \%)\n",
213+
other_time,
214+
other_time/total_time*100);
195215
}
196216
};
197217

0 commit comments

Comments
 (0)