Constraints.h
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 #ifndef QPOASES_CONSTRAINTS_H
37 #define QPOASES_CONSTRAINTS_H
38 
39 
40 #include <qpOASES_e/Indexlist.h>
41 
42 
44 
45 
56 typedef struct
57 {
58  int n;
66  Indexlist active;
67  Indexlist inactive;
68 } Constraints;
69 
70 
71 
73 void ConstraintsCON( Constraints* _THIS,
74  int _n
75  );
76 
79 void ConstraintsCPY( Constraints* FROM,
80  Constraints* TO
81  );
82 
83 
88  int _n
89  );
90 
91 
99  int number,
100  SubjectToStatus _status
101  );
102 
109  );
110 
117  );
118 
125  );
126 
127 
132  int number
133  );
134 
139  int number,
140  SubjectToStatus _status
141  );
142 
148  int number
149  );
150 
151 
154 static inline int Constraints_getNC( Constraints* _THIS
155  );
156 
159 static inline int Constraints_getNEC( Constraints* _THIS
160  );
161 
164 static inline int Constraints_getNIC( Constraints* _THIS
165  );
166 
169 static inline int Constraints_getNUC( Constraints* _THIS
170  );
171 
174 static inline int Constraints_getNAC( Constraints* _THIS
175  );
176 
179 static inline int Constraints_getNIAC( Constraints* _THIS
180  );
181 
182 
185 static inline Indexlist* Constraints_getActive( Constraints* _THIS
186  );
187 
190 static inline Indexlist* Constraints_getInactive( Constraints* _THIS
191  );
192 
193 
196 static inline int Constraints_getNumberOfType( Constraints* _THIS,
197  SubjectToType _type
198  );
199 
200 
204 static inline SubjectToType Constraints_getType( Constraints* _THIS,
205  int i
206  );
207 
212  int i
213  );
214 
215 
219 static inline returnValue Constraints_setType( Constraints* _THIS,
220  int i,
221  SubjectToType value
222  );
223 
227 static inline returnValue Constraints_setStatus( Constraints* _THIS,
228  int i,
229  SubjectToStatus value
230  );
231 
232 
234 static inline void Constraints_setNoLower( Constraints* _THIS,
235  BooleanType _status
236  );
237 
239 static inline void Constraints_setNoUpper( Constraints* _THIS,
240  BooleanType _status
241  );
242 
243 
246 static inline BooleanType Constraints_hasNoLower( Constraints* _THIS
247  );
248 
251 static inline BooleanType Constraints_hasNoUpper( Constraints* _THIS
252  );
253 
254 
267  int offset
268  );
269 
278  int offset
279  );
280 
281 
287  );
288 
289 
296  SubjectToStatus _status
297  );
298 
299 
305  Indexlist* const indexlist,
306  int newnumber,
307  SubjectToStatus newstatus
308  );
309 
315  Indexlist* const indexlist,
316  int removenumber
317  );
318 
324  Indexlist* const indexlist,
325  int number1,
326  int number2
327  );
328 
329 
330 
331 /*
332  * g e t N u m b e r O f T y p e
333  */
334 static inline int Constraints_getNumberOfType( Constraints* _THIS, SubjectToType _type )
335 {
336  int i;
337  int numberOfType = 0;
338 
339  if ( _THIS->type != 0 )
340  {
341  for( i=0; i<_THIS->n; ++i )
342  if ( _THIS->type[i] == _type )
343  ++numberOfType;
344  }
345 
346  return numberOfType;
347 }
348 
349 
350 /*
351  * g e t T y p e
352  */
353 static inline SubjectToType Constraints_getType( Constraints* _THIS, int i )
354 {
355  if ( ( i >= 0 ) && ( i < _THIS->n ) )
356  return _THIS->type[i];
357 
358  return ST_UNKNOWN;
359 }
360 
361 
362 /*
363  * g e t S t a t u s
364  */
365 static inline SubjectToStatus Constraints_getStatus( Constraints* _THIS, int i )
366 {
367  if ( ( i >= 0 ) && ( i < _THIS->n ) )
368  return _THIS->status[i];
369 
370  return ST_UNDEFINED;
371 }
372 
373 
374 /*
375  * s e t T y p e
376  */
377 static inline returnValue Constraints_setType( Constraints* _THIS, int i, SubjectToType value )
378 {
379  if ( ( i >= 0 ) && ( i < _THIS->n ) )
380  {
381  _THIS->type[i] = value;
382  return SUCCESSFUL_RETURN;
383  }
384  else
386 }
387 
388 
389 /*
390  * s e t S t a t u s
391  */
392 static inline returnValue Constraints_setStatus( Constraints* _THIS, int i, SubjectToStatus value )
393 {
394  if ( ( i >= 0 ) && ( i < _THIS->n ) )
395  {
396  _THIS->status[i] = value;
397  return SUCCESSFUL_RETURN;
398  }
399  else
401 }
402 
403 
404 /*
405  * s e t N o L o w e r
406  */
407 static inline void Constraints_setNoLower( Constraints* _THIS, BooleanType _status )
408 {
409  _THIS->noLower = _status;
410 }
411 
412 
413 /*
414  * s e t N o U p p e r
415  */
416 static inline void Constraints_setNoUpper( Constraints* _THIS, BooleanType _status )
417 {
418  _THIS->noUpper = _status;
419 }
420 
421 
422 /*
423  * h a s N o L o w e r
424  */
426 {
427  return _THIS->noLower;
428 }
429 
430 
431 /*
432  * h a s N o U p p p e r
433  */
435 {
436  return _THIS->noUpper;
437 }
438 
439 
440 
441 /*
442  * g e t N C
443  */
444 static inline int Constraints_getNC( Constraints* _THIS )
445 {
446  return _THIS->n;
447 }
448 
449 
450 /*
451  * g e t N E C
452  */
453 static inline int Constraints_getNEC( Constraints* _THIS )
454 {
456 }
457 
458 
459 /*
460  * g e t N I C
461  */
462 static inline int Constraints_getNIC( Constraints* _THIS )
463 {
464  return Constraints_getNumberOfType( _THIS,ST_BOUNDED );
465 }
466 
467 
468 /*
469  * g e t N U C
470  */
471 static inline int Constraints_getNUC( Constraints* _THIS )
472 {
474 }
475 
476 
477 /*
478  * g e t N A C
479  */
480 static inline int Constraints_getNAC( Constraints* _THIS )
481 {
482  return Indexlist_getLength( &(_THIS->active) );
483 }
484 
485 
486 /*
487  * g e t N I A C
488  */
489 static inline int Constraints_getNIAC( Constraints* _THIS )
490 {
491  return Indexlist_getLength( &(_THIS->inactive) );
492 }
493 
494 
495 
496 /*
497  * g e t A c t i v e
498  */
500 {
501  return &(_THIS->active);
502 }
503 
504 
505 /*
506  * g e t I n a c t i v e
507  */
509 {
510  return &(_THIS->inactive);
511 }
512 
513 
515 
516 
517 #endif /* QPOASES_CONSTRAINTS_H */
518 
519 
520 /*
521  * end of file
522  */
returnValue Constraints_rotate(Constraints *_THIS, int offset)
Definition: Constraints.c:322
SubjectToType type[NCMAX]
Definition: Constraints.h:60
static int Constraints_getNC(Constraints *_THIS)
Definition: Constraints.h:444
static int Constraints_getNUC(Constraints *_THIS)
Definition: Constraints.h:471
static SubjectToStatus Constraints_getStatus(Constraints *_THIS, int i)
Definition: Constraints.h:365
static Indexlist * Constraints_getInactive(Constraints *_THIS)
Definition: Constraints.h:508
returnValue Constraints_print(Constraints *_THIS)
Definition: Constraints.c:397
static void Constraints_setNoUpper(Constraints *_THIS, BooleanType _status)
Definition: Constraints.h:416
Allows to pass back messages to the calling function.
static void Constraints_setNoLower(Constraints *_THIS, BooleanType _status)
Definition: Constraints.h:407
returnValue Constraints_setupConstraint(Constraints *_THIS, int number, SubjectToStatus _status)
Definition: Constraints.c:127
returnValue Constraints_addIndex(Constraints *_THIS, Indexlist *const indexlist, int newnumber, SubjectToStatus newstatus)
Definition: Constraints.c:486
#define ST_UNDEFINED
returnValue Constraints_moveInactiveToActive(Constraints *_THIS, int number, SubjectToStatus _status)
Definition: Constraints.c:216
static int Constraints_getNEC(Constraints *_THIS)
Definition: Constraints.h:453
BooleanType noLower
Definition: Constraints.h:63
void ConstraintsCPY(Constraints *FROM, Constraints *TO)
Definition: Constraints.c:61
static Indexlist * Constraints_getActive(Constraints *_THIS)
Definition: Constraints.h:499
static SubjectToType Constraints_getType(Constraints *_THIS, int i)
Definition: Constraints.h:353
returnValue Constraints_swapIndex(Constraints *_THIS, Indexlist *const indexlist, int number1, int number2)
Definition: Constraints.c:542
static int Indexlist_getLength(Indexlist *_THIS)
Definition: Indexlist.h:183
BooleanType noUpper
Definition: Constraints.h:64
returnValue Constraints_setupAllLower(Constraints *_THIS)
Definition: Constraints.c:174
SubjectToStatus status[NCMAX]
Definition: Constraints.h:61
returnValue Constraints_moveActiveToInactive(Constraints *_THIS, int number)
Definition: Constraints.c:194
returnValue Constraints_init(Constraints *_THIS, int _n)
Definition: Constraints.c:89
returnValue Constraints_removeIndex(Constraints *_THIS, Indexlist *const indexlist, int removenumber)
Definition: Constraints.c:517
static int Constraints_getNumberOfType(Constraints *_THIS, SubjectToType _type)
Definition: Constraints.h:334
static returnValue Constraints_setStatus(Constraints *_THIS, int i, SubjectToStatus value)
Definition: Constraints.h:392
returnValue Constraints_setupAllUpper(Constraints *_THIS)
Definition: Constraints.c:184
returnValue Constraints_flipFixed(Constraints *_THIS, int number)
Definition: Constraints.c:238
static BooleanType Constraints_hasNoLower(Constraints *_THIS)
Definition: Constraints.h:425
static int Constraints_getNIC(Constraints *_THIS)
Definition: Constraints.h:462
static returnValue Constraints_setType(Constraints *_THIS, int i, SubjectToType value)
Definition: Constraints.h:377
returnValue Constraints_shift(Constraints *_THIS, int offset)
Definition: Constraints.c:259
static int Constraints_getNIAC(Constraints *_THIS)
Definition: Constraints.h:489
static BooleanType Constraints_hasNoUpper(Constraints *_THIS)
Definition: Constraints.h:434
returnValue Constraints_setupAll(Constraints *_THIS, SubjectToStatus _status)
Definition: Constraints.c:434
void ConstraintsCON(Constraints *_THIS, int _n)
Definition: Constraints.c:50
static int Constraints_getNAC(Constraints *_THIS)
Definition: Constraints.h:480
returnValue Constraints_setupAllInactive(Constraints *_THIS)
Definition: Constraints.c:164


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