constants.h 3.5 KB

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