1515#include < limits>
1616
1717#include " linalg.hpp"
18+ #include " io/HighsIO.h" // For pdlpLogging
1819#include " pdlp/cupdlp/cupdlp.h" // For pdlpLogging
1920
20- namespace step {
21-
2221static constexpr double kDivergentMovement = 1e10 ;
2322
24- StepSizeConfig InitializeStepSizesPowerMethod (const HighsLp& lp,
25- double op_norm_sq) {
23+ StepSizeConfig PdlpStep:: InitializeStepSizesPowerMethod (const HighsLp& lp,
24+ double op_norm_sq) {
2625 StepSizeConfig config;
2726 config.power_method_lambda = op_norm_sq;
2827
2928 // Compute primal weight beta = ||c||^2 / ||b||^2
3029 double cost_norm = linalg::compute_cost_norm (lp, 2.0 );
3130 double rhs_norm = linalg::compute_rhs_norm (lp, 2.0 );
32- // highsLogUser(params_. log_options_, HighsLogType::kInfo, "Cost norm: %g, RHS norm: %g\n", cost_norm, rhs_norm);
31+ highsLogUser (* log_options_, HighsLogType::kInfo , " Cost norm: %g, RHS norm: %g\n " , cost_norm, rhs_norm);
3332 config.beta = cost_norm * cost_norm / (rhs_norm * rhs_norm + 1e-10 );
3433
3534 // cuPDLP-C style weight initialization
@@ -41,27 +40,25 @@ StepSizeConfig InitializeStepSizesPowerMethod(const HighsLp& lp,
4140 return config;
4241}
4342
44- bool CheckNumericalStability (const std::vector<double >& delta_x,
45- const std::vector<double >& delta_y, double omega) {
43+ bool PdlpStep:: CheckNumericalStability (const std::vector<double >& delta_x,
44+ const std::vector<double >& delta_y, double omega) {
4645 // Using omega as primal_weight for consistency
4746 double movement = ComputeMovement (delta_x, delta_y, omega);
4847
4948 if (movement == 0.0 ) {
50- std::cout << " Warning: Zero movement detected - numerical termination"
51- << std::endl;
49+ highsLogUser (*log_options_, HighsLogType::kInfo , " Warning: Zero movement detected - numerical termination\n " );
5250 return false ;
5351 }
5452
5553 if (movement > kDivergentMovement ) {
56- std::cout << " Warning: Divergent movement detected: " << movement
57- << std::endl;
54+ highsLogUser (*log_options_, HighsLogType::kInfo , " Warning: Divergent movement detected: %g\n " , movement);
5855 return false ;
5956 }
6057
6158 return true ;
6259}
6360
64- double ComputeMovement (const std::vector<double >& delta_primal,
61+ double PdlpStep:: ComputeMovement (const std::vector<double >& delta_primal,
6562 const std::vector<double >& delta_dual,
6663 double primal_weight) {
6764 double primal_squared_norm = 0.0 ;
@@ -78,7 +75,7 @@ double ComputeMovement(const std::vector<double>& delta_primal,
7875 (0.5 / primal_weight) * dual_squared_norm;
7976}
8077
81- double ComputeNonlinearity (const std::vector<double >& delta_primal,
78+ double PdlpStep:: ComputeNonlinearity (const std::vector<double >& delta_primal,
8279 const std::vector<double >& delta_aty,
8380 const std::vector<double >& aty_current,
8481 const std::vector<double >& aty_new) {
@@ -92,7 +89,7 @@ double ComputeNonlinearity(const std::vector<double>& delta_primal,
9289
9390// --- Implementation of functions from step.hpp ---
9491
95- void UpdateX (std::vector<double >& x_new, const std::vector<double >& x_current,
92+ void PdlpStep:: UpdateX (std::vector<double >& x_new, const std::vector<double >& x_current,
9693 const HighsLp& lp, const std::vector<double >& y_current,
9794 double eta, double omega, FILE* pdlp_log_file_) {
9895 std::vector<double > ATy_cache (lp.num_col_ );
@@ -107,7 +104,7 @@ void UpdateX(std::vector<double>& x_new, const std::vector<double>& x_current,
107104 }
108105}
109106
110- void UpdateY (std::vector<double >& y_new, const std::vector<double >& y_current,
107+ void PdlpStep:: UpdateY (std::vector<double >& y_new, const std::vector<double >& y_current,
111108 const HighsLp& lp, const std::vector<double >& ax_new,
112109 const std::vector<double >& ax_current, double eta, double omega) {
113110 for (HighsInt j = 0 ; j < lp.num_row_ ; j++) {
@@ -141,7 +138,7 @@ void UpdateY(std::vector<double>& y_new, const std::vector<double>& y_current,
141138 }
142139}
143140
144- void UpdateIteratesFixed (const HighsLp& lp, const PrimalDualParams& params,
141+ void PdlpStep:: UpdateIteratesFixed (const HighsLp& lp, const PrimalDualParams& params,
145142 double fixed_eta, std::vector<double >& x_new,
146143 std::vector<double >& y_new,
147144 std::vector<double >& ax_new,
@@ -155,7 +152,7 @@ void UpdateIteratesFixed(const HighsLp& lp, const PrimalDualParams& params,
155152 UpdateY (y_new, y_current, lp, ax_new, ax_current, params.eta , params.omega );
156153}
157154
158- void UpdateIteratesAdaptive (
155+ void PdlpStep:: UpdateIteratesAdaptive (
159156 const HighsLp& lp, const PrimalDualParams& params,
160157 std::vector<double >& x_new, std::vector<double >& y_new,
161158 std::vector<double >& ax_new, const std::vector<double >& x_current,
@@ -265,7 +262,7 @@ void UpdateIteratesAdaptive(
265262 }
266263}
267264
268- bool UpdateIteratesMalitskyPock (
265+ bool PdlpStep:: UpdateIteratesMalitskyPock (
269266 const HighsLp& lp, const PrimalDualParams& params,
270267 std::vector<double >& x_new, std::vector<double >& y_new,
271268 std::vector<double >& ax_new, const std::vector<double >& x_current,
@@ -383,33 +380,33 @@ bool UpdateIteratesMalitskyPock(
383380 }
384381
385382 if (!CheckNumericalStability (delta_x, delta_y, params.omega )) {
386- std::cerr << " Numerical instability in Malitsky-Pock step" << std::endl;
383+ highsLogUser (*log_options_, HighsLogType::kWarning ,
384+ " Numerical instability in Malitsky-Pock step\n " );
387385 return false ;
388386 }
389387
390388 accepted_step = true ;
391389
392- if (inner_iterations > 1 ) {
393- std::cout << " Malitsky-Pock: accepted after " << inner_iterations
394- << " line search iterations" << std::endl;
395- }
390+ if (inner_iterations > 1 )
391+ highsLogUser (*log_options_, HighsLogType:: kInfo ,
392+ " Malitsky-Pock: accepted after %d line search iterations\n " ,
393+ inner_iterations);
396394
397395 } else {
398396 // Reduce step size and try again
399397 new_primal_step_size *=
400398 params.malitsky_pock_params .step_size_downscaling_factor ;
401399
402- if (inner_iterations % 10 == 0 ) {
403- std::cout << " Malitsky-Pock line search: iteration " << inner_iterations
404- << " , reducing step to " << new_primal_step_size << std::endl;
405- }
400+ if (inner_iterations % 10 == 0 )
401+ highsLogUser (*log_options_, HighsLogType:: kInfo ,
402+ " Malitsky-Pock line search: iteration %d , reducing step to %g \n " ,
403+ inner_iterations, new_primal_step_size);
406404 }
407405 }
408406
409407 if (!accepted_step) {
410- std::cerr
411- << " Malitsky-Pock: Failed to find acceptable step after 60 iterations"
412- << std::endl;
408+ highsLogUser (*log_options_, HighsLogType::kWarning ,
409+ " Malitsky-Pock: Failed to find acceptable step after 60 iterations\n " );
413410 return false ;
414411 }
415412
@@ -418,4 +415,3 @@ bool UpdateIteratesMalitskyPock(
418415 return true ;
419416}
420417
421- } // namespace step
0 commit comments