Skip to content

Commit b038d5b

Browse files
committed
fix offset in obj
1 parent 348e2c0 commit b038d5b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

highs/pdlp/hipdlp/pdhg.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ void PDLPSolver::preprocessLp() {
4747
logger_.info("Original LP matrix must be in column-wise format,");
4848
}
4949

50+
lp_.offset_ = original_lp_->offset_;
51+
5052
int num_new_cols = 0;
5153
int nEqs = 0;
5254
constraint_types_.resize(nRows_orig);
@@ -378,8 +380,8 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
378380
x_current_ = x;
379381
y_current_ = y;
380382
linalg::project_bounds(lp_, x_current_);
381-
x_sum_ = x_current_;
382-
x_avg_ = x_current_;
383+
linalg::project_bounds(lp_, x_sum_);
384+
linalg::project_bounds(lp_, x_avg_);
383385
linalg::Ax(lp, x_current_, Ax_cache_);
384386
std::vector<double> Ax_avg = Ax_cache_;
385387
std::vector<double> ATy_avg(lp.num_col_, 0.0);
@@ -507,9 +509,7 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
507509

508510
// Recompute Ax and ATy for the restarted iterates
509511
linalg::Ax(lp, x_current_, Ax_cache_);
510-
debug_pdlp_data_.ax_norm = linalg::vector_norm(Ax_cache_);
511512
linalg::ATy(lp, y_current_, ATy_cache_);
512-
debug_pdlp_data_.aty_norm = linalg::vector_norm(ATy_cache_);
513513
restart_scheme_.SetLastRestartIter(iter);
514514

515515
//continue; //same logic as cupdlp
@@ -816,7 +816,7 @@ PDLPSolver::ComputeDualityGap(const std::vector<double>& x,
816816
}
817817

818818
double PDLPSolver::ComputeDualObjective(const std::vector<double>& y) {
819-
double dual_obj = 0.0;
819+
double dual_obj = lp_.offset_;
820820

821821
// Compute b'y (or rhs'y in cuPDLP notation)
822822
for (int i = 0; i < lp_.num_row_; ++i) {
@@ -851,19 +851,19 @@ bool PDLPSolver::CheckConvergence(const int iter, const std::vector<double>& x,
851851

852852
// Compute primal feasibility
853853
double primal_feasibility =
854-
ComputePrimalFeasibility(ax_vector);
854+
ComputePrimalFeasibility(ax_vector);
855855
results.primal_feasibility = primal_feasibility;
856856

857857
// Compute dual feasibility
858858
double dual_feasibility = ComputeDualFeasibility(aty_vector);
859859
results.dual_feasibility = dual_feasibility;
860860

861861
// Compute objectives
862-
double primal_obj = 0.0;
862+
double primal_obj = lp_.offset_;
863863
for (int i = 0; i < lp_.num_col_; ++i) {
864864
primal_obj += lp_.col_cost_[i] * x[i];
865865
}
866-
results.primal_obj = primal_obj;
866+
results.primal_obj = primal_obj ;
867867

868868
double dual_obj = ComputeDualObjective(y);
869869
results.dual_obj = dual_obj;

highs/pdlp/hipdlp/scaling.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ void Scaling::ApplyScaling(const std::vector<double>& col_scaling,
305305
lp_->a_matrix_.value_[el] /= (row_scaling[row] * col_scaling[col]);
306306
}
307307
}
308+
309+
//TO DO: scale offset
310+
308311
}
309312

310313
void Scaling::unscaleSolution(std::vector<double>& x,

0 commit comments

Comments
 (0)