@@ -715,6 +715,94 @@ bool hiopAlgFilterIPMBase::evalNlpAndLogErrors(const hiopIterate& it,
715715 return true ;
716716}
717717
718+ bool hiopAlgFilterIPMBase::evalNlpAndLogErrors2 (const hiopIterate& it,
719+ const hiopResidual& resid,
720+ const double & mu,
721+ double & nlpoptim,
722+ double & nlpfeas,
723+ double & nlpcomplem,
724+ double & nlpoverall,
725+ double & logoptim,
726+ double & logfeas,
727+ double & logcomplem,
728+ double & logoverall,
729+ double & cons_violation)
730+ {
731+ nlp->runStats .tmSolverInternal .start ();
732+
733+ size_type n = nlp->n_complem (), m = nlp->m ();
734+ // the one norms
735+ // double nrmDualBou=it.normOneOfBoundDuals();
736+ // double nrmDualEqu=it.normOneOfEqualityDuals();
737+ double nrmDualBou, nrmDualEqu;
738+ it.normOneOfDuals (nrmDualEqu, nrmDualBou);
739+
740+ nlp->log ->printf (hovScalars, " nrmOneDualEqu %g nrmOneDualBo %g\n " , nrmDualEqu, nrmDualBou);
741+ if (nrmDualBou > 1e+10 ) {
742+ nlp->log ->printf (hovWarning,
743+ " Unusually large bound dual variables (norm1=%g) occured, "
744+ " which may cause numerical instabilities if it persists. Convergence "
745+ " issues or inacurate optimal solutions may be experienced. Possible causes: "
746+ " tight bounds or bad scaling of the optimization variables.\n " ,
747+ nrmDualBou);
748+ if (nlp->options ->GetString (" fixed_var" ) == " remove" ) {
749+ nlp->log ->printf (hovWarning,
750+ " For example, increase 'fixed_var_tolerance' to remove "
751+ " additional variables.\n " );
752+ } else if (nlp->options ->GetString (" fixed_var" ) == " relax" ) {
753+ nlp->log ->printf (hovWarning,
754+ " For example, increase 'fixed_var_tolerance' to relax "
755+ " aditional (tight) variables and/or increase 'fixed_var_perturb' "
756+ " to decrease the tightness.\n " );
757+ } else {
758+ nlp->log ->printf (hovWarning,
759+ " Potential fixes: fix or relax variables with tight bounds "
760+ " (see 'fixed_var' option) or rescale variables.\n " );
761+ }
762+ }
763+
764+ // scaling factors
765+ // sd = max { p_smax, ||zl||_H + ||zu||_H + (||vl||_1 + ||vu||_1)/m } /p_smax
766+ // sc = max { p_smax, ||zl||_H + ||zu||_H } /p_smax
767+ // nlpoptim = ||gradf + Jc'*yc + Jd'*Jd - M*zl - M*zu||_Hinv
768+ // ||yd+vl-vu||_inf
769+ // nlpfeas = ||crhs- c||_inf
770+ // ||drs- d||_inf
771+ // ||x-sxl-xl||_H
772+ // ||x-sxu+xu||_H
773+ // ||d-sdl-dl||
774+ //
775+ double sd = fmax (p_smax, (nrmDualBou + nrmDualEqu) / (n + m)) / p_smax;
776+ double sc = n == 0 ? 0 : fmax (p_smax, nrmDualBou / n) / 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 (hovScalars,
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+
718806bool hiopAlgFilterIPMBase::evalNlp_funcOnly (hiopIterate& iter, double & f, hiopVector& c, hiopVector& d)
719807{
720808 bool new_x = true ;
0 commit comments