Skip to content

Commit d80bbbe

Browse files
committed
vectorize projection
1 parent 3dbe848 commit d80bbbe

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

check/TestPdlp.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ TEST_CASE("pdlp-restart-add-row", "[pdlp]") {
336336

337337
TEST_CASE("hi-pdlp", "[pdlp]") {
338338
std::string model =
339-
"adlittle"; //"adlittle";//"afiro";// shell// stair //25fv47 //fit2p
339+
"25fv47"; //"adlittle";//"afiro";// shell// stair //25fv47 //fit2p
340340
std::string model_file =
341341
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
342342
Highs h;
@@ -346,20 +346,19 @@ TEST_CASE("hi-pdlp", "[pdlp]") {
346346
h.setOptionValue("kkt_tolerance", kkt_tolerance);
347347
h.setOptionValue("presolve", "off");
348348

349-
HighsInt pdlp_features_off =
349+
HighsInt pdlp_features_off = 0
350350
// kPdlpScalingOff +
351351
// kPdlpRestartOff
352-
kPdlpAdaptiveStepSizeOff;
352+
//+ kPdlpAdaptiveStepSizeOff
353+
;
353354
h.setOptionValue("pdlp_features_off", pdlp_features_off);
354355

355356
HighsInt pdlp_scaling = // 0;
356357
kPdlpScalingRuiz
357358
//+ kPdlpScalingL2
358359
+ kPdlpScalingPC;
359360
h.setOptionValue("pdlp_scaling_mode", pdlp_scaling);
360-
h.setOptionValue("pdlp_step_size_strategy", 1);
361-
h.setOptionValue("pdlp_restart_strategy", 2);
362-
h.setOptionValue("pdlp_iteration_limit", 3520);
361+
//h.setOptionValue("pdlp_iteration_limit", 3520);
363362
// h.setOptionValue("log_dev_level", kHighsLogDevLevelVerbose);
364363
auto start_hipdlp = std::chrono::high_resolution_clock::now();
365364
HighsStatus run_status = h.run();

highs/pdlp/hipdlp/linalg.cc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@ double project_non_negative(double x) { return std::max(0.0, x); }
2222

2323
void project_bounds(const HighsLp& lp, std::vector<double>& x) {
2424
for (HighsInt i = 0; i < lp.num_col_; ++i) {
25-
// Project to upper bound
26-
if (x[i] > lp.col_upper_[i]) {
27-
x[i] = lp.col_upper_[i];
28-
}
29-
// Project to lower bound
30-
if (x[i] < lp.col_lower_[i]) {
31-
x[i] = lp.col_lower_[i];
32-
}
25+
x[i] = std::max(lp.col_lower_[i], std::min(x[i], lp.col_upper_[i]));
3326
}
3427
}
3528

highs/pdlp/hipdlp/pdhg.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,12 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
635635

636636
restart_scheme_.last_restart_iter_ = iter;
637637
// Recompute Ax and ATy for the restarted iterates
638+
hipdlpTimerStart(kHipdlpClockMatrixMultiply);
638639
linalg::Ax(lp, x_current_, Ax_cache_);
640+
hipdlpTimerStop(kHipdlpClockMatrixMultiply);
641+
hipdlpTimerStart(kHipdlpClockMatrixTransposeMultiply);
639642
linalg::ATy(lp, y_current_, ATy_cache_);
643+
hipdlpTimerStop(kHipdlpClockMatrixTransposeMultiply);
640644

641645
restart_scheme_.SetLastRestartIter(iter);
642646
}
@@ -679,9 +683,12 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
679683

680684
// Compute ATy for the new iterate
681685
Ax_cache_ = Ax_next_;
686+
/*
682687
hipdlpTimerStart(kHipdlpClockMatrixTransposeMultiply);
683688
linalg::ATy(lp, y_next_, ATy_cache_);
684689
hipdlpTimerStop(kHipdlpClockMatrixTransposeMultiply);
690+
*/
691+
ATy_cache_ = ATy_next_;
685692

686693
hipdlpTimerStop(kHipdlpClockIterateUpdate);
687694

@@ -1400,6 +1407,10 @@ void PDLPSolver::updateIteratesFixed() {
14001407
hipdlpTimerStart(kHipdlpClockProjectY);
14011408
y_next_ = updateY(y_current_, Ax_cache_, Ax_next_, stepsize_.dual_step);
14021409
hipdlpTimerStop(kHipdlpClockProjectY);
1410+
1411+
hipdlpTimerStart(kHipdlpClockMatrixTransposeMultiply);
1412+
linalg::ATy(lp_, y_next_, ATy_next_);
1413+
hipdlpTimerStop(kHipdlpClockMatrixTransposeMultiply);
14031414
}
14041415

14051416
void PDLPSolver::updateIteratesAdaptive() {

0 commit comments

Comments
 (0)