Skip to content

Commit e44adae

Browse files
committed
fix restart with bound
1 parent b038d5b commit e44adae

File tree

9 files changed

+35
-32
lines changed

9 files changed

+35
-32
lines changed

highs/pdlp/HiPdlpWrapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
5454

5555
// 4. Solve with HiPdlp
5656
std::vector<double> x, y;
57+
x.resize(pdlp.getnCol(),0.0);
58+
y.resize(pdlp.getnRow(), 0.0);
5759
pdlp.solve(x, y);
5860

5961
// 5. Unscale with HiPdlp

highs/pdlp/cupdlp/cupdlp_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ struct DebugPdlpData {
405405
double aty_norm;
406406
double ax_average_norm;
407407
double aty_average_norm;
408+
double x_average_norm;
408409
};
409410

410411
struct CUPDLP_WORK {

highs/pdlp/cupdlp/cupdlp_restart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ PDHG_restart_choice PDHG_Check_Restart_GPU(CUPDLPwork *work) {
8080
resobj->dDualFeasLastCandidate = resobj->dDualFeasAverage;
8181
resobj->dDualityGapLastCandidate = resobj->dDualityGapAverage;
8282
}
83-
83+
work->settings->nLogLevel = 2;
8484
if (restart_choice != PDHG_NO_RESTART) {
8585
if (muCurrent < muAverage) {
8686
if (work->settings->nLogLevel > 1)

highs/pdlp/cupdlp/cupdlp_solver.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,15 +546,25 @@ void PDHG_Init_Variables(const cupdlp_int* has_variables, CUPDLPwork *work) {
546546
// XXX: PDLP Does not project x0, so we uncomment for 1-1 comparison
547547

548548
PDHG_Project_Bounds(work, x->data);
549-
549+
double x_norm;
550+
cupdlp_twoNorm(work, lp->nCols, x->data, &x_norm);
551+
cupdlp_printf("||x0||_2 = %e\n", x_norm);
552+
550553
// cupdlp_zero(iterates->y, cupdlp_float, lp->nRows);
551554
if (!*has_variables)
552555
CUPDLP_ZERO_VEC(y->data, cupdlp_float, lp->nRows);
553556

554557
// Ax(work, iterates->ax, iterates->x);
555558
// ATyCPU(work, iterates->aty, iterates->y);
556559
Ax(work, ax, x);
560+
double ax_norm;
561+
cupdlp_twoNorm(work, lp->nRows, ax->data, &ax_norm);
562+
cupdlp_printf("||Ax0||_2 = %e\n", ax_norm);
563+
work->debug_pdlp_data_.ax_norm = ax_norm;
557564
ATy(work, aty, y);
565+
double aty_norm;
566+
cupdlp_twoNorm(work, lp->nCols, aty->data, &aty_norm);
567+
work->debug_pdlp_data_.aty_norm = aty_norm;
558568

559569
// cupdlp_zero(iterates->xSum, cupdlp_float, lp->nCols);
560570
// cupdlp_zero(iterates->ySum, cupdlp_float, lp->nRows);
@@ -897,6 +907,7 @@ cupdlp_retcode PDHG_Solve(const cupdlp_int* has_variables, CUPDLPwork *pdhg) {
897907

898908
pdhg->debug_pdlp_log_file_ = fopen("cuPDLP.log", "w");
899909
assert(pdhg->debug_pdlp_log_file_);
910+
debugPdlpDataInitialise(&pdhg->debug_pdlp_data_);
900911

901912
// PDHG_Init_Data does nothing!
902913
PDHG_Init_Data(pdhg);
@@ -916,9 +927,9 @@ cupdlp_retcode PDHG_Solve(const cupdlp_int* has_variables, CUPDLPwork *pdhg) {
916927
const int iter_log_between_header = 50;
917928
int iter_log_since_header = iter_log_between_header;
918929
debugPdlpIterHeaderLog(pdhg->debug_pdlp_log_file_);
919-
debugPdlpDataInitialise(&pdhg->debug_pdlp_data_);
930+
920931
for (timers->nIter = 0; timers->nIter < settings->nIterLim; ++timers->nIter) {
921-
debugPdlpIterLog(pdhg->debug_pdlp_log_file_, timers->nIter, &pdhg->debug_pdlp_data_, pdhg->stepsize->dBeta);
932+
debugPdlpIterLog(pdhg->debug_pdlp_log_file_, timers->nIter, &pdhg->debug_pdlp_data_, pdhg->stepsize->dBeta, pdhg->stepsize->dPrimalStep, pdhg->stepsize->dDualStep);
922933
PDHG_Compute_SolvingTime(pdhg);
923934
#if CUPDLP_DUMP_ITERATES_STATS && CUPDLP_DEBUG
924935
PDHG_Dump_Stats(pdhg);
@@ -1041,6 +1052,17 @@ cupdlp_retcode PDHG_Solve(const cupdlp_int* has_variables, CUPDLPwork *pdhg) {
10411052
PDHG_Restart_Iterate(pdhg);
10421053
}
10431054

1055+
CUPDLPvec *ax = iterates->ax[timers->nIter % 2];
1056+
CUPDLPvec *aty = iterates->aty[timers->nIter % 2];
1057+
double debug_pdlp_data_ax_norm = 0.0;
1058+
cupdlp_twoNorm(pdhg, problem->nRows, ax->data,
1059+
&debug_pdlp_data_ax_norm);
1060+
pdhg->debug_pdlp_data_.ax_norm = debug_pdlp_data_ax_norm;
1061+
double debug_pdlp_data_aty_norm = 0.0;
1062+
cupdlp_twoNorm(pdhg, problem->nCols, aty->data, &debug_pdlp_data_aty_norm);
1063+
pdhg->debug_pdlp_data_.aty_norm = debug_pdlp_data_aty_norm;
1064+
1065+
10441066
// CUPDLP_CALL(PDHG_Update_Iterate(pdhg));
10451067
if (PDHG_Update_Iterate(pdhg) == RETCODE_FAILED) {
10461068
// cupdlp_printf("Time limit reached.\n");

highs/pdlp/cupdlp/cupdlp_step.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ void PDHG_primalGradientStep(CUPDLPwork *work, CUPDLPvec *xUpdate,
1818
cupdlp_float dPrimalStepSize) {
1919
CUPDLPproblem *problem = work->problem;
2020

21-
// print norm of A'y
22-
double debug_pdlp_data_aty_norm = 0.0;
23-
cupdlp_twoNorm(work, problem->nCols, ATy->data, &debug_pdlp_data_aty_norm);
24-
work->debug_pdlp_data_.aty_norm = debug_pdlp_data_aty_norm;
2521

2622
#if !defined(CUPDLP_CPU) && USE_KERNELS
2723
cupdlp_pgrad_cuda(xUpdate->data, x->data, problem->cost,
@@ -197,11 +193,6 @@ void PDHG_Update_Iterate_Constant_Step_Size(CUPDLPwork *pdhg) {
197193
CUPDLPvec *atyUpdate = iterates->aty[(iter + 1) % 2];
198194

199195
Ax(pdhg, ax, x);
200-
//pint norm of Ax
201-
double debug_pdlp_data_ax_norm = 0.0;
202-
cupdlp_twoNorm(pdhg, problem->nRows, ax->data,
203-
&debug_pdlp_data_ax_norm);
204-
pdhg->debug_pdlp_data_.ax_norm = debug_pdlp_data_ax_norm;
205196
ATy(pdhg, aty, y);
206197

207198
// x^{k+1} = proj_{X}(x^k - dPrimalStep * (c - A'y^k))
@@ -310,17 +301,6 @@ cupdlp_retcode PDHG_Update_Iterate_Adaptive_Step_Size(CUPDLPwork *pdhg) {
310301
#endif
311302
}
312303

313-
double debug_pdlp_data_ax_norm = 0.0;
314-
cupdlp_twoNorm(pdhg, problem->nRows, ax->data,
315-
&debug_pdlp_data_ax_norm);
316-
pdhg->debug_pdlp_data_.ax_norm = debug_pdlp_data_ax_norm;
317-
318-
319-
double debug_pdlp_data_aty_norm = 0.0;
320-
cupdlp_twoNorm(pdhg, problem->nCols, aty->data,
321-
&debug_pdlp_data_aty_norm);
322-
pdhg->debug_pdlp_data_.aty_norm = debug_pdlp_data_aty_norm;
323-
324304
stepsize->dPrimalStep = dStepSizeUpdate / sqrt(stepsize->dBeta);
325305
stepsize->dDualStep = dStepSizeUpdate * sqrt(stepsize->dBeta);
326306

@@ -426,7 +406,7 @@ void PDHG_Compute_Average_Iterate(CUPDLPwork *work) {
426406
work->debug_pdlp_data_.x_average_norm = debug_pdlp_data_x_average_norm;
427407

428408
cupdlp_float debug_pdlp_data_ax_average_norm = 0.0;
429-
cupdlp_twoNormSquared(work, lp->nCols, iterates->axAverage->data, &debug_pdlp_data_ax_average_norm);
409+
cupdlp_twoNormSquared(work, lp->nRows, iterates->axAverage->data, &debug_pdlp_data_ax_average_norm);
430410
work->debug_pdlp_data_.ax_average_norm = debug_pdlp_data_ax_average_norm;
431411

432412
// Uncomment this once Yanyu is computing aty_average_norm

highs/pdlp/cupdlp/cupdlp_utils.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ void writeSol(const char *fout, cupdlp_int nCols, cupdlp_int nRows,
17831783
}
17841784

17851785
void debugPdlpIterHeaderLog(FILE* file) {
1786-
fprintf(file, " Iter ||Ax|| ||Aty|| ||Ax_Avg|| ||Aty_Avg|| beta PrimalStep DualStep \n");
1786+
fprintf(file, " Iter ||Ax|| ||Aty|| ||Ax_Avg|| ||Aty_Avg|| ||x_avg|| beta PrimalStep DualStep \n");
17871787
}
17881788

17891789
void debugPdlpDataInitialise(struct DebugPdlpData* debug_pdlp) {
@@ -1794,12 +1794,13 @@ void debugPdlpDataInitialise(struct DebugPdlpData* debug_pdlp) {
17941794
}
17951795

17961796
void debugPdlpIterLog(FILE* file, const int iter_num, const struct DebugPdlpData* debug_pdlp, const double beta, const double primal_step, const double dual_step) {
1797-
fprintf(file, "%6d %11.4g %11.4g %11.4g %11.4g %11.4g %11.4g %11.4g\n",
1797+
fprintf(file, "%6d %11.4g %11.4g %11.4g %11.4g %11.4g %11.4g %11.4g %11.4g\n",
17981798
iter_num,
17991799
debug_pdlp->ax_norm,
18001800
debug_pdlp->aty_norm,
18011801
debug_pdlp->ax_average_norm,
18021802
debug_pdlp->aty_average_norm,
1803+
debug_pdlp->x_average_norm,
18031804
beta,
18041805
primal_step,
18051806
dual_step);

highs/pdlp/cupdlp/cupdlp_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void writeSol(const char *fout, cupdlp_int nCols, cupdlp_int nRows,
195195

196196
void debugPdlpIterHeaderLog(FILE* file);
197197
void debugPdlpDataInitialise(struct DebugPdlpData* debug_pdlp);
198-
void debugPdlpIterLog(FILE* file, const int iter_num, const struct DebugPdlpData* debug_pdlp, const double beta);
198+
void debugPdlpIterLog(FILE* file, const int iter_num, const struct DebugPdlpData* debug_pdlp, const double beta, const double primal_step, const double dual_step);
199199
void debugPdlpFeasOptLog(FILE* file,
200200
const int iter_num,
201201
const double primal_obj, const double dual_obj,

highs/pdlp/hipdlp/defs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct StepSizeConfig {
3838
double dual_step;
3939
double beta;
4040
double power_method_lambda;
41+
int step_size_iter = 0; //nStepSizeIter
4142
};
4243

4344
struct MalitskyPockParams {

highs/pdlp/hipdlp/pdhg.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,6 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
393393
(params_.step_size_strategy == StepSizeStrategy::MALITSKY_POCK);
394394
bool primal_average_initialized = false;
395395

396-
// Store iterates at last restart for primal weight update
397-
x_at_last_restart_ = x_current_;
398-
y_at_last_restart_ = y_current_;
399-
400396
logger_.print_iteration_header();
401397

402398
// --- 2. Main PDHG Loop ---

0 commit comments

Comments
 (0)