examples/code_generation/mpc_mhe/getting_started_export/qpoases/SRC/SubjectTo.cpp
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-2008 by Hans Joachim Ferreau et al. All rights reserved.
6  *
7  * qpOASES is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * qpOASES is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with qpOASES; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  */
22 
23 
35 #include <SubjectTo.hpp>
36 
37 
38 /*****************************************************************************
39  * P U B L I C *
40  *****************************************************************************/
41 
42 
43 /*
44  * S u b j e c t T o
45  */
46 SubjectTo::SubjectTo( ) : noLower( BT_TRUE ),
47  noUpper( BT_TRUE ),
48  size( 0 )
49 {
50  int i;
51 
52  for( i=0; i<size; ++i )
53  {
54  type[i] = ST_UNKNOWN;
55  status[i] = ST_UNDEFINED;
56  }
57 }
58 
59 
60 /*
61  * S u b j e c t T o
62  */
64  noUpper( rhs.noUpper ),
65  size( rhs.size )
66 {
67  int i;
68 
69  for( i=0; i<size; ++i )
70  {
71  type[i] = rhs.type[i];
72  status[i] = rhs.status[i];
73  }
74 }
75 
76 
77 /*
78  * ~ S u b j e c t T o
79  */
81 {
82 }
83 
84 
85 /*
86  * o p e r a t o r =
87  */
89 {
90  int i;
91 
92  if ( this != &rhs )
93  {
94  size = rhs.size;
95 
96  for( i=0; i<size; ++i )
97  {
98  type[i] = rhs.type[i];
99  status[i] = rhs.status[i];
100  }
101 
102  noLower = rhs.noLower;
103  noUpper = rhs.noUpper;
104  }
105 
106  return *this;
107 }
108 
109 
110 
111 /*
112  * i n i t
113  */
115 {
116  int i;
117 
118  size = n;
119 
120  noLower = BT_TRUE;
121  noUpper = BT_TRUE;
122 
123  for( i=0; i<size; ++i )
124  {
125  type[i] = ST_UNKNOWN;
126  status[i] = ST_UNDEFINED;
127  }
128 
129  return SUCCESSFUL_RETURN;
130 }
131 
132 
133 
134 /*****************************************************************************
135  * P R O T E C T E D *
136  *****************************************************************************/
137 
138 /*
139  * a d d I n d e x
140  */
142  int newnumber, SubjectToStatus newstatus
143  )
144 {
145  /* consistency check */
146  if ( status[newnumber] == newstatus )
148 
149  status[newnumber] = newstatus;
150 
151  if ( indexlist->addNumber( newnumber ) == RET_INDEXLIST_EXCEEDS_MAX_LENGTH )
153 
154  return SUCCESSFUL_RETURN;
155 }
156 
157 
158 /*
159  * r e m o v e I n d e x
160  */
162  int removenumber
163  )
164 {
165  status[removenumber] = ST_UNDEFINED;
166 
167  if ( indexlist->removeNumber( removenumber ) != SUCCESSFUL_RETURN )
168  return THROWERROR( RET_UNKNOWN_BUG );
169 
170  return SUCCESSFUL_RETURN;
171 }
172 
173 
174 /*
175  * s w a p I n d e x
176  */
178  int number1, int number2
179  )
180 {
181  /* consistency checks */
182  if ( status[number1] != status[number2] )
184 
185  if ( number1 == number2 )
186  {
188  return SUCCESSFUL_RETURN;
189  }
190 
191  if ( indexlist->swapNumbers( number1,number2 ) != SUCCESSFUL_RETURN )
193 
194  return SUCCESSFUL_RETURN;
195 }
196 
197 
198 /*
199  * end of file
200  */
Allows to pass back messages to the calling function.
Base class for managing working sets of bounds and constraints.
#define ST_UNDEFINED
returnValue swapIndex(Indexlist *const indexlist, int number1, int number2)
returnValue addIndex(Indexlist *const indexlist, int newnumber, SubjectToStatus newstatus)
returnValue removeIndex(Indexlist *const indexlist, int removenumber)
void rhs(const real_t *x, real_t *f)
#define BT_TRUE
Definition: acado_types.hpp:47


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