Skip to content

Commit 36884ec

Browse files
committed
wip
1 parent a3eb935 commit 36884ec

File tree

8 files changed

+33
-17
lines changed

8 files changed

+33
-17
lines changed

check/TestPdlp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ TEST_CASE("pdlp-restart-add-row", "[pdlp]") {
333333
}
334334

335335
TEST_CASE("hi-pdlp", "[pdlp]") {
336-
std::string model = "adlittle"; //"adlittle";//"afiro";//
336+
std::string model = "afiro"; //"adlittle";//"afiro";//
337337
std::string model_file =
338338
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
339339
Highs h;

highs/pdlp/CupdlpWrapper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
205205
&pdlp_num_iter);
206206
highs_info.pdlp_iteration_count = pdlp_num_iter;
207207

208+
// Print final solution using debugPdlpFinalSolutionLog
209+
debugPdlpFinalSolutionLog(w->debug_pdlp_log_file, highs_solution.col_value.data(), lp.num_col_, highs_solution.row_dual.data(), lp.num_row_);
210+
fclose(w->debug_pdlp_log_file);
208211
model_status = HighsModelStatus::kUnknown;
209212
highs_solution.value_valid = value_valid;
210213
highs_solution.dual_valid = dual_valid;

highs/pdlp/HiPdlpWrapper.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "pdlp/hipdlp/logger.hpp"
1515
#include "pdlp/hipdlp/pdhg.hpp"
1616
#include "pdlp/hipdlp/restart.hpp"
17+
#include "pdlp/cupdlp/cupdlp_utils.h"
1718

1819
HighsStatus solveLpHiPdlp(HighsLpSolverObject& solver_object) {
1920
return solveLpHiPdlp(solver_object.options_, solver_object.timer_,
@@ -67,11 +68,8 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
6768
}
6869

6970
// print col_value and row_dual
70-
for (HighsInt i = 0; i < pdlp_solution.col_value.size(); i++)
71-
printf("x[%d]=%g\n", (int)i, pdlp_solution.col_value[i]);
72-
for (HighsInt i = 0; i < pdlp_solution.row_dual.size(); i++)
73-
printf("y[%d]=%g\n", (int)i, pdlp_solution.row_dual[i]);
74-
71+
debugPdlpFinalSolutionLog(pdlp.debug_pdlp_log_file_, pdlp_solution.col_value.data(), lp.num_col_, pdlp_solution.row_dual.data(), lp.num_row_);
72+
pdlp.solveReturn();
7573
// --- Print Summary ---
7674
pdlp.logSummary();
7775

@@ -121,14 +119,14 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
121119
assert(termination_status == TerminationStatus::OPTIMAL ||
122120
termination_status == TerminationStatus::TIMEOUT);
123121
//highs_solution.col_value = x;
124-
highs_solution.col_value.resize(lp.num_col_);
122+
//highs_solution.col_value.resize(lp.num_col_);
125123
//highs_solution.row_dual = y;
126-
lp.a_matrix_.product(highs_solution.row_value, highs_solution.col_value);
127-
lp.a_matrix_.productTranspose(highs_solution.col_dual,
128-
highs_solution.row_dual);
129-
for (HighsInt iCol = 0; iCol < lp.num_col_; iCol++)
130-
highs_solution.col_dual[iCol] =
131-
lp.col_cost_[iCol] - highs_solution.col_dual[iCol];
124+
//lp.a_matrix_.product(highs_solution.row_value, highs_solution.col_value);
125+
//lp.a_matrix_.productTranspose(highs_solution.col_dual,
126+
// highs_solution.row_dual);
127+
//for (HighsInt iCol = 0; iCol < lp.num_col_; iCol++)
128+
// highs_solution.col_dual[iCol] =
129+
// lp.col_cost_[iCol] - highs_solution.col_dual[iCol];
132130
highs_solution.value_valid = true;
133131
highs_solution.dual_valid = true;
134132
return HighsStatus::kOk;

highs/pdlp/cupdlp/cupdlp_solver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ cupdlp_retcode PDHG_Solve(const cupdlp_int* has_variables, CUPDLPwork *pdhg) {
11521152
#endif
11531153

11541154
exit_cleanup:
1155-
fclose(pdhg->debug_pdlp_log_file);
1155+
//fclose(pdhg->debug_pdlp_log_file);
11561156
return retcode;
11571157
}
11581158

highs/pdlp/cupdlp/cupdlp_utils.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,4 +1804,15 @@ void debugPdlpRestarScoretLog(FILE* file, const double weight_squared, const dou
18041804
const double dual_feas, const double obj_gap) {
18051805
fprintf(file, "Restart Score: Weight^2 = %.6g, Primal Feas = %.6g, Dual Feas = %.6g, Obj Gap = %.6g\n",
18061806
weight_squared, primal_feas, dual_feas, obj_gap);
1807+
}
1808+
1809+
void debugPdlpFinalSolutionLog(FILE* file, const double* x, int nCols, const double* y, int nRows) {
1810+
fprintf(file,"Primal solution (x):\n");
1811+
for (int i = 0; i < nCols; ++i) {
1812+
fprintf(file, "x[%d]=%g\n", i, x[i]);
1813+
}
1814+
fprintf(file, "Dual solution (y):\n");
1815+
for (int i = 0; i < nRows; ++i) {
1816+
fprintf(file, "y[%d]=%g\n", i, y[i]);
1817+
}
18071818
}

highs/pdlp/cupdlp/cupdlp_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void writeSol(const char *fout, cupdlp_int nCols, cupdlp_int nRows,
198198
void debugPdlpAtyNormLog(FILE* file, const double aty_norm);
199199
void debugPdlpRestartLog(FILE* file, const int iter_num, const double current_score, const double average_score);
200200
void debugPdlpRestarScoretLog(FILE* file, const double weight_squared, const double primal_feas, const double dual_feas, const double obj_gap);
201+
void debugPdlpFinalSolutionLog(FILE* file, const double* x, int nCols, const double* y, int nRows);
201202

202203

203204
#ifdef __cplusplus

highs/pdlp/hipdlp/pdhg.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
468468
results_ = current_results;
469469
results_.term_code = TerminationStatus::OPTIMAL;
470470

471-
return solveReturn();
471+
//return solveReturn();
472+
return ;
472473
}
473474

474475
// --- 6. Restart Check ---

highs/pdlp/hipdlp/pdhg.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class PDLPSolver {
5151
int getIterationCount() const { return final_iter_count_; }
5252
void logSummary();
5353

54+
void solveReturn();
55+
FILE* debug_pdlp_log_file_ = nullptr;
56+
5457
private:
5558
// Problem data
5659
HighsLp lp_; // The problem to solve
@@ -97,11 +100,10 @@ class PDLPSolver {
97100
std::vector<double> dSlackPos_;
98101
std::vector<double> dSlackNeg_;
99102

100-
FILE* debug_pdlp_log_file_ = nullptr;
103+
101104
Timer total_timer;
102105

103106
// Helper functions
104-
void solveReturn();
105107
void Initialize(const HighsLp& lp, std::vector<double>& x,
106108
std::vector<double>& y);
107109
SolverResults results_;

0 commit comments

Comments
 (0)