Skip to content

Commit c3588b1

Browse files
committed
Merge branch 'latest' of https://github.com/ERGO-Code/HiGHS into dualFixing
2 parents 7ed9e2a + 26c42ae commit c3588b1

File tree

5 files changed

+49
-52
lines changed

5 files changed

+49
-52
lines changed

highs/ipm/ipx/ipm.cc

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -821,13 +821,15 @@ void IPM::PrintHeader() {
821821
std::stringstream h_logging_stream;
822822
h_logging_stream.str(std::string());
823823
h_logging_stream
824-
<< (kTerminationLogging ? "\n" : "")
825-
<< " " << Format("Iter", 4)
826-
<< " " << Format("P.res", 8) << " " << Format("D.res", 8)
827-
<< " " << Format("P.obj", 15) << " " << Format("D.obj", 15)
828-
<< " " << Format("mu", 8);
824+
<< " " << Format("Iter", 4)
825+
<< " " << Format("primal obj", 15)
826+
<< " " << Format("dual obj", 15)
827+
<< " " << Format("pinf", 9)
828+
<< " " << Format("dinf", 9)
829+
<< " " << Format("gap", 8);
830+
// h_logging_stream << " " << Format("mu", 8);
829831
if (!control_.timelessLog())
830-
h_logging_stream << " " << Format("Time", 7);
832+
h_logging_stream << " " << Format("time", 7);
831833
control_.hLog(h_logging_stream);
832834
control_.Debug()
833835
<< " " << Format("stepsizes", 9)
@@ -841,17 +843,29 @@ void IPM::PrintHeader() {
841843
void IPM::PrintOutput() {
842844
const bool ipm_optimal = iterate_->feasible() && iterate_->optimal();
843845

844-
if (kTerminationLogging) PrintHeader();
846+
double logging_pobj = iterate_->pobjective_after_postproc();
847+
double logging_dobj = iterate_->dobjective_after_postproc();
848+
double logging_presidual = iterate_->presidual();
849+
double logging_dresidual = iterate_->dresidual();
850+
851+
// Now logging relative primal and dual infeasibility, and also
852+
// the relative primal dual objective gap
853+
logging_presidual /= iterate_->bounds_measure_;
854+
logging_dresidual /= iterate_->costs_measure_;
855+
double logging_gap = std::abs(logging_pobj - logging_dobj) /
856+
(1.0+0.5 *std::fabs(logging_pobj + logging_dobj));
857+
845858
std::stringstream h_logging_stream;
846859
h_logging_stream.str(std::string());
847860
h_logging_stream
848861
<< " " << Format(info_->iter, 3)
849862
<< (ipm_optimal ? "*" : " ")
850-
<< " " << Scientific(iterate_->presidual(), 8, 2)
851-
<< " " << Scientific(iterate_->dresidual(), 8, 2)
852-
<< " " << Scientific(iterate_->pobjective_after_postproc(), 15, 8)
853-
<< " " << Scientific(iterate_->dobjective_after_postproc(), 15, 8)
854-
<< " " << Scientific(iterate_->mu(), 8, 2);
863+
<< " " << Scientific(logging_pobj, 15, 8)
864+
<< " " << Scientific(logging_dobj, 15, 8)
865+
<< " " << Scientific(logging_presidual, 9, 2)
866+
<< " " << Scientific(logging_dresidual, 9, 2)
867+
<< " " << Scientific(logging_gap, 8, 2);
868+
// h_logging_stream << " " << Scientific(iterate_->mu(), 8, 2);
855869
if (!control_.timelessLog())
856870
h_logging_stream << " " << Fixed(control_.Elapsed(), 6, 0) << "s";
857871
control_.hLog(h_logging_stream);

highs/ipm/ipx/iterate.cc

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Iterate::Iterate(const Model& model) : model_(model) {
5555
}
5656
}
5757
assert_consistency();
58+
this->bounds_measure_ = 1.0 + model_.norm_bounds();
59+
this->costs_measure_ = 1.0 + model_.norm_c();
60+
5861
}
5962

6063
void Iterate::Initialize(const Vector& x, const Vector& xl, const Vector& xu,
@@ -219,40 +222,21 @@ double Iterate::mu_max() const { Evaluate(); return mu_max_; }
219222

220223
bool Iterate::feasible() const {
221224
Evaluate();
222-
const double bounds_measure = 1.0 + model_.norm_bounds();
223-
const double costs_measure = 1.0 + model_.norm_c();
224-
const double rel_presidual = presidual_ / bounds_measure;
225-
const double rel_dresidual = dresidual_ / costs_measure;
226-
const bool primal_feasible = presidual_ <= feasibility_tol_ * (bounds_measure);
227-
const bool dual_feasible = dresidual_ <= feasibility_tol_ * (costs_measure);
225+
const bool primal_feasible = presidual_ <= feasibility_tol_ * bounds_measure_;
226+
const bool dual_feasible = dresidual_ <= feasibility_tol_ * costs_measure_;
228227
const bool is_feasible = primal_feasible && dual_feasible;
229-
if (kTerminationLogging) {
230-
printf("\nIterate::feasible presidual_ = %11.4g; bounds_measure = %11.4g; "
231-
"rel_presidual = %11.4g; feasibility_tol = %11.4g: primal_feasible = %d\n",
232-
presidual_, bounds_measure, rel_presidual, feasibility_tol_, primal_feasible);
233-
printf("Iterate::feasible dresidual_ = %11.4g; costs_measure = %11.4g; "
234-
"rel_dresidual = %11.4g; feasibility_tol = %11.4g: dual_feasible = %d\n",
235-
dresidual_, costs_measure, rel_dresidual, feasibility_tol_, dual_feasible);
236-
}
237228
return is_feasible;
238229
}
239230

240231
bool Iterate::optimal() const {
241232
Evaluate();
242233
double pobj = pobjective_after_postproc();
243234
double dobj = dobjective_after_postproc();
244-
double obj = 0.5 * (pobj + dobj);
235+
double ave_obj = 0.5 * (pobj + dobj);
245236
double gap = pobj - dobj;
246237
const double abs_gap = std::abs(gap);
247-
const double obj_measure = 1.0+std::abs(obj);
238+
const double obj_measure = 1.0+std::abs(ave_obj);
248239
const bool is_optimal = abs_gap <= optimality_tol_ * obj_measure;
249-
if (kTerminationLogging) {
250-
const double rel_gap = abs_gap / obj_measure;
251-
printf("Iterate::optimal abs_gap = %11.4g;"
252-
" obj_measure = %11.4g; rel_gap = %11.4g;"
253-
" optimality_tol = %11.4g: optimal = %d\n",
254-
abs_gap, obj_measure, rel_gap, optimality_tol_, is_optimal);
255-
}
256240
return is_optimal;
257241
}
258242

highs/ipm/ipx/iterate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ class Iterate {
199199
// The method can only be called after Postprocess().
200200
void DropToComplementarity(Vector& x, Vector& y, Vector& z) const;
201201

202+
double bounds_measure_;
203+
double costs_measure_;
204+
202205
private:
203206
// A (primal or dual) variable that is required to be positive in the IPM is
204207
// not moved closer to zero than kBarrierMin.

highs/ipm/ipx/utils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include <vector>
55
#include "ipm/ipx/ipx_internal.h"
66

7-
const bool kTerminationLogging = false;
8-
97
namespace ipx {
108

119
bool AllFinite(const Vector& x);

highs/pdlp/cupdlp/cupdlp_solver.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -843,15 +843,14 @@ void PDHG_Print_Iter(CUPDLPwork *pdhg) {
843843
else
844844
cupdlp_snprintf(timeString, 8, "%6ds", (cupdlp_int)timers->dSolvingTime);
845845

846-
// cupdlp_printf("%9d %+15.8e %+15.8e %+8.2e %8.2e %10.2e %8.2e %7s
847-
// [L]\n",
848-
// timers->nIter, resobj->dPrimalObj, resobj->dDualObj,
849-
// resobj->dDualityGap, resobj->dComplementarity,
850-
// resobj->dPrimalFeas, resobj->dDualFeas, timeString);
851-
846+
CUPDLPscaling *scaling = pdhg->scaling;
847+
const double gap_log_value = resobj->dRelObjGap;
848+
const double primal_feas_log_value = resobj->dPrimalFeas / (1.0 + scaling->dNormRhs);
849+
const double dual_feas_log_value = resobj->dDualFeas / (1.0 + scaling->dNormCost);
852850
cupdlp_printf("%9d %+15.8e %+15.8e %+8.2e %10.2e %8.2e %7s [L]\n",
853851
timers->nIter, resobj->dPrimalObj, resobj->dDualObj,
854-
resobj->dDualityGap, resobj->dPrimalFeas, resobj->dDualFeas,
852+
// resobj->dDualityGap, resobj->dPrimalFeas, resobj->dDualFeas,
853+
gap_log_value, primal_feas_log_value, dual_feas_log_value,
855854
timeString);
856855
}
857856

@@ -865,16 +864,15 @@ void PDHG_Print_Iter_Average(CUPDLPwork *pdhg) {
865864
else
866865
cupdlp_snprintf(timeString, 8, "%6ds", (cupdlp_int)timers->dSolvingTime);
867866

868-
// cupdlp_printf("%9d %+15.8e %+15.8e %+8.2e %8.2e %10.2e %8.2e %7s
869-
// [A]\n",
870-
// timers->nIter, resobj->dPrimalObjAverage,
871-
// resobj->dDualObjAverage, resobj->dDualityGapAverage,
872-
// resobj->dComplementarityAverage, resobj->dPrimalFeasAverage,
873-
// resobj->dDualFeasAverage, timeString);
867+
CUPDLPscaling *scaling = pdhg->scaling;
868+
const double gap_log_value = resobj->dRelObjGapAverage;
869+
const double primal_feas_log_value = resobj->dPrimalFeasAverage / (1.0 + scaling->dNormRhs);
870+
const double dual_feas_log_value = resobj->dDualFeasAverage / (1.0 + scaling->dNormCost);
874871
cupdlp_printf("%9d %+15.8e %+15.8e %+8.2e %10.2e %8.2e %7s [A]\n",
875872
timers->nIter, resobj->dPrimalObjAverage,
876-
resobj->dDualObjAverage, resobj->dDualityGapAverage,
877-
resobj->dPrimalFeasAverage, resobj->dDualFeasAverage,
873+
resobj->dDualObjAverage,
874+
// resobj->dDualityGapAverage, resobj->dPrimalFeasAverage, resobj->dDualFeasAverage,
875+
gap_log_value, primal_feas_log_value, dual_feas_log_value,
878876
timeString);
879877
}
880878

0 commit comments

Comments
 (0)