Skip to content

Commit a5a91cc

Browse files
committed
IPX now logging as HiPO
1 parent 94e9932 commit a5a91cc

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

highs/ipm/ipx/ipm.cc

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,14 @@ void IPM::PrintHeader() {
823823
h_logging_stream
824824
<< (kTerminationLogging ? "\n" : "")
825825
<< " " << 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);
826+
<< " " << Format("primal obj", 15)
827+
<< " " << Format("dual obj", 15)
828+
<< " " << Format("pinf", 9)
829+
<< " " << Format("dinf", 9)
830+
<< " " << Format("gap", 8);
831+
// h_logging_stream << " " << Format("mu", 8);
829832
if (!control_.timelessLog())
830-
h_logging_stream << " " << Format("Time", 7);
833+
h_logging_stream << " " << Format("time", 7);
831834
control_.hLog(h_logging_stream);
832835
control_.Debug()
833836
<< " " << Format("stepsizes", 9)
@@ -842,16 +845,29 @@ void IPM::PrintOutput() {
842845
const bool ipm_optimal = iterate_->feasible() && iterate_->optimal();
843846

844847
if (kTerminationLogging) PrintHeader();
848+
double logging_pobj = iterate_->pobjective_after_postproc();
849+
double logging_dobj = iterate_->dobjective_after_postproc();
850+
double logging_presidual = iterate_->presidual();
851+
double logging_dresidual = iterate_->dresidual();
852+
853+
// Now logging relative primal and dual infeasibility, and also
854+
// the relative primal dual objective gap
855+
logging_presidual /= (1.0 + iterate_->bounds_measure_);
856+
logging_dresidual /= (1.0 + iterate_->costs_measure_);
857+
double logging_gap = std::abs(logging_pobj - logging_dobj) /
858+
(1.0+0.5 *std::fabs(logging_pobj + logging_dobj));
859+
845860
std::stringstream h_logging_stream;
846861
h_logging_stream.str(std::string());
847862
h_logging_stream
848863
<< " " << Format(info_->iter, 3)
849864
<< (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);
865+
<< " " << Scientific(logging_pobj, 15, 8)
866+
<< " " << Scientific(logging_dobj, 15, 8)
867+
<< " " << Scientific(logging_presidual, 9, 2)
868+
<< " " << Scientific(logging_dresidual, 9, 2)
869+
<< " " << Scientific(logging_gap, 8, 2);
870+
// h_logging_stream << " " << Scientific(iterate_->mu(), 8, 2);
855871
if (!control_.timelessLog())
856872
h_logging_stream << " " << Fixed(control_.Elapsed(), 6, 0) << "s";
857873
control_.hLog(h_logging_stream);

highs/ipm/ipx/iterate.cc

Lines changed: 9 additions & 8 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,20 +222,18 @@ 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 double rel_presidual = presidual_ / bounds_measure_;
226+
const double rel_dresidual = dresidual_ / costs_measure_;
227+
const bool primal_feasible = presidual_ <= feasibility_tol_ * (bounds_measure_);
228+
const bool dual_feasible = dresidual_ <= feasibility_tol_ * (costs_measure_);
228229
const bool is_feasible = primal_feasible && dual_feasible;
229230
if (kTerminationLogging) {
230231
printf("\nIterate::feasible presidual_ = %11.4g; bounds_measure = %11.4g; "
231232
"rel_presidual = %11.4g; feasibility_tol = %11.4g: primal_feasible = %d\n",
232-
presidual_, bounds_measure, rel_presidual, feasibility_tol_, primal_feasible);
233+
presidual_, bounds_measure_, rel_presidual, feasibility_tol_, primal_feasible);
233234
printf("Iterate::feasible dresidual_ = %11.4g; costs_measure = %11.4g; "
234235
"rel_dresidual = %11.4g; feasibility_tol = %11.4g: dual_feasible = %d\n",
235-
dresidual_, costs_measure, rel_dresidual, feasibility_tol_, dual_feasible);
236+
dresidual_, costs_measure_, rel_dresidual, feasibility_tol_, dual_feasible);
236237
}
237238
return is_feasible;
238239
}

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.

0 commit comments

Comments
 (0)