Skip to content

Commit 034a87b

Browse files
committed
Removed DetailedTimings and suppressed debug logging in HiPDLP
1 parent f89f683 commit 034a87b

File tree

4 files changed

+12
-60
lines changed

4 files changed

+12
-60
lines changed

highs/pdlp/HiPdlpWrapper.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
5656
std::vector<double> x, y;
5757
x.resize(pdlp.getnCol(),0.0);
5858
y.resize(pdlp.getnRow(), 0.0);
59-
auto solve_start = std::chrono::high_resolution_clock::now();
59+
6060
pdlp.solve(x, y);
61-
auto solve_end = std::chrono::high_resolution_clock::now();
62-
pdlp.timings_.total_time = std::chrono::duration<double>(solve_end - solve_start).count();
63-
pdlp.timings_.print("HiPdlp :", options.log_options);
6461

6562
// 5. Unscale with HiPdlp
6663
pdlp.unscaleSolution(x, y);

highs/pdlp/cupdlp/cupdlp_utils.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,7 @@ void writeSol(const char *fout, cupdlp_int nCols, cupdlp_int nRows,
17831783
}
17841784

17851785
void debugPdlpIterHeaderLog(FILE* file) {
1786+
if (!file) return;
17861787
fprintf(file, " Iter ||Ax|| ||Aty|| ||Ax_Avg|| ||Aty_Avg|| ||x_avg|| beta PrimalStep DualStep \n");
17871788
}
17881789

@@ -1794,6 +1795,7 @@ void debugPdlpDataInitialise(struct DebugPdlpData* debug_pdlp) {
17941795
}
17951796

17961797
void debugPdlpIterLog(FILE* file, const int iter_num, const struct DebugPdlpData* debug_pdlp, const double beta, const double primal_step, const double dual_step) {
1798+
if (!file) return;
17971799
fprintf(file, "%6d %11.4g %11.4g %11.4g %11.4g %11.4g %11.4g %11.4g %11.4g\n",
17981800
iter_num,
17991801
debug_pdlp->ax_norm,
@@ -1811,6 +1813,7 @@ void debugPdlpFeasOptLog(FILE* file,
18111813
const double primal_obj, const double dual_obj,
18121814
const double gap, const double primal_feas, const double dual_feas,
18131815
const char* type) {
1816+
if (!file) return;
18141817
fprintf(file,
18151818
"%6d Feasibility-optimality %s\n"
18161819
" primal_obj = %11.4g\n"
@@ -1822,16 +1825,19 @@ void debugPdlpFeasOptLog(FILE* file,
18221825
}
18231826

18241827
void debugPdlpRestartLog(FILE* file, const int iter_num, const double current_score, const double average_score) {
1828+
if (!file) return;
18251829
fprintf(file, "Restart at iter %6d: Current Score = %.6g, Average Score = %.6g\n", iter_num, current_score, average_score);
18261830
}
18271831

18281832
void debugPdlpRestarScoretLog(FILE* file, const double weight_squared, const double primal_feas,
18291833
const double dual_feas, const double obj_gap) {
1834+
if (!file) return;
18301835
fprintf(file, "Restart Score: Weight^2 = %.6g, Primal Feas = %.6g, Dual Feas = %.6g, Obj Gap = %.6g\n",
18311836
weight_squared, primal_feas, dual_feas, obj_gap);
18321837
}
18331838

18341839
void debugPdlpFinalSolutionLog(FILE* file, const double* x, int nCols, const double* y, int nRows) {
1840+
if (!file) return;
18351841
fprintf(file,"Primal solution (x):\n");
18361842
for (int i = 0; i < nCols; ++i) {
18371843
fprintf(file, "x[%d]=%g\n", i, x[i]);

highs/pdlp/hipdlp/pdhg.cc

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,16 @@ PostSolveRetcode PDLPSolver::postprocess(HighsSolution& solution) {
465465

466466
void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
467467
hipdlpTimerStart(kHipdlpClockSolve);
468-
auto solve_start = std::chrono::high_resolution_clock::now();
469468
Timer solver_timer;
470469
const HighsLp& lp = lp_;
471470

472-
debug_pdlp_log_file_ = fopen("HiPDLP.log", "w");
473-
assert(debug_pdlp_log_file_);
471+
const bool debug_logging = false;
472+
if (debug_logging) {
473+
debug_pdlp_log_file_ = fopen("HiPDLP.log", "w");
474+
assert(debug_pdlp_log_file_);
475+
}
474476

475477
// --- 0. Using PowerMethod to estimate the largest eigenvalue ---
476-
auto init_start = std::chrono::high_resolution_clock::now();
477478
initializeStepSizes();
478479

479480
PrimalDualParams working_params = params_;
@@ -518,9 +519,6 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
518519

519520
logger_.print_iteration_header();
520521

521-
auto init_end = std::chrono::high_resolution_clock::now();
522-
timings_.other_time += std::chrono::duration<double>(init_end - init_start).count();
523-
524522
// --- 2. Main PDHG Loop ---
525523
debugPdlpIterHeaderLog(debug_pdlp_log_file_);
526524
debugPdlpDataInitialise(&debug_pdlp_data_);
@@ -548,10 +546,7 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
548546
bool_checking = (bool_checking || iter % PDHG_CHECK_INTERVAL == 0);
549547
if (bool_checking) {
550548
hipdlpTimerStart(kHipdlpClockAverageIterate);
551-
auto avg_start = std::chrono::high_resolution_clock::now();
552549
computeAverageIterate(Ax_avg, ATy_avg);
553-
auto avg_end = std::chrono::high_resolution_clock::now();
554-
timings_.average_iterate_time += std::chrono::duration<double>(avg_end - avg_start).count();
555550
hipdlpTimerStop(kHipdlpClockAverageIterate);
556551

557552
// Reset the average iterate accumulation
@@ -562,7 +557,6 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
562557
SolverResults average_results;
563558

564559
hipdlpTimerStart(kHipdlpClockConvergenceCheck);
565-
auto conv_start = std::chrono::high_resolution_clock::now();
566560
// Compute residuals for current iterate
567561
bool current_converged = checkConvergence(
568562
iter, x_current_, y_current_, Ax_cache_, ATy_cache_,
@@ -572,8 +566,6 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
572566
bool average_converged =
573567
checkConvergence(iter, x_avg_, y_avg_, Ax_avg, ATy_avg,
574568
params_.tolerance, average_results, "[A]");
575-
auto conv_end = std::chrono::high_resolution_clock::now();
576-
timings_.convergence_check_time += std::chrono::duration<double>(conv_end - conv_start).count();
577569
hipdlpTimerStop(kHipdlpClockConvergenceCheck);
578570

579571
debugPdlpIterHeaderLog(debug_pdlp_log_file_);
@@ -603,7 +595,6 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
603595
}
604596

605597
// --- 4. Restart Check (using computed results) ---
606-
auto restart_start = std::chrono::high_resolution_clock::now();
607598
RestartInfo restart_info =
608599
restart_scheme_.Check(iter, current_results, average_results);
609600

@@ -637,22 +628,16 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
637628
sum_weights_ = 0.0;
638629

639630
restart_scheme_.last_restart_iter_ = iter;
640-
auto matvec_start = std::chrono::high_resolution_clock::now();
641631
// Recompute Ax and ATy for the restarted iterates
642632
linalg::Ax(lp, x_current_, Ax_cache_);
643633
linalg::ATy(lp, y_current_, ATy_cache_);
644-
auto matvec_end = std::chrono::high_resolution_clock::now();
645-
timings_.matrix_multiply_time += std::chrono::duration<double>(matvec_end - matvec_start).count();
646634

647635
restart_scheme_.SetLastRestartIter(iter);
648636
}
649-
auto restart_end = std::chrono::high_resolution_clock::now();
650-
timings_.restart_check_time += std::chrono::duration<double>(restart_end - restart_start).count();
651637
}
652638

653639
// --- 5. Core PDHG update Step ---
654640
hipdlpTimerStart(kHipdlpClockIterateUpdate);
655-
auto update_start = std::chrono::high_resolution_clock::now();
656641
bool step_success = true;
657642

658643
// Store current iterates before update (for next iteration's x_current_,
@@ -686,16 +671,11 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
686671
return solveReturn(TerminationStatus::ERROR);
687672
}
688673
}
689-
auto update_end = std::chrono::high_resolution_clock::now();
690-
timings_.iterate_update_time += std::chrono::duration<double>(update_end - update_start).count();
691674

692675
// Compute ATy for the new iterate
693676
Ax_cache_ = Ax_next_;
694677
hipdlpTimerStart(kHipdlpClockMatrixTransposeMultiply);
695-
auto aty_start = std::chrono::high_resolution_clock::now();
696678
linalg::ATy(lp, y_next_, ATy_cache_);
697-
auto aty_end = std::chrono::high_resolution_clock::now();
698-
timings_.matrix_multiply_time += std::chrono::duration<double>(aty_end - aty_start).count();
699679
hipdlpTimerStop(kHipdlpClockMatrixTransposeMultiply);
700680

701681
hipdlpTimerStop(kHipdlpClockIterateUpdate);
@@ -704,10 +684,7 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
704684
// The number of iterations since the last restart
705685
int inner_iter = iter - restart_scheme_.GetLastRestartIter();
706686
hipdlpTimerStart(kHipdlpClockAverageIterate);
707-
auto avg_update_start = std::chrono::high_resolution_clock::now();
708687
updateAverageIterates(x_next_, y_next_, working_params, inner_iter);
709-
auto avg_update_end = std::chrono::high_resolution_clock::now();
710-
timings_.average_iterate_time += std::chrono::duration<double>(avg_update_end - avg_update_start).count();
711688
hipdlpTimerStop(kHipdlpClockAverageIterate);
712689

713690

@@ -725,8 +702,6 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
725702
x = x_avg_;
726703
y = y_avg_;
727704

728-
auto solve_end = std::chrono::high_resolution_clock::now();
729-
timings_.total_time = std::chrono::duration<double>(solve_end - solve_start).count();
730705

731706
return solveReturn(TerminationStatus::TIMEOUT);
732707
}
@@ -1408,31 +1383,21 @@ std::vector<double> PDLPSolver::updateY(const std::vector<double> &y, const std:
14081383

14091384
void PDLPSolver::updateIteratesFixed() {
14101385
hipdlpTimerStart(kHipdlpClockProjectX);
1411-
auto proj_start = std::chrono::high_resolution_clock::now();
14121386
x_next_ = updateX(x_current_, ATy_cache_, stepsize_.primal_step);
1413-
auto proj_end = std::chrono::high_resolution_clock::now();
1414-
timings_.projection_time += std::chrono::duration<double>(proj_end - proj_start).count();
14151387
hipdlpTimerStop(kHipdlpClockProjectX);
14161388

14171389
hipdlpTimerStart(kHipdlpClockMatrixMultiply);
1418-
auto ax_start = std::chrono::high_resolution_clock::now();
14191390
linalg::Ax(lp_, x_next_, Ax_next_);
1420-
auto ax_end = std::chrono::high_resolution_clock::now();
1421-
timings_.matrix_multiply_time += std::chrono::duration<double>(ax_end - ax_start).count();
14221391
hipdlpTimerStop(kHipdlpClockMatrixMultiply);
14231392

14241393
hipdlpTimerStart(kHipdlpClockProjectY);
1425-
auto proj_y_start = std::chrono::high_resolution_clock::now();
14261394
y_next_ = updateY(y_current_, Ax_cache_, Ax_next_, stepsize_.dual_step);
1427-
auto proj_y_end = std::chrono::high_resolution_clock::now();
1428-
timings_.projection_time += std::chrono::duration<double>(proj_y_end - proj_y_start).count();
14291395
hipdlpTimerStop(kHipdlpClockProjectY);
14301396
}
14311397

14321398
void PDLPSolver::updateIteratesAdaptive() {
14331399
hipdlpTimerStart(kHipdlpClockStepSizeAdjustment);
14341400

1435-
auto step_adjust_start = std::chrono::high_resolution_clock::now();
14361401
const double MIN_ETA = 1e-6;
14371402
const double MAX_ETA = 1.0;
14381403

@@ -1469,32 +1434,20 @@ void PDLPSolver::updateIteratesAdaptive() {
14691434

14701435
// Primal update
14711436
hipdlpTimerStart(kHipdlpClockProjectX);
1472-
auto proj_start = std::chrono::high_resolution_clock::now();
14731437
xupdate = updateX(x_candidate, aty_candidate, primal_step_update);
1474-
auto proj_end = std::chrono::high_resolution_clock::now();
1475-
timings_.projection_time += std::chrono::duration<double>(proj_end - proj_start).count();
14761438
hipdlpTimerStop(kHipdlpClockProjectX);
14771439

14781440
hipdlpTimerStart(kHipdlpClockMatrixMultiply);
1479-
auto ax_start = std::chrono::high_resolution_clock::now();
14801441
linalg::Ax(lp_, xupdate, axupdate);
1481-
auto ax_end = std::chrono::high_resolution_clock::now();
1482-
timings_.matrix_multiply_time += std::chrono::duration<double>(ax_end - ax_start).count();
14831442
hipdlpTimerStop(kHipdlpClockMatrixMultiply);
14841443

14851444
// Dual update with timing
14861445
hipdlpTimerStart(kHipdlpClockProjectY);
1487-
auto proj_y_start = std::chrono::high_resolution_clock::now();
14881446
yupdate = updateY(y_candidate, ax_candidate, axupdate, dual_step_update);
1489-
auto proj_y_end = std::chrono::high_resolution_clock::now();
1490-
timings_.projection_time += std::chrono::duration<double>(proj_y_end - proj_y_start).count();
14911447
hipdlpTimerStop(kHipdlpClockProjectY);
14921448

14931449
hipdlpTimerStart(kHipdlpClockMatrixTransposeMultiply);
1494-
auto aty_start = std::chrono::high_resolution_clock::now();
14951450
linalg::ATy(lp_, yupdate, atyupdate);
1496-
auto aty_end = std::chrono::high_resolution_clock::now();
1497-
timings_.matrix_multiply_time += std::chrono::duration<double>(aty_end - aty_start).count();
14981451
hipdlpTimerStop(kHipdlpClockMatrixTransposeMultiply);
14991452

15001453
// Compute deltas
@@ -1571,8 +1524,6 @@ void PDLPSolver::updateIteratesAdaptive() {
15711524
stepsize_.primal_step = dStepSizeUpdate / std::sqrt(stepsize_.beta);
15721525
stepsize_.dual_step = dStepSizeUpdate * std::sqrt(stepsize_.beta);
15731526

1574-
auto step_adjust_end = std::chrono::high_resolution_clock::now();
1575-
timings_.step_size_adjustment_time += std::chrono::duration<double>(step_adjust_end - step_adjust_start).count();
15761527
hipdlpTimerStop(kHipdlpClockStepSizeAdjustment);
15771528
}
15781529

highs/pdlp/hipdlp/pdhg.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ class PDLPSolver {
5151
// --- Debugging ---
5252
FILE* debug_pdlp_log_file_ = nullptr;
5353
DebugPdlpData debug_pdlp_data_;
54-
DetailedTimings timings_;
55-
const DetailedTimings& getTimings() const { return timings_; }
5654

5755
void reportHipdlpTimer();
5856
void closeDebugLog();

0 commit comments

Comments
 (0)