Skip to content

Commit f5b1a8b

Browse files
committed
Now trying to log beta
1 parent ab1f094 commit f5b1a8b

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

highs/pdlp/cupdlp/cupdlp_solver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ cupdlp_retcode PDHG_Solve(const cupdlp_int* has_variables, CUPDLPwork *pdhg) {
918918
const int iter_log_between_header = 50;
919919
int iter_log_since_header = iter_log_between_header;
920920
for (timers->nIter = 0; timers->nIter < settings->nIterLim; ++timers->nIter) {
921-
pdlpIterLog(pdhg->pdlp_log_file, timers->nIter);
921+
pdlpIterLog(pdhg->pdlp_log_file, timers->nIter, pdhg->stepsize->dBeta);
922922
PDHG_Compute_SolvingTime(pdhg);
923923
#if CUPDLP_DUMP_ITERATES_STATS && CUPDLP_DEBUG
924924
PDHG_Dump_Stats(pdhg);

highs/pdlp/cupdlp/cupdlp_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,8 +1782,8 @@ void writeSol(const char *fout, cupdlp_int nCols, cupdlp_int nRows,
17821782
fclose(fptr);
17831783
}
17841784

1785-
void pdlpIterLog(FILE* file, const int iter_num) {
1786-
fprintf(file, "Iter %6d\n", iter_num);
1785+
void pdlpIterLog(FILE* file, const int iter_num, const double beta) {
1786+
fprintf(file, "Iter %6d; beta = %g\n", iter_num, beta);
17871787
}
17881788

17891789
void pdlpAxNormLog(FILE* file, const double ax_norm) {

highs/pdlp/cupdlp/cupdlp_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void writeSol(const char *fout, cupdlp_int nCols, cupdlp_int nRows,
193193
cupdlp_float *col_value, cupdlp_float *col_dual,
194194
cupdlp_float *row_value, cupdlp_float *row_dual);
195195

196-
void pdlpIterLog(FILE* file, const int iter_num);
196+
void pdlpIterLog(FILE* file, const int iter_num, const double beta);
197197
void pdlpAxNormLog(FILE* file, const double ax_norm);
198198
void pdlpAtyNormLog(FILE* file, const double aty_norm);
199199

highs/pdlp/hipdlp/pdhg.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,18 @@ void PDLPSolver::Solve(HighsLp& original_lp, const PrimalDualParams& params,
356356

357357
logger_.print_iteration_header();
358358

359-
pdlp_log_file = fopen("HiPDLP.log", "w");
360-
assert(pdlp_log_file);
359+
pdlp_log_file_ = fopen("HiPDLP.log", "w");
360+
assert(pdlp_log_file_);
361361

362362
// --- 2. Main PDHG Loop ---
363363
// A single loop handles max iterations, convergence, and restarts.
364364
for (int iter = 0; iter < params.max_iterations; ++iter) {
365-
pdlpIterLog(pdlp_log_file, iter);
365+
const double dummy_beta = 0.0;
366+
pdlpIterLog(pdlp_log_file_, iter, dummy_beta);
366367
linalg::Ax(lp, x_current_, Ax_current);
367368
//print norm of Ax
368369
double ax_norm = linalg::vector_norm(Ax_current);
369-
pdlpAxNormLog(pdlp_log_file, ax_norm);
370+
pdlpAxNormLog(pdlp_log_file_, ax_norm);
370371

371372
linalg::ATy(lp, y_current_, ATy_current);
372373
if (solver_timer.read() > params.time_limit) {
@@ -399,22 +400,22 @@ void PDLPSolver::Solve(HighsLp& original_lp, const PrimalDualParams& params,
399400
case StepSizeStrategy::FIXED:
400401
step::UpdateIteratesFixed(lp, working_params, fixed_eta, x, y, Ax_new,
401402
x_current_, y_current_, Ax_current,
402-
pdlp_log_file);
403+
pdlp_log_file_);
403404
break;
404405

405406
case StepSizeStrategy::ADAPTIVE:
406407
step::UpdateIteratesAdaptive(lp, working_params, x, y, Ax_new,
407408
x_current_, y_current_, Ax_current,
408409
ATy_current, current_eta_, iter,
409-
pdlp_log_file);
410+
pdlp_log_file_);
410411
break;
411412

412413
case StepSizeStrategy::MALITSKY_POCK:
413414
step_success = step::UpdateIteratesMalitskyPock(
414415
lp, working_params, x, y, Ax_new, x_current_, y_current_,
415416
Ax_current, ATy_current, current_eta_, ratio_last_two_step_sizes_,
416417
num_rejected_steps_, first_malitsky_iteration,
417-
pdlp_log_file);
418+
pdlp_log_file_);
418419

419420
if (!step_success) {
420421
std::cerr << "Malitsky-Pock step failed at iteration " << iter
@@ -566,7 +567,7 @@ void PDLPSolver::Solve(HighsLp& original_lp, const PrimalDualParams& params,
566567
}
567568

568569
void PDLPSolver::solveReturn() {
569-
if (pdlp_log_file) fclose(pdlp_log_file);
570+
if (pdlp_log_file_) fclose(pdlp_log_file_);
570571
}
571572

572573
void PDLPSolver::Initialize(const HighsLp& lp, std::vector<double>& x,

highs/pdlp/hipdlp/pdhg.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class PDLPSolver {
8484
ScalingParams scaling_params_;
8585
Scaling scaling_;
8686

87-
FILE* pdlp_log_file = nullptr;
87+
FILE* pdlp_log_file_ = nullptr;
8888

8989
// HighsStatus TransformGxLeqToGeq(HighsLp& lp);
9090
void PreprocessLp(const HighsLp& original_lp, HighsLp& processed_lp);

highs/pdlp/hipdlp/step.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ double ComputeNonlinearity(const std::vector<double>& delta_primal,
8888
void UpdateX(std::vector<double>& x_new, const std::vector<double>& x_current,
8989
const HighsLp& lp, const std::vector<double>& y_current,
9090
double eta, double omega,
91-
FILE* pdlp_log_file) {
91+
FILE* pdlp_log_file_) {
9292
std::vector<double> ATy_cache(lp.num_col_);
9393
linalg::ATy(lp, y_current, ATy_cache);
9494
//print the norm of ATy_cache
9595
double aty_norm = linalg::vector_norm(ATy_cache);
96-
pdlpAtyNormLog(pdlp_log_file, aty_norm);
96+
pdlpAtyNormLog(pdlp_log_file_, aty_norm);
9797
for (HighsInt i = 0; i < lp.num_col_; i++) {
9898
double gradient = lp.col_cost_[i] - ATy_cache[i];
9999
x_new[i] = linalg::project_box(x_current[i] - (eta / omega) * gradient,
@@ -142,8 +142,8 @@ void UpdateIteratesFixed(const HighsLp& lp, const PrimalDualParams& params,
142142
const std::vector<double>& x_current,
143143
const std::vector<double>& y_current,
144144
const std::vector<double>& ax_current,
145-
FILE* pdlp_log_file) {
146-
UpdateX(x_new, x_current, lp, y_current, params.eta, params.omega, pdlp_log_file);
145+
FILE* pdlp_log_file_) {
146+
UpdateX(x_new, x_current, lp, y_current, params.eta, params.omega, pdlp_log_file_);
147147
linalg::Ax(lp, x_new, ax_new);
148148
UpdateY(y_new, y_current, lp, ax_new, ax_current, params.eta, params.omega);
149149
}
@@ -157,7 +157,7 @@ void UpdateIteratesAdaptive(const HighsLp& lp, const PrimalDualParams& params,
157157
const std::vector<double>& ax_current,
158158
const std::vector<double>& aty_current,
159159
double& current_eta, int& step_size_iter_count,
160-
FILE* pdlp_log_file) {
160+
FILE* pdlp_log_file_) {
161161
const double MIN_ETA = 1e-6;
162162
const double MAX_ETA = 1.0;
163163

@@ -182,7 +182,7 @@ void UpdateIteratesAdaptive(const HighsLp& lp, const PrimalDualParams& params,
182182
std::vector<double> aty_candidate(lp.num_col_);
183183

184184
// Primal update
185-
UpdateX(x_candidate, x_current, lp, y_current, current_eta, params.omega, pdlp_log_file);
185+
UpdateX(x_candidate, x_current, lp, y_current, current_eta, params.omega, pdlp_log_file_);
186186
linalg::Ax(lp, x_candidate, ax_candidate);
187187

188188
// Dual update
@@ -268,14 +268,14 @@ bool UpdateIteratesMalitskyPock(
268268
const std::vector<double>& aty_current, double& current_eta,
269269
double& ratio_last_two_step_sizes, int& num_rejected_steps,
270270
bool first_iteration,
271-
FILE* pdlp_log_file) // Add this parameter to track first iteration
271+
FILE* pdlp_log_file_) // Add this parameter to track first iteration
272272
{
273273
// Step 1: Compute primal update first (without extrapolation)
274274
const double primal_step_size = current_eta / params.omega;
275275

276276
std::vector<double> x_candidate(lp.num_col_);
277277
UpdateX(x_candidate, x_current, lp, y_current, primal_step_size,
278-
params.omega, pdlp_log_file);
278+
params.omega, pdlp_log_file_);
279279

280280
// Compute Ax for the primal candidate
281281
std::vector<double> ax_candidate(lp.num_row_);

0 commit comments

Comments
 (0)