Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++){
Expand Down Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
Loading