Skip to content

Commit

Permalink
Applied IPX commit b4bc41eabf6476101e2355312e51afa090c791d6
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Dec 13, 2022
1 parent e5ea838 commit e9f424f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/ipm/ipx/ipm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,31 @@ void IPM::Driver(KKTSolver* kkt, Iterate* iterate, Info* info) {
info->status_ipm = IPX_STATUS_optimal;
break;
}
if (info->iter >= maxiter_) {
info->status_ipm = IPX_STATUS_iter_limit;
if (num_bad_iter_ >= 5 ||
iterate_->complementarity() > kDivergeTol * best_complementarity_) {
// No progress in reducing the complementarity gap.
// Check if model seems to be primal or dual infeasible.
bool dualized = iterate_->model().dualized();
double pobjective = iterate_->pobjective_after_postproc();
double dobjective = iterate_->dobjective_after_postproc();
if (dobjective > std::max(10.0 * std::abs(pobjective), 1.0)) {
// Dual objective tends to positive infinity. Looks like the
// model is dual unbounded, i.e. primal infeasible.
info->status_ipm = dualized ?
IPX_STATUS_dual_infeas : IPX_STATUS_primal_infeas;
} else if (pobjective < -std::max(10.0 * std::abs(dobjective), 1.0)) {
// Primal objective tends to negative infinity. Looks like the
// model is primal unbounded, i.e. dual infeasible.
info->status_ipm = dualized ?
IPX_STATUS_primal_infeas : IPX_STATUS_dual_infeas;
}
else {
info->status_ipm = IPX_STATUS_no_progress;
}
break;
}
if (num_bad_iter_ >= 5) {
info->status_ipm = IPX_STATUS_no_progress;
if (info->iter >= maxiter_) {
info->status_ipm = IPX_STATUS_iter_limit;
break;
}
if ((info->errflag = control_.InterruptCheck()) != 0)
Expand Down Expand Up @@ -222,6 +241,7 @@ void IPM::ComputeStartingPoint() {
zu[j] += zshift2;
}
iterate_->Initialize(x, xl, xu, y, zl, zu);
best_complementarity_ = iterate_->complementarity();
}

// Computes maximum alpha such that x + alpha*dx >= 0.
Expand Down Expand Up @@ -435,6 +455,8 @@ void IPM::MakeStep(const Step& step) {
num_bad_iter_++;
else
num_bad_iter_ = 0;
best_complementarity_ =
std::min(best_complementarity_, iterate_->complementarity());
}

void IPM::SolveNewtonSystem(const double* rb, const double* rc,
Expand Down
7 changes: 7 additions & 0 deletions src/ipm/ipx/ipm.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class IPM {

private:
struct Step;
// IPM terminates when the complementarity gap of the current iterate
// exceeds kDivergeTol times the smallest complementarity gap of all
// iterates so far.
static constexpr double kDivergeTol = 1e6;

void ComputeStartingPoint();
void Predictor(Step& step);
Expand Down Expand Up @@ -71,6 +75,9 @@ class IPM {
// Counts the # bad iterations since the last good iteration. An iteration
// is bad if the primal or dual step size is < 0.05.
Int num_bad_iter_{0};
// Smallest complementarity gap of all iterates so far.
double best_complementarity_{0.0};

Int maxiter_{-1};
};

Expand Down

0 comments on commit e9f424f

Please sign in to comment.