1 module constants;
2 
3 nothrow @nogc extern(C):
4 
5 import glob_opts; // for c_float
6 
7 /*******************
8 * OSQP Versioning *
9 *******************/
10 //# define OSQP_VERSION ("0.6.0") /* string literals automatically null-terminated
11 enum string OSQP_VERSION = "0.6.0";
12 
13 /******************
14 * Solver Status  *
15 ******************/
16 //# define OSQP_DUAL_INFEASIBLE_INACCURATE (4)
17 //# define OSQP_PRIMAL_INFEASIBLE_INACCURATE (3)
18 //# define OSQP_SOLVED_INACCURATE (2)
19 //# define OSQP_SOLVED (1)
20 //# define OSQP_MAX_ITER_REACHED (-2)
21 //# define OSQP_PRIMAL_INFEASIBLE (-3)    /* primal infeasible  */
22 //# define OSQP_DUAL_INFEASIBLE (-4)      /* dual infeasible */
23 //# define OSQP_SIGINT (-5)               /* interrupted by user */
24 //# ifdef PROFILING
25 //#  define OSQP_TIME_LIMIT_REACHED (-6)
26 //# endif // ifdef PROFILING
27 //# define OSQP_NON_CVX (-7)              /* problem non convex */
28 //# define OSQP_UNSOLVED (-10)            /* Unsolved. Only setup function has been called */
29 
30 enum int OSQP_DUAL_INFEASIBLE_INACCURATE = 4;
31 enum int OSQP_PRIMAL_INFEASIBLE_INACCURATE = 3;
32 enum int OSQP_SOLVED_INACCURATE = 2;
33 enum int OSQP_SOLVED = 1;
34 enum int OSQP_MAX_ITER_REACHED = -2;
35 enum int OSQP_PRIMAL_INFEASIBLE = -3;    /* primal infeasible  */
36 enum int OSQP_DUAL_INFEASIBLE = -4;      /* dual infeasible */
37 enum int OSQP_SIGINT = -5;               /* interrupted by user */
38 version (PROFILING)
39 {
40     enum int OSQP_TIME_LIMIT_REACHED = -6;
41 }
42 enum int OSQP_NON_CVX = -7;              /* problem non convex */
43 enum int OSQP_UNSOLVED = -10;            /* Unsolved. Only setup function has been called */
44 
45 
46 
47 /*************************
48 * Linear System Solvers *
49 *************************/
50 enum linsys_solver_type { QDLDL_SOLVER, MKL_PARDISO_SOLVER };
51 
52 // todo : for qdldl_interface compilaton
53 enum int QDLDL_SOLVER = 0;
54 enum int MKL_PARDISO_SOLVER = 1;
55 
56 //extern const char *[] LINSYS_SOLVER_NAME;
57 
58 
59 /******************
60 * Solver Errors  *
61 ******************/
62 enum int OSQP_DATA_VALIDATION_ERROR = 1;
63 enum int OSQP_SETTINGS_VALIDATION_ERROR = 2;
64 enum int OSQP_LINSYS_SOLVER_LOAD_ERROR = 3;
65 enum int OSQP_LINSYS_SOLVER_INIT_ERROR = 4;
66 enum int OSQP_NONCVX_ERROR = 5;
67 enum int OSQP_MEM_ALLOC_ERROR = 6;
68 enum int OSQP_WORKSPACE_NOT_INIT_ERROR = 7;
69 
70 enum osqp_error_type {
71     OSQP_DATA_VALIDATION_ERROR,  /* Start errors from 1 */
72     OSQP_SETTINGS_VALIDATION_ERROR,
73     OSQP_LINSYS_SOLVER_LOAD_ERROR,
74     OSQP_LINSYS_SOLVER_INIT_ERROR,
75     OSQP_NONCVX_ERROR,
76     OSQP_MEM_ALLOC_ERROR,
77     OSQP_WORKSPACE_NOT_INIT_ERROR,
78 };
79 //extern const char * [] OSQP_ERROR_MESSAGE;
80 
81 /**********************************
82 * Solver Parameters and Settings *
83 **********************************/
84 
85 //# define RHO (0.1)
86 //# define SIGMA (1E-06)
87 //# define MAX_ITER (4000)
88 //# define EPS_ABS (1E-3)
89 //# define EPS_REL (1E-3)
90 //# define EPS_PRIM_INF (1E-4)
91 //# define EPS_DUAL_INF (1E-4)
92 //# define ALPHA (1.6)
93 //# define LINSYS_SOLVER (QDLDL_SOLVER)
94 
95 //# define RHO_MIN (1e-06)
96 //# define RHO_MAX (1e06)
97 //# define RHO_EQ_OVER_RHO_INEQ (1e03)
98 //# define RHO_TOL (1e-04) ///< tolerance for detecting if an inequality is set to equality
99 
100 enum float RHO = 0.1;
101 enum float SIGMA = 1E-06;
102 enum int MAX_ITER = 4000;
103 enum float EPS_ABS = 1E-3;
104 enum float EPS_REL = 1E-3;
105 enum float EPS_PRIM_INF = 1E-4;
106 enum float EPS_DUAL_INF = 1E-4;
107 enum float ALPHA = 1.6;
108 alias LINSYS_SOLVER = QDLDL_SOLVER;
109 
110 enum float RHO_MIN = 1e-06;
111 enum float RHO_MAX = 1e06;
112 enum float RHO_EQ_OVER_RHO_INEQ = 1e03;
113 enum float RHO_TOL = 1e-04; ///< tolerance for detecting if an inequality is set to equality
114 
115 
116 version (EMBEDDED){}
117 else {
118 //#  define DELTA (1E-6)
119 //#  define POLISH (0)
120 //#  define POLISH_REFINE_ITER (3)
121 //#  define VERBOSE (1)
122     enum float DELTA = 1E-6;
123     enum int POLISH = 0;
124     enum int POLISH_REFINE_ITER = 3;
125     enum int VERBOSE = 1;
126 } // ifndef EMBEDDED
127 
128 //# define SCALED_TERMINATION (0)
129 //# define CHECK_TERMINATION (25)
130 //# define WARM_START (1)
131 //# define SCALING (10)
132 //# define MIN_SCALING (1e-04) ///< minimum scaling value
133 //# define MAX_SCALING (1e+04) ///< maximum scaling value
134 enum int SCALED_TERMINATION = 0;
135 enum int CHECK_TERMINATION = 25;
136 enum int WARM_START = 1;
137 enum int SCALING = 10;
138 enum c_float MIN_SCALING = 1e-04;   ///< minimum scaling value
139 enum c_float MAX_SCALING = 1e+04;   ///< maximum scaling value
140 
141 
142 //# ifndef OSQP_NULL
143 //#  define OSQP_NULL 0
144 //# endif /* ifndef OSQP_NULL */
145 // todo : test
146 auto OSQP_NULL = null;
147 
148 //# ifndef OSQP_NAN
149 //#  define OSQP_NAN ((c_float)0x7fc00000UL)  // not a number
150 //# endif /* ifndef OSQP_NAN */
151 enum c_float OSQP_NAN = (cast(c_float)0x7fc00000UL);  // not a number
152 
153 //# ifndef OSQP_INFTY
154 //#  define OSQP_INFTY ((c_float)1e30)        // infinity
155 //# endif /* ifndef OSQP_INFTY */
156 enum c_float OSQP_INFTY = (cast(c_float)1e30) ; // infinity
157 
158 version (EMBEDDED_1){}
159 else {
160 //#  define ADAPTIVE_RHO (1)
161 //#  define ADAPTIVE_RHO_INTERVAL (0)
162 //#  define ADAPTIVE_RHO_FRACTION (0.4)           ///< fraction of setup time after which we update rho
163 //#  define ADAPTIVE_RHO_MULTIPLE_TERMINATION (4) ///< multiple of check_termination after which we update rho (if PROFILING disabled)
164 //#  define ADAPTIVE_RHO_FIXED (100)              ///< number of iterations after which we update rho if termination_check  and PROFILING are disabled
165 //#  define ADAPTIVE_RHO_TOLERANCE (5)            ///< tolerance for adopting new rho; minimum ratio between new rho and the current one
166     enum int ADAPTIVE_RHO = 1;
167     enum int ADAPTIVE_RHO_INTERVAL = 0;
168     enum c_float ADAPTIVE_RHO_FRACTION = 0.4;        ///< fraction of setup time after which we update rho
169     enum int ADAPTIVE_RHO_MULTIPLE_TERMINATION = 4;  ///< multiple of check_termination after which we update rho (if PROFILING disabled)
170     enum int ADAPTIVE_RHO_FIXED = 100;               ///< number of iterations after which we update rho if termination_check  and PROFILING are disabled
171     enum int ADAPTIVE_RHO_TOLERANCE = 5;             ///< tolerance for adopting new rho; minimum ratio between new rho and the current one
172 
173 } // if EMBEDDED != 1
174 
175 version (PROFILING) {
176     //#  define TIME_LIMIT (0)                        ///< Disable time limit as default
177     enum int TIME_LIMIT = 0;                          ///< Disable time limit as default
178 } // ifdef PROFILING
179 
180 /* Printing */
181 //# define PRINT_INTERVAL 200
182 enum int PRINT_INTERVAL = 200;