Skip to content

Commit b43e0b3

Browse files
committed
large bound duals warning is displayed only once
1 parent 56afc29 commit b43e0b3

File tree

2 files changed

+10
-97
lines changed

2 files changed

+10
-97
lines changed

src/Optimization/hiopAlgFilterIPM.cpp

Lines changed: 5 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ hiopAlgFilterIPMBase::hiopAlgFilterIPMBase(hiopNlpFormulation* nlp_in, const boo
9797
d_soc(nullptr),
9898
within_FR_(within_FR),
9999
pd_perturb_(nullptr),
100-
fact_acceptor_(nullptr)
100+
fact_acceptor_(nullptr),
101+
warn_large_bnd_duals_(false)
101102
{
102103
// force completion of the nlp's initialization
103104
nlp->finalizeInitialization();
@@ -662,7 +663,7 @@ bool hiopAlgFilterIPMBase::evalNlpAndLogErrors(const hiopIterate& it,
662663
}
663664

664665
nlp->log->printf(hovIteration, "nrmOneDualEqu %g nrmOneDualBo %g\n", nrmDualEqu, nrmDualBou);
665-
if(nrmDualBou > 1e+10) {
666+
if(nrmDualBou > 1e+10 && !warn_large_bnd_duals_) {
666667
nlp->log->printf(hovWarning,
667668
"Unusually large bound dual variables (norm1=%g) occured, \n"
668669
" which may cause numerical instabilities, convergence issues, \n"
@@ -673,7 +674,8 @@ bool hiopAlgFilterIPMBase::evalNlpAndLogErrors(const hiopIterate& it,
673674

674675
nlp->log->printf(hovWarning,
675676
"HiOp options 'fixed_var_tolerance', 'bound_relax_perturb', or \n"
676-
" 'elastic_mode' may remedy this issue. Also see 'scaling_type' option.\n");
677+
" 'elastic_mode' may remedy this issue. Also see 'scaling_type' option.\n");
678+
warn_large_bnd_duals_ = true;
677679
}
678680

679681
// scaling factors
@@ -710,99 +712,6 @@ bool hiopAlgFilterIPMBase::evalNlpAndLogErrors(const hiopIterate& it,
710712
return true;
711713
}
712714

713-
// bool hiopAlgFilterIPMBase::evalNlpAndLogErrors2(const hiopIterate& it,
714-
// const hiopResidual& resid,
715-
// const double& mu,
716-
// double& nlpoptim,
717-
// double& nlpfeas,
718-
// double& nlpcomplem,
719-
// double& nlpoverall,
720-
// double& logoptim,
721-
// double& logfeas,
722-
// double& logcomplem,
723-
// double& logoverall,
724-
// double& cons_violation)
725-
// {
726-
// nlp->runStats.tmSolverInternal.start();
727-
728-
// size_type n = nlp->n_complem();
729-
// double sc;
730-
// double sd;
731-
// double nrmDualBou;
732-
// double nrmDualEqu;
733-
// if(!it.compute_sc_sd(sc, sd, nrmDualEqu, nrmDualBou)) {
734-
// return false;
735-
// }
736-
737-
// nlp->log->printf(hovWarning, "nrmOneDualEqu %g nrmOneDualBo %g\n", nrmDualEqu, nrmDualBou);
738-
// if(nrmDualBou > 1e+10) {
739-
// nlp->log->printf(hovWarning,
740-
// "Unusually large bound dual variables (norm1=%g) occured, "
741-
// "which may cause numerical instabilities if it persists. Convergence "
742-
// " issues or inacurate optimal solutions may be experienced. Possible causes: "
743-
// " tight bounds or bad scaling of the optimization variables.\n",
744-
// nrmDualBou);
745-
// if(nlp->options->GetString("fixed_var") == "remove") {
746-
// nlp->log->printf(hovWarning,
747-
// "For example, increase 'fixed_var_tolerance' to remove "
748-
// "additional variables.\n");
749-
// } else if(nlp->options->GetString("fixed_var") == "relax") {
750-
// nlp->log->printf(hovWarning,
751-
// "For example, increase 'fixed_var_tolerance' to relax "
752-
// "aditional (tight) variables and/or increase 'fixed_var_perturb' "
753-
// "to decrease the tightness.\n");
754-
// } else {
755-
// nlp->log->printf(hovWarning,
756-
// "Potential fixes: fix or relax variables with tight bounds "
757-
// "(see 'fixed_var' option) or rescale variables.\n");
758-
// }
759-
// }
760-
761-
// // scaling factors
762-
// //sd = max { p_smax, ||zl||_M + ||zu||_M + (||vl||_1 + ||vu||_1)/m } /p_smax
763-
// //sc = max { p_smax, ||zl||_M + ||zu||_M } /p_smax
764-
// //nlpoptim = ||gradf + Jc'*yc + Jd'*Jd - M*zl - M*zu||_Hinv
765-
// // ||yd+vl-vu||_inf
766-
// //nlpfeas = ||crhs- c||_inf
767-
// // ||drs- d||_inf
768-
// // ||x-sxl-xl||_inf
769-
// // ||x-sxu+xu||_inf
770-
// // ||d-sdl-dl||
771-
// //
772-
// //double sd = fmax(p_smax, (nrmDualBou + nrmDualEqu) / (n + m)) / p_smax;
773-
// //double sc = n == 0 ? 0 : fmax(p_smax, nrmDualBou / n) / p_smax;
774-
775-
// sd = fmax(p_smax, sd) / p_smax;
776-
// sc = n == 0 ? 0 : fmax(p_smax, sc) / p_smax;
777-
778-
// sd = fmin(sd, 1e+8);
779-
// sc = fmin(sc, 1e+8);
780-
781-
// // actual nlp errors
782-
// resid.getNlpErrors(nlpoptim, nlpfeas, nlpcomplem, cons_violation);
783-
784-
// // finally, the scaled nlp error
785-
// nlpoverall = fmax(nlpoptim / sd, fmax(cons_violation, nlpcomplem / sc));
786-
787-
// nlp->log->printf(hovWarning,
788-
// "nlpoverall %g nloptim %g sd %g nlpfeas %g nlpcomplem %g sc %g cons_violation %g\n",
789-
// nlpoverall,
790-
// nlpoptim,
791-
// sd,
792-
// nlpfeas,
793-
// nlpcomplem,
794-
// cons_violation,
795-
// sc);
796-
797-
// // actual log errors
798-
// resid.getBarrierErrors(logoptim, logfeas, logcomplem);
799-
800-
// // finally, the scaled barrier error
801-
// logoverall = fmax(logoptim / sd, fmax(cons_violation, logcomplem / sc));
802-
// nlp->runStats.tmSolverInternal.stop();
803-
// return true;
804-
// }
805-
806715
bool hiopAlgFilterIPMBase::evalNlp_funcOnly(hiopIterate& iter, double& f, hiopVector& c, hiopVector& d)
807716
{
808717
bool new_x = true;

src/Optimization/hiopAlgFilterIPM.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,13 @@ class hiopAlgFilterIPMBase
345345

346346
/* Flag to tell if this is a FR problem */
347347
bool within_FR_;
348-
348+
349349
hiopPDPerturbation* pd_perturb_;
350350
hiopFactAcceptor* fact_acceptor_;
351+
352+
/// Flag that tracks whether the warning "Unusually large bound dual variables" has been issued.
353+
bool warn_large_bnd_duals_;
354+
351355
};
352356

353357
class hiopAlgFilterIPMQuasiNewton : public hiopAlgFilterIPMBase

0 commit comments

Comments
 (0)