Skip to content

Commit e997fc1

Browse files
committed
sth work but slow
1 parent ce15c6b commit e997fc1

File tree

1 file changed

+29
-34
lines changed

1 file changed

+29
-34
lines changed

highs/pdlp/hipdlp/pdhg.cc

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -729,32 +729,6 @@ bool PDLPSolver::runConvergenceCheckAndRestart(size_t iter,
729729
RestartInfo restart_info = restart_scheme_.Check(iter, current_results, average_results);
730730

731731
if (restart_info.should_restart) {
732-
// A. Reset current iterate to Average if needed
733-
/*
734-
if (restart_info.restart_to_average) {
735-
#ifdef CUPDLP_GPU
736-
CUDA_CHECK(cudaMemcpy(d_x_current_, d_x_avg_, lp_.num_col_ * sizeof(double), cudaMemcpyDeviceToDevice));
737-
CUDA_CHECK(cudaMemcpy(d_y_current_, d_y_avg_, lp_.num_row_ * sizeof(double), cudaMemcpyDeviceToDevice));
738-
linalgGpuAx(d_x_current_, d_ax_current_);
739-
linalgGpuATy(d_y_current_, d_aty_current_);
740-
#else
741-
x_current_ = x_avg_;
742-
y_current_ = y_avg_;
743-
Ax_cache_ = Ax_avg_;
744-
ATy_cache_ = ATy_avg_;
745-
#endif
746-
// Store restart stats
747-
restart_scheme_.primal_feas_last_restart_ = average_results.primal_feasibility;
748-
restart_scheme_.dual_feas_last_restart_ = average_results.dual_feasibility;
749-
restart_scheme_.duality_gap_last_restart_ = average_results.duality_gap;
750-
} else {
751-
restart_scheme_.primal_feas_last_restart_ = current_results.primal_feasibility;
752-
restart_scheme_.dual_feas_last_restart_ = current_results.dual_feasibility;
753-
restart_scheme_.duality_gap_last_restart_ = current_results.duality_gap;
754-
}
755-
*/
756-
757-
758732
if (params_.use_halpern_restart ) {
759733
if (params_.step_size_strategy == StepSizeStrategy::PID) {
760734
updatePrimalWeightAtRestart(current_results);
@@ -800,14 +774,21 @@ bool PDLPSolver::runConvergenceCheckAndRestart(size_t iter,
800774
restart_scheme_.duality_gap_last_restart_ = current_results.duality_gap;
801775
}
802776

803-
// B. Update Primal/Dual Weights (Beta)
804-
PrimalDualParams dummy_params = params_; // Helper to calc ratios
805-
#ifdef CUPDLP_GPU
806-
computeStepSizeRatioGpu(dummy_params);
807-
#else
808-
computeStepSizeRatio(dummy_params);
809-
#endif
810-
current_eta_ = dummy_params.eta; // Update global eta
777+
// B. Update Primal/Dual Weights (Beta)'
778+
if (params_.use_halpern_restart &&
779+
params_.step_size_strategy == StepSizeStrategy::PID) {
780+
current_eta_ = std::sqrt(stepsize_.primal_step * stepsize_.dual_step);
781+
// Update omega for restart scheme
782+
restart_scheme_.UpdateBeta(stepsize_.beta);
783+
} else {
784+
PrimalDualParams dummy_params = params_; // Helper to calc ratios
785+
#ifdef CUPDLP_GPU
786+
computeStepSizeRatioGpu(dummy_params);
787+
#else
788+
computeStepSizeRatio(dummy_params);
789+
#endif
790+
current_eta_ = dummy_params.eta; // Update global eta
791+
}
811792

812793
// C. Reset Restart Reference Point
813794
#ifdef CUPDLP_GPU
@@ -1750,6 +1731,20 @@ void PDLPSolver::initializeStepSizes() {
17501731
"Initial step sizes from power method lambda = %g: primal = "
17511732
"%g; dual = %g\n",
17521733
op_norm_sq, stepsize_.primal_step, stepsize_.dual_step);
1734+
} else if (params_.step_size_strategy == StepSizeStrategy::PID) {
1735+
const double op_norm_sq = PowerMethod();
1736+
stepsize_.power_method_lambda = op_norm_sq;
1737+
const double safety_factor = 0.998;
1738+
double base_step = safety_factor / std::sqrt(op_norm_sq);
1739+
1740+
primal_weight_ = 1.0;
1741+
best_primal_weight_ = primal_weight_;
1742+
best_primal_dual_residual_gap_ = INFINITY;
1743+
primal_weight_error_sum_ = 0.0;
1744+
primal_weight_last_error_ = 0.0;
1745+
stepsize_.beta = primal_weight_ * primal_weight_;
1746+
stepsize_.primal_step = base_step / primal_weight_; // = base_step
1747+
stepsize_.dual_step = base_step * primal_weight_;
17531748
} else {
17541749
// Use matrix infinity norm for adaptive step size
17551750
// Compute infinity norm of matrix elements

0 commit comments

Comments
 (0)