Commit 32da2b73 authored by Martin Marinov's avatar Martin Marinov

Merge remote-tracking branch 'VCI/master' into ReForm-master

parents d9f3de21 49e4334c
......@@ -158,6 +158,7 @@ int NewtonSolver::solve(NProblemInterface* _problem, const SMatrixD& _A,
while( iter < max_iters_)
{
double kkt_res2(0.0);
double constraint_res2(0.0);
int reg_iters(0);
do
{
......@@ -177,9 +178,10 @@ int NewtonSolver::solve(NProblemInterface* _problem, const SMatrixD& _A,
// check numerical stability of KKT system and regularize if necessary
kkt_res2 = (KKT_*dx-rhs).squaredNorm();
constraint_res2 = (_A*dx.head(n)-rhs.tail(m)).squaredNorm();
}
if(!fact_ok || kkt_res2 > KKT_res_eps)
if(!fact_ok || kkt_res2 > KKT_res_eps || constraint_res2 > max_allowed_constraint_violation2)
{
DEB_warning(2, "Warning: numerical issues in KKT system");
// alternatingly regularize hessian and constraints
......@@ -202,10 +204,10 @@ int NewtonSolver::solve(NProblemInterface* _problem, const SMatrixD& _A,
}
++reg_iters;
}
while(kkt_res2 > KKT_res_eps && reg_iters < max_KKT_regularization_iters);
while( (kkt_res2 > KKT_res_eps || constraint_res2 > max_allowed_constraint_violation2) && reg_iters < max_KKT_regularization_iters);
// no valid step could be found?
if(kkt_res2 > KKT_res_eps || reg_iters >= max_KKT_regularization_iters)
if(kkt_res2 > KKT_res_eps || constraint_res2 > max_allowed_constraint_violation2 || reg_iters >= max_KKT_regularization_iters)
{
DEB_error("numerical issues in KKT system could not be resolved "
"-> terminating NewtonSolver with current solution");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment