Skip to content

Commit cf4c1e4

Browse files
committed
Merge branch 'hi-pdlp-jh' into hi-pdlp
2 parents 049575b + 3489218 commit cf4c1e4

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

highs/pdlp/hipdlp/restart.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// restart.cc
1212
#include "restart.hpp"
1313

14+
#include "io/HighsIO.h" // For pdlpLogging
15+
1416
#include <algorithm>
1517
#include <cmath>
1618

@@ -90,16 +92,13 @@ RestartInfo RestartScheme::Check(int current_iter,
9092
(candidate_score > last_candidate_score_);
9193

9294
if (artificial_restart) {
93-
std::cout << "Artificial restart triggered at iteration "
94-
<< current_iter << std::endl;
95+
highsLogUser(*log_options_, HighsLogType::kInfo, "Artificial restart triggered at iteration %d\n", current_iter);
9596
info.should_restart = true;
9697
} else if (sufficient_decay) {
97-
std::cout << "Sufficient decay triggered at iteration " << current_iter
98-
<< std::endl;
98+
highsLogUser(*log_options_, HighsLogType::kInfo, "Sufficient decay triggered at iteration %d\n", current_iter);
9999
info.should_restart = true;
100100
} else if (necessary_decay) {
101-
std::cout << "Necessary decay triggered at iteration " << current_iter
102-
<< std::endl;
101+
highsLogUser(*log_options_, HighsLogType::kInfo, "Necessary decay triggered at iteration %d\n", current_iter);
103102
info.should_restart = true;
104103
} else {
105104
info.should_restart = false;

highs/pdlp/hipdlp/restart.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ class RestartScheme {
3939

4040
int GetLastRestartIter() const { return last_restart_iter_; }
4141
void passParams(const PrimalDualParams* params) { params_ = params; };
42+
void passLogOptions(const HighsLogOptions* log_options) { log_options_ = log_options; };
4243

4344
private:
4445
const PrimalDualParams* params_;
46+
const HighsLogOptions* log_options_;
4547
// Computes a merit score for a given set of residuals
4648
double ComputeRestartScore(const SolverResults& results);
4749

highs/pdlp/hipdlp/scaling.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "linalg.hpp"
1919

20+
#include "io/HighsIO.h" // For pdlpLogging
21+
2022
void Scaling::Initialize(const HighsLp& lp) {
2123
col_scale_.assign(lp.num_col_, 1.0);
2224
row_scale_.assign(lp.num_row_, 1.0);
@@ -27,11 +29,12 @@ void Scaling::Initialize(const HighsLp& lp) {
2729
norm_rhs_ = linalg::compute_rhs_norm(lp, 2.0);
2830
}
2931

30-
void LogMatrixNorms(const HighsLp& lp, const std::string& stage) {
31-
std::cout << "\n--- Matrix Norms " << stage << " ---" << std::endl;
32+
void Scaling::LogMatrixNorms(const std::string& stage) {
33+
const HighsLp& lp = *lp_;
34+
highsLogUser(params_->log_options_, HighsLogType::kInfo, "\n--- Matrix Norms %d ---\n", stage.c_str());
3235

3336
if (lp.num_col_ == 0 || lp.num_row_ == 0) {
34-
std::cout << "Matrix is empty." << std::endl;
37+
highsLogUser(params_->log_options_, HighsLogType::kInfo, "Matrix is empty\n");
3538
return;
3639
}
3740

@@ -43,7 +46,7 @@ void LogMatrixNorms(const HighsLp& lp, const std::string& stage) {
4346
iEl < lp.a_matrix_.start_[iCol + 1]; ++iEl) {
4447
max_abs_val = std::max(max_abs_val, std::abs(lp.a_matrix_.value_[iEl]));
4548
}
46-
std::cout << " Col " << iCol << ": " << max_abs_val << std::endl;
49+
highsLogUser(params_->log_options_, HighsLogType::kInfo, " Col %d: %g\n", iCol, max_abs_val);
4750
}
4851

4952
// --- Calculate and Log Row Norms (Infinity Norm) ---
@@ -59,10 +62,9 @@ void LogMatrixNorms(const HighsLp& lp, const std::string& stage) {
5962
}
6063

6164
for (HighsInt iRow = 0; iRow < lp.num_row_; ++iRow) {
62-
std::cout << " Row " << iRow << ": " << row_max_abs_vals[iRow]
63-
<< std::endl;
65+
highsLogUser(params_->log_options_, HighsLogType::kInfo, " Row %d: %g\n", iRow, row_max_abs_vals[iRow]);
6466
}
65-
std::cout << "-------------------------\n" << std::endl;
67+
highsLogUser(params_->log_options_, HighsLogType::kInfo, "-------------------------\n");
6668
}
6769

6870
void Scaling::scaleProblem() {

highs/pdlp/hipdlp/scaling.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Scaling {
2727
void unscaleSolution(std::vector<double>& x, std::vector<double>& y) const;
2828
void passLp(HighsLp* lp) { lp_ = lp; };
2929
void passParams(const PrimalDualParams* params) { params_ = params; };
30-
30+
void LogMatrixNorms(const std::string& stage) ;
3131
// Get scaling vectors (for unscaling solution later)
3232
bool IsScaled() const { return is_scaled_; }
3333
const std::vector<double>& GetColScaling() const { return col_scale_; }

0 commit comments

Comments
 (0)