Options.c
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
36 #include <qpOASES_e/Options.h>
37 
38 
40 
41 
42 /*****************************************************************************
43  * P U B L I C *
44  *****************************************************************************/
45 
46 
47 /*
48  * O p t i o n s
49  */
50 void OptionsCON( Options* _THIS
51  )
52 {
53  #ifdef __CODE_GENERATION__
54  Options_setToFast( _THIS );
55  #else
56  Options_setToDefault( _THIS );
57  #endif /* __CODE_GENERATION__ */
58 }
59 
60 
61 /*
62  * c o p y
63  */
64 void OptionsCPY( Options* FROM,
65  Options* TO
66  )
67 {
68  TO->printLevel = FROM->printLevel;
69 
70  TO->enableRamping = FROM->enableRamping;
71  TO->enableFarBounds = FROM->enableFarBounds;
75  TO->enableNZCTests = FROM->enableNZCTests;
79 
81  TO->boundTolerance = FROM->boundTolerance;
82  TO->boundRelaxation = FROM->boundRelaxation;
83  TO->epsNum = FROM->epsNum;
84  TO->epsDen = FROM->epsDen;
85  TO->maxPrimalJump = FROM->maxPrimalJump;
86  TO->maxDualJump = FROM->maxDualJump;
87 
88  TO->initialRamping = FROM->initialRamping;
89  TO->finalRamping = FROM->finalRamping;
91  TO->growFarBounds = FROM->growFarBounds;
93  TO->epsFlipping = FROM->epsFlipping;
97  TO->epsIterRef = FROM->epsIterRef;
98  TO->epsLITests = FROM->epsLITests;
99  TO->epsNZCTests = FROM->epsNZCTests;
100 
105 }
106 
107 
108 
109 /*
110  * s e t T o D e f a u l t
111  */
113  )
114 {
115  _THIS->printLevel = PL_MEDIUM;
116  #ifdef __DEBUG__
117  _THIS->printLevel = PL_HIGH;
118  #endif
119  #ifdef __SUPPRESSANYOUTPUT__
120  _THIS->printLevel = PL_NONE;
121  #endif
122  #ifdef __CODE_GENERATION__
123  _THIS->printLevel = QPOASES_PRINTLEVEL;
124  #endif
125 
126  _THIS->enableRamping = BT_TRUE;
127  _THIS->enableFarBounds = BT_TRUE;
128  _THIS->enableFlippingBounds = BT_TRUE;
130  _THIS->enableFullLITests = BT_FALSE;
131  _THIS->enableNZCTests = BT_TRUE;
132  _THIS->enableDriftCorrection = 1;
134  _THIS->enableEqualities = BT_FALSE;
135 
136  #ifdef __USE_SINGLE_PRECISION__
137  _THIS->terminationTolerance = 1.0e2 * QPOASES_EPS;
138  _THIS->boundTolerance = 1.0e2 * QPOASES_EPS;
139  #else
140  _THIS->terminationTolerance = 5.0e6 * QPOASES_EPS;
141  _THIS->boundTolerance = 1.0e6 * QPOASES_EPS;
142  #endif
143  _THIS->boundRelaxation = 1.0e4;
144  #ifdef __USE_SINGLE_PRECISION__
145  _THIS->epsNum = -1.0e2 * QPOASES_EPS;
146  _THIS->epsDen = 1.0e2 * QPOASES_EPS;
147  #else
148  _THIS->epsNum = -1.0e3 * QPOASES_EPS;
149  _THIS->epsDen = 1.0e3 * QPOASES_EPS;
150  #endif
151  _THIS->maxPrimalJump = 1.0e8;
152  _THIS->maxDualJump = 1.0e8;
153 
154  _THIS->initialRamping = 0.5;
155  _THIS->finalRamping = 1.0;
156  _THIS->initialFarBounds = 1.0e6;
157  _THIS->growFarBounds = 1.0e3;
158  _THIS->initialStatusBounds = ST_LOWER;
159  #ifdef __USE_SINGLE_PRECISION__
160  _THIS->epsFlipping = 5.0e1 * QPOASES_EPS;
161  #else
162  _THIS->epsFlipping = 1.0e3 * QPOASES_EPS;
163  #endif
164  _THIS->numRegularisationSteps = 0;
165  #ifdef __USE_SINGLE_PRECISION__
166  _THIS->epsRegularisation = 2.0e1 * QPOASES_EPS;
167  _THIS->numRefinementSteps = 2;
168  #else
169  _THIS->epsRegularisation = 1.0e3 * QPOASES_EPS;
170  _THIS->numRefinementSteps = 1;
171  #endif
172  _THIS->epsIterRef = 1.0e2 * QPOASES_EPS;
173  #ifdef __USE_SINGLE_PRECISION__
174  _THIS->epsLITests = 5.0e1 * QPOASES_EPS;
175  _THIS->epsNZCTests = 1.0e2 * QPOASES_EPS;
176  #else
177  _THIS->epsLITests = 1.0e5 * QPOASES_EPS;
178  _THIS->epsNZCTests = 3.0e3 * QPOASES_EPS;
179  #endif
180 
182  _THIS->dropBoundPriority = 1;
183  _THIS->dropEqConPriority = 1;
184  _THIS->dropIneqConPriority = 1;
185 
186  return SUCCESSFUL_RETURN;
187 }
188 
189 
190 /*
191  * s e t T o R e l i a b l e
192  */
194  )
195 {
196  Options_setToDefault( _THIS );
197 
198  _THIS->enableFullLITests = BT_TRUE;
200 
201  #ifdef __USE_SINGLE_PRECISION__
202  _THIS->numRefinementSteps = 3;
203  #else
204  _THIS->numRefinementSteps = 2;
205  #endif /*__USE_SINGLE_PRECISION__ */
206 
207  return SUCCESSFUL_RETURN;
208 }
209 
210 
211 /*
212  * s e t T o M P C
213  */
215  )
216 {
217  Options_setToDefault( _THIS );
218 
219  _THIS->enableRamping = BT_FALSE;
220  _THIS->enableFarBounds = BT_TRUE;
222  _THIS->enableRegularisation = BT_TRUE;
223  _THIS->enableNZCTests = BT_FALSE;
224  _THIS->enableDriftCorrection = 0;
225  #ifdef __USE_SINGLE_PRECISION__
226  _THIS->enableEqualities = BT_FALSE;
227  #else
228  _THIS->enableEqualities = BT_TRUE;
229  #endif
230 
231  #ifdef __USE_SINGLE_PRECISION__
232  _THIS->terminationTolerance = 1.0e3 * QPOASES_EPS;
233  #else
234  _THIS->terminationTolerance = 1.0e9 * QPOASES_EPS;
235  #endif
236 
238  _THIS->numRegularisationSteps = 1;
239  #ifdef __USE_SINGLE_PRECISION__
240  _THIS->numRefinementSteps = 1;
241  #else
242  _THIS->numRefinementSteps = 0;
243  #endif
244 
245  return SUCCESSFUL_RETURN;
246 }
247 
248 
249 /*
250  * s e t T o F a s t
251  */
253  )
254 {
255  return Options_setToMPC( _THIS );
256 }
257 
258 
259 
260 /*
261  * e n s u r e C o n s i s t e n c y
262  */
264  )
265 {
266  BooleanType needToAdjust = BT_FALSE;
267 
268  /* flipping bounds require far bounds */
269  /* (ckirches) Removed this as per filter's trust region
270  if( enableFlippingBounds == BT_TRUE )
271  enableFarBounds = BT_TRUE;
272  */
273 
274  if( _THIS->enableDriftCorrection < 0 )
275  {
276  _THIS->enableDriftCorrection = 0;
277  needToAdjust = BT_TRUE;
278  }
279 
280  if( _THIS->enableCholeskyRefactorisation < 0 )
281  {
283  needToAdjust = BT_TRUE;
284  }
285 
286 
287  if ( _THIS->terminationTolerance <= 0.0 )
288  {
290  needToAdjust = BT_TRUE;
291  }
292 
293  if ( _THIS->epsIterRef <= 0.0 )
294  {
295  _THIS->epsIterRef = QPOASES_EPS;
296  needToAdjust = BT_TRUE;
297  }
298 
299  if ( _THIS->epsRegularisation <= 0.0 )
300  {
302  needToAdjust = BT_TRUE;
303  }
304 
305  if ( _THIS->boundTolerance <= 0.0 )
306  {
307  _THIS->boundTolerance = QPOASES_EPS;
308  needToAdjust = BT_TRUE;
309  }
310 
311  if ( _THIS->boundRelaxation <= 0.0 )
312  {
313  _THIS->boundRelaxation = QPOASES_EPS;
314  needToAdjust = BT_TRUE;
315  }
316 
317  if ( _THIS->maxPrimalJump <= 0.0 )
318  {
319  _THIS->maxPrimalJump = QPOASES_EPS;
320  needToAdjust = BT_TRUE;
321  }
322 
323  if ( _THIS->maxDualJump <= 0.0 )
324  {
325  _THIS->maxDualJump = QPOASES_EPS;
326  needToAdjust = BT_TRUE;
327  }
328 
329 
330  if ( _THIS->initialRamping < 0.0 )
331  {
332  _THIS->initialRamping = 0.0;
333  needToAdjust = BT_TRUE;
334  }
335 
336  if ( _THIS->finalRamping < 0.0 )
337  {
338  _THIS->finalRamping = 0.0;
339  needToAdjust = BT_TRUE;
340  }
341 
342  if ( _THIS->initialFarBounds <= _THIS->boundRelaxation )
343  {
345  needToAdjust = BT_TRUE;
346  }
347 
348  if ( _THIS->growFarBounds < 1.1 )
349  {
350  _THIS->growFarBounds = 1.1;
351  needToAdjust = BT_TRUE;
352  }
353 
354  if ( _THIS->epsFlipping <= 0.0 )
355  {
356  _THIS->epsFlipping = QPOASES_EPS;
357  needToAdjust = BT_TRUE;
358  }
359 
360  if ( _THIS->numRegularisationSteps < 0 )
361  {
362  _THIS->numRegularisationSteps = 0;
363  needToAdjust = BT_TRUE;
364  }
365 
366  if ( _THIS->epsRegularisation < 0.0 )
367  {
369  needToAdjust = BT_TRUE;
370  }
371 
372  if ( _THIS->numRefinementSteps < 0 )
373  {
374  _THIS->numRefinementSteps = 0;
375  needToAdjust = BT_TRUE;
376  }
377 
378  if ( _THIS->epsIterRef < 0.0 )
379  {
380  _THIS->epsIterRef = QPOASES_EPS;
381  needToAdjust = BT_TRUE;
382  }
383 
384  if ( _THIS->epsLITests < 0.0 )
385  {
386  _THIS->epsLITests = QPOASES_EPS;
387  needToAdjust = BT_TRUE;
388  }
389 
390  if ( _THIS->epsNZCTests < 0.0 )
391  {
392  _THIS->epsNZCTests = QPOASES_EPS;
393  needToAdjust = BT_TRUE;
394  }
395 
396  if ( needToAdjust == BT_TRUE )
398 
399  return SUCCESSFUL_RETURN;
400 }
401 
402 
403 /*
404  * p r i n t
405  */
407  )
408 {
409  #ifndef __SUPPRESSANYOUTPUT__
410 
411  myStatic char myPrintfString[QPOASES_MAX_STRING_LENGTH];
413 
414  qpOASES_myPrintf( "\n################### qpOASES -- QP OPTIONS ##################\n" );
415  qpOASES_myPrintf( "\n" );
416 
418  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"printLevel = %s\n",info );
419  qpOASES_myPrintf( myPrintfString );
420 
421  qpOASES_myPrintf( "\n" );
422 
424  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableRamping = %s\n",info );
425  qpOASES_myPrintf( myPrintfString );
426 
428  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableFarBounds = %s\n",info );
429  qpOASES_myPrintf( myPrintfString );
430 
432  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableFlippingBounds = %s\n",info );
433  qpOASES_myPrintf( myPrintfString );
434 
436  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableRegularisation = %s\n",info );
437  qpOASES_myPrintf( myPrintfString );
438 
440  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableFullLITests = %s\n",info );
441  qpOASES_myPrintf( myPrintfString );
442 
444  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableNZCTests = %s\n",info );
445  qpOASES_myPrintf( myPrintfString );
446 
447  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableDriftCorrection = %d\n",_THIS->enableDriftCorrection );
448  qpOASES_myPrintf( myPrintfString );
449 
450  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableCholeskyRefactorisation = %d\n",_THIS->enableCholeskyRefactorisation );
451  qpOASES_myPrintf( myPrintfString );
452 
454  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"enableEqualities = %s\n",info );
455  qpOASES_myPrintf( myPrintfString );
456 
457  qpOASES_myPrintf( "\n" );
458 
459  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"terminationTolerance = %e\n",_THIS->terminationTolerance );
460  qpOASES_myPrintf( myPrintfString );
461 
462  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"boundTolerance = %e\n",_THIS->boundTolerance );
463  qpOASES_myPrintf( myPrintfString );
464 
465  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"boundRelaxation = %e\n",_THIS->boundRelaxation );
466  qpOASES_myPrintf( myPrintfString );
467 
468  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"epsNum = %e\n",_THIS->epsNum );
469  qpOASES_myPrintf( myPrintfString );
470 
471  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"epsDen = %e\n",_THIS->epsDen );
472  qpOASES_myPrintf( myPrintfString );
473 
474  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"maxPrimalJump = %e\n",_THIS->maxPrimalJump );
475  qpOASES_myPrintf( myPrintfString );
476 
477  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"maxDualJump = %e\n",_THIS->maxDualJump );
478  qpOASES_myPrintf( myPrintfString );
479 
480  qpOASES_myPrintf( "\n" );
481 
482  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"initialRamping = %e\n",_THIS->initialRamping );
483  qpOASES_myPrintf( myPrintfString );
484 
485  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"finalRamping = %e\n",_THIS->finalRamping );
486  qpOASES_myPrintf( myPrintfString );
487 
488  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"initialFarBounds = %e\n",_THIS->initialFarBounds );
489  qpOASES_myPrintf( myPrintfString );
490 
491  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"growFarBounds = %e\n",_THIS->growFarBounds );
492  qpOASES_myPrintf( myPrintfString );
493 
495  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"initialStatusBounds = %s\n",info );
496  qpOASES_myPrintf( myPrintfString );
497 
498  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"epsFlipping = %e\n",_THIS->epsFlipping );
499  qpOASES_myPrintf( myPrintfString );
500 
501  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"numRegularisationSteps = %d\n",_THIS->numRegularisationSteps );
502  qpOASES_myPrintf( myPrintfString );
503 
504  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"epsRegularisation = %e\n",_THIS->epsRegularisation );
505  qpOASES_myPrintf( myPrintfString );
506 
507  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"numRefinementSteps = %d\n",_THIS->numRefinementSteps );
508  qpOASES_myPrintf( myPrintfString );
509 
510  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"epsIterRef = %e\n",_THIS->epsIterRef );
511  qpOASES_myPrintf( myPrintfString );
512 
513  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"epsLITests = %e\n",_THIS->epsLITests );
514  qpOASES_myPrintf( myPrintfString );
515 
516  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"epsNZCTests = %e\n",_THIS->epsNZCTests );
517  qpOASES_myPrintf( myPrintfString );
518 
519  qpOASES_myPrintf( "\n\n" );
520 
521  #endif /* __SUPPRESSANYOUTPUT__ */
522 
523  return SUCCESSFUL_RETURN;
524 }
525 
526 
527 
528 /*****************************************************************************
529  * P R O T E C T E D *
530  *****************************************************************************/
531 
532 
533 
535 
536 
537 /*
538  * end of file
539  */
returnValue Options_ensureConsistency(Options *_THIS)
Definition: Options.c:263
#define ST_LOWER
returnValue Options_setToFast(Options *_THIS)
Definition: Options.c:252
Allows to pass back messages to the calling function.
returnValue Options_setToMPC(Options *_THIS)
Definition: Options.c:214
#define PL_MEDIUM
#define PL_NONE
#define ST_INACTIVE
#define PL_HIGH
Provides a generic way to set and pass user-specified options.
Definition: options.hpp:65
returnValue qpOASES_myPrintf(const char *s)
Definition: Utils.c:269
void OptionsCPY(Options *FROM, Options *TO)
Definition: Options.c:64
returnValue Options_print(Options *_THIS)
Definition: Options.c:406
returnValue Options_setToReliable(Options *_THIS)
Definition: Options.c:193
#define BT_TRUE
Definition: acado_types.hpp:47
static const real_t QPOASES_EPS
#define QPOASES_MAX_STRING_LENGTH
#define BT_FALSE
Definition: acado_types.hpp:49
returnValue qpOASES_convertPrintLevelToString(PrintLevel value, char *const string)
Definition: Utils.c:840
returnValue qpOASES_convertSubjectToStatusToString(SubjectToStatus value, char *const string)
Definition: Utils.c:798
returnValue qpOASES_convertBooleanTypeToString(BooleanType value, char *const string)
Definition: Utils.c:782
returnValue Options_setToDefault(Options *_THIS)
Definition: Options.c:112
BEGIN_NAMESPACE_QPOASES void OptionsCON(Options *_THIS)
Definition: Options.c:50
#define myStatic
Definition: Types.h:103


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:54