[numerics] fix gap between residual and full error criterion
/* #define DEBUG_NOCOLOR */
/* #define DEBUG_MESSAGES */
#include "debug.h"
-const char* const SICONOS_GLOBAL_FRICTION_3D_ADMM_STR = "CONVEXQP ADMM";
+const char* const SICONOS_GLOBAL_FRICTION_3D_ADMM_STR = "GFC3D ADMM";
typedef struct {
double * reaction_hat;
@@ -180,7 +180,7 @@ void gfc3d_ADMM(GlobalFrictionContactProblem* restrict problem, double* restrict
cblas_dcopy(m , reaction , 1 , reaction_hat, 1);
cblas_dcopy(m , u , 1 , u_hat, 1);
- double e_k = INFINITY, e, d, alpha, r, s;
+ double e_k = INFINITY, e, d, alpha, r, s, residual;
double tau , tau_k = 1.0;
int pos;
double normUT;
@@ -311,28 +311,33 @@ void gfc3d_ADMM(GlobalFrictionContactProblem* restrict problem, double* restrict
cblas_dcopy(m , reaction , 1 , reaction_k, 1);
cblas_dcopy(m , u , 1 , u_k, 1);
- error = sqrt(e);
+ residual = sqrt(e);
if (fabs(norm_q) > DBL_EPSILON)
- error /= norm_q;
+ residual /= norm_q;
- numerics_printf_verbose(1,"---- GFC3D - ADMM - Iteration %i rho = %14.7e \t residual = %14.7e", iter, rho, error);
-
- if (error < tolerance) hasNotConverged = 0;
- *info = hasNotConverged;
- }
+ numerics_printf_verbose(1,"---- GFC3D - ADMM - Iteration %i rho = %14.7e, residual = %14.7e, tol = %14.7e", iter, rho, residual, tolerance);
+ if (residual < tolerance)
+ {
/* check the full criterion */
- /* **** Criterium convergence **** */
-
cblas_dscal(m, rho, reaction, 1);
gfc3d_compute_error(problem, reaction, u, z, tolerance, options, norm_q, &error);
- numerics_printf_verbose(1,"---- GFC3D - ADMM - Iteration %i rho = %14.7e \t error = %14.7e", iter, rho, error);
-
- if (error < tolerance) hasNotConverged = 0;
- else hasNotConverged = 1;
+ if (error < dparam[SICONOS_DPARAM_TOL])
+ {
+ hasNotConverged = 0;
+ numerics_printf_verbose(1,"---- GFC3D - ADMM - Iteration %i rho = %14.7e \t full error = %14.7e", iter, rho, error);
+ }
+ else
+ {
+ numerics_printf_verbose(1,"---- GFC3D - ADMM - The tolerance on the residual is not sufficient to reach accuracy (error = %14.7e)", error);
+ tolerance = tolerance * residual/error;
+ numerics_printf_verbose(1,"---- GFC3D - ADMM - We reduce the tolerance on the residual to %14.7e", tolerance);
+ cblas_dscal(m, 1.0/rho, reaction, 1);
+ }
+ }
*info = hasNotConverged;
+ }
- numerics_printf_verbose(1,"---- GFC3D - ADMM - #Iteration %i Final Residual = %14.7e", iter, error);
dparam[SICONOS_DPARAM_RESIDU] = error;
iparam[SICONOS_IPARAM_ITER_DONE] = iter;
