diff --git a/include/constants.h b/include/constants.h index 8b02018..4543f03 100644 --- a/include/constants.h +++ b/include/constants.h @@ -11,6 +11,17 @@ extern "C" { #define DAQP_UNCONSTRAINED_OPTIMAL -2 #define DAQP_INF ((c_float)1e30) +// PRECISION-DEPENDENT TOLERANCES +#ifdef DAQP_SINGLE_PRECISION +#define DAQP_LU_SING_TOL ((c_float)1e-6) // pivot magnitude below this is singular (daqp_lu) +#define DAQP_INIT_PRIM_TOL ((c_float)1e-5) // slack "on bound" band for primal warm start +#define DAQP_INIT_DUAL_TOL ((c_float)1e-6) // multiplier sign threshold for dual warm start +#else +#define DAQP_LU_SING_TOL ((c_float)1e-12) +#define DAQP_INIT_PRIM_TOL ((c_float)1e-9) +#define DAQP_INIT_DUAL_TOL ((c_float)1e-12) +#endif + // DEFAULT SETTINGS #define DAQP_DEFAULT_PRIM_TOL 1e-6 #define DAQP_DEFAULT_DUAL_TOL 1e-12 diff --git a/src/api.c b/src/api.c index 8ef4754..73efa99 100644 --- a/src/api.c +++ b/src/api.c @@ -539,7 +539,7 @@ int daqp_first_violating(c_float* x, c_float* A, c_float* bu, c_float* bl, int n void daqp_primal_init_active(DAQPProblem* qp, c_float* x){ int i,disp; c_float Ax, slack; - c_float tol= 1e-9; + c_float tol= DAQP_INIT_PRIM_TOL; // Simple constraints for(i=0; i < qp->ms; i++){ @@ -579,7 +579,7 @@ void daqp_primal_init_active(DAQPProblem* qp, c_float* x){ // based on a dual iterate void daqp_dual_init_active(DAQPProblem* qp, c_float* lam){ int i; - c_float tol = 1e-12; + c_float tol = DAQP_INIT_DUAL_TOL; for(i=0; i < qp->m; i++){ if(qp->sense[i] & DAQP_IMMUTABLE) continue; if(lam[i] > tol){ diff --git a/src/utils.c b/src/utils.c index c551dba..7af1dd3 100644 --- a/src/utils.c +++ b/src/utils.c @@ -534,7 +534,7 @@ int daqp_lu(c_float* A, int* P, int n) { } // Check for singularity - if (max_val < 1e-12) return -1; + if (max_val < DAQP_LU_SING_TOL) return -1; // Swap rows in A for (int k = 0; k < n; k++) {