blob: 93b2ac14a7981d92dacacec19522eb0888a450e6 [file] [log] [blame]
Austin Schuh9049e202022-02-20 17:34:16 -08001#ifndef CONSTANTS_H
2# define CONSTANTS_H
3
4# ifdef __cplusplus
5extern "C" {
6# endif // ifdef __cplusplus
7
8
9/*******************
10* OSQP Versioning *
11*******************/
12#include "version.h"
13
14/******************
15* Solver Status *
16******************/
17# define OSQP_DUAL_INFEASIBLE_INACCURATE (4)
18# define OSQP_PRIMAL_INFEASIBLE_INACCURATE (3)
19# define OSQP_SOLVED_INACCURATE (2)
20# define OSQP_SOLVED (1)
21# define OSQP_MAX_ITER_REACHED (-2)
22# define OSQP_PRIMAL_INFEASIBLE (-3) /* primal infeasible */
23# define OSQP_DUAL_INFEASIBLE (-4) /* dual infeasible */
24# define OSQP_SIGINT (-5) /* interrupted by user */
25# ifdef PROFILING
26# define OSQP_TIME_LIMIT_REACHED (-6)
27# endif // ifdef PROFILING
28# define OSQP_NON_CVX (-7) /* problem non convex */
29# define OSQP_UNSOLVED (-10) /* Unsolved. Only setup function has been called */
30
31
32/*************************
33* Linear System Solvers *
34*************************/
35enum linsys_solver_type { QDLDL_SOLVER, MKL_PARDISO_SOLVER, UNKNOWN_SOLVER=99 };
36extern const char * LINSYS_SOLVER_NAME[];
37
38
39/******************
40* Solver Errors *
41******************/
42enum osqp_error_type {
43 OSQP_DATA_VALIDATION_ERROR = 1, /* Start errors from 1 */
44 OSQP_SETTINGS_VALIDATION_ERROR,
45 OSQP_LINSYS_SOLVER_LOAD_ERROR,
46 OSQP_LINSYS_SOLVER_INIT_ERROR,
47 OSQP_NONCVX_ERROR,
48 OSQP_MEM_ALLOC_ERROR,
49 OSQP_WORKSPACE_NOT_INIT_ERROR,
50};
51extern const char * OSQP_ERROR_MESSAGE[];
52
53
54/**********************************
55* Solver Parameters and Settings *
56**********************************/
57
58# define RHO (0.1)
59# define SIGMA (1E-06)
60# define MAX_ITER (4000)
61# define EPS_ABS (1E-3)
62# define EPS_REL (1E-3)
63# define EPS_PRIM_INF (1E-4)
64# define EPS_DUAL_INF (1E-4)
65# define ALPHA (1.6)
66# define LINSYS_SOLVER (QDLDL_SOLVER)
67
68# define RHO_MIN (1e-06)
69# define RHO_MAX (1e06)
70# define RHO_EQ_OVER_RHO_INEQ (1e03)
71# define RHO_TOL (1e-04) ///< tolerance for detecting if an inequality is set to equality
72
73
74# ifndef EMBEDDED
75# define DELTA (1E-6)
76# define POLISH (0)
77# define POLISH_REFINE_ITER (3)
78# define VERBOSE (1)
79# endif // ifndef EMBEDDED
80
81# define SCALED_TERMINATION (0)
82# define CHECK_TERMINATION (25)
83# define WARM_START (1)
84# define SCALING (10)
85
86# define MIN_SCALING (1e-04) ///< minimum scaling value
87# define MAX_SCALING (1e+04) ///< maximum scaling value
88
89
90# ifndef OSQP_NULL
91# define OSQP_NULL 0
92# endif /* ifndef OSQP_NULL */
93
94# ifndef OSQP_NAN
95# define OSQP_NAN ((c_float)0x7fc00000UL) // not a number
96# endif /* ifndef OSQP_NAN */
97
98# ifndef OSQP_INFTY
99# define OSQP_INFTY ((c_float)1e30) // infinity
100# endif /* ifndef OSQP_INFTY */
101
102# ifndef OSQP_DIVISION_TOL
103# define OSQP_DIVISION_TOL ((c_float)1.0 / OSQP_INFTY)
104# endif /* ifndef OSQP_DIVISION_TOL */
105
106
107# if EMBEDDED != 1
108# define ADAPTIVE_RHO (1)
109# define ADAPTIVE_RHO_INTERVAL (0)
110# define ADAPTIVE_RHO_FRACTION (0.4) ///< fraction of setup time after which we update rho
111# define ADAPTIVE_RHO_MULTIPLE_TERMINATION (4) ///< multiple of check_termination after which we update rho (if PROFILING disabled)
112# define ADAPTIVE_RHO_FIXED (100) ///< number of iterations after which we update rho if termination_check and PROFILING are disabled
113# define ADAPTIVE_RHO_TOLERANCE (5) ///< tolerance for adopting new rho; minimum ratio between new rho and the current one
114# endif // if EMBEDDED != 1
115
116# ifdef PROFILING
117# define TIME_LIMIT (0) ///< Disable time limit as default
118# endif // ifdef PROFILING
119
120/* Printing */
Austin Schuh39f26f62022-02-24 21:34:46 -0800121# define PRINT_INTERVAL 5
Austin Schuh9049e202022-02-20 17:34:16 -0800122
123
124# ifdef __cplusplus
125}
126# endif // ifdef __cplusplus
127
128#endif // ifndef CONSTANTS_H