@@ -26,6 +26,15 @@ static constexpr double kDivergentMovement = 1e10;
2626
2727using namespace std ;
2828
29+ void vecPrint (const std::vector<double >& vec, const char * name) {
30+ std::cout << name << " : [" ;
31+ for (size_t i = 0 ; i < vec.size (); ++i) {
32+ std::cout << vec[i];
33+ if (i < vec.size () - 1 ) std::cout << " , " ;
34+ }
35+ std::cout << " ]" << std::endl;
36+ }
37+
2938void PDLPSolver::preprocessLp () {
3039 logger_.info (
3140 " Preprocessing LP using cupdlp formulation (slack variables for "
@@ -412,9 +421,9 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
412421
413422 // --- 3. Convergence and Restart Check (BEFORE iterate update) ---
414423 bool bool_checking = (iter < 10 ) ||
415- (iter == (params_.max_iterations - 1 )) ||
416- (iter > 0 && (iter % PDHG_CHECK_INTERVAL == 0 ));
417-
424+ (iter == (params_.max_iterations - 1 ));
425+
426+ bool_checking = (bool_checking || iter % PDHG_CHECK_INTERVAL == 0 );
418427 if (bool_checking) {
419428 ComputeAverageIterate (Ax_avg, ATy_avg);
420429 // Reset the average iterate accumulation
@@ -467,36 +476,35 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
467476 restart_scheme_.Check (iter, current_results, average_results);
468477
469478 if (restart_info.should_restart ) {
470- std::vector<double > restart_x, restart_y;
471479 if (restart_info.restart_to_average ) {
472- // Restart from the average iterate
473- restart_x = x_avg_;
474- restart_y = y_avg_;
480+ restart_scheme_.primal_feas_last_restart_ = average_results.primal_feasibility ;
481+ restart_scheme_.dual_feas_last_restart_ = average_results.dual_feasibility ;
482+ restart_scheme_.duality_gap_last_restart_ = average_results.duality_gap ;
483+
484+ x_current_ = x_avg_;
485+ y_current_ = y_avg_;
475486
476487 Ax_cache_ = Ax_avg;
477488 ATy_cache_ = ATy_avg;
478489 } else {
479- // Restart from the current iterate
480- restart_x = x_current_ ;
481- restart_y = y_current_ ;
490+ restart_scheme_. primal_feas_last_restart_ = current_results. primal_feasibility ;
491+ restart_scheme_. dual_feas_last_restart_ = current_results. dual_feasibility ;
492+ restart_scheme_. duality_gap_last_restart_ = current_results. duality_gap ;
482493 }
483494
484495 // Perform the primal weight update using z^{n,0} and z^{n-1,0}
485496 PDHG_Compute_Step_Size_Ratio (working_params);
486497 current_eta_ = working_params.eta ;
487498 restart_scheme_.passParams (&working_params);
488- restart_scheme_.UpdateBeta (working_params.omega * working_params.omega );
489499
490- x_at_last_restart_ = restart_x ; // Current becomes the new last
491- y_at_last_restart_ = restart_y ;
500+ x_at_last_restart_ = x_current_ ; // Current becomes the new last
501+ y_at_last_restart_ = y_current_ ;
492502
493503 std::fill (x_sum_.begin (), x_sum_.end (), 0.0 );
494504 std::fill (y_sum_.begin (), y_sum_.end (), 0.0 );
495505 sum_weights_ = 0.0 ;
496506
497- // Set x_current_ and y_current_ for the next iteration's starting point
498- x_current_ = restart_x;
499- y_current_ = restart_y;
507+ restart_scheme_.last_restart_iter_ = iter;
500508
501509 // Recompute Ax and ATy for the restarted iterates
502510 linalg::Ax (lp, x_current_, Ax_cache_);
@@ -607,15 +615,15 @@ void PDLPSolver::PDHG_Compute_Step_Size_Ratio(
607615 // iterates.
608616 double primal_diff_norm = linalg::diffTwoNorm (x_at_last_restart_, x_current_);
609617 double dual_diff_norm = linalg::diffTwoNorm (y_at_last_restart_, y_current_);
610-
618+
611619 double dMeanStepSize = std::sqrt (stepsize_.primal_step *
612620 stepsize_.dual_step );
613621
614622
615623 // 2. Update the primal weight (beta = omega^2) if movements are significant.
616624 if (std::min (primal_diff_norm, dual_diff_norm) > 1e-10 ) {
617625 double beta_update_ratio = dual_diff_norm / primal_diff_norm;
618- double old_beta = working_params. omega * working_params. omega ;
626+ double old_beta = stepsize_. beta ;
619627
620628 double dLogBetaUpdate = 0.5 * std::log (beta_update_ratio) +
621629 0.5 * std::log (std::sqrt (old_beta));
@@ -626,6 +634,7 @@ void PDLPSolver::PDHG_Compute_Step_Size_Ratio(
626634 stepsize_.dual_step = stepsize_.primal_step * stepsize_.beta ;
627635 working_params.eta = std::sqrt (stepsize_.primal_step * stepsize_.dual_step );
628636 working_params.omega = std::sqrt (stepsize_.beta );
637+ restart_scheme_.UpdateBeta (stepsize_.beta );
629638}
630639
631640void PDLPSolver::UpdateAverageIterates (const std::vector<double >& x,
@@ -1365,3 +1374,4 @@ double PDLPSolver::ComputeNonlinearity(const std::vector<double>& delta_primal,
13651374 }
13661375 return std::abs (nonlinearity);
13671376}
1377+
0 commit comments