qpOASES 3.2.1
An Implementation of the Online Active Set Strategy
QProblem.ipp
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-2017 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
38
39
40/*****************************************************************************
41 * P U B L I C *
42 *****************************************************************************/
43
44
45/*
46 * g e t C o n s t r a i n t s
47 */
49{
50 int_t nV = getNV( );
51
52 if ( nV == 0 )
54
55 _constraints = constraints;
56
57 return SUCCESSFUL_RETURN;
58}
59
60
61
62/*
63 * g e t N C
64 */
65inline int_t QProblem::getNC( ) const
66{
67 return constraints.getNC( );
68}
69
70
71/*
72 * g e t N E C
73 */
74inline int_t QProblem::getNEC( ) const
75{
76 return constraints.getNEC( );
77}
78
79
80/*
81 * g e t N A C
82 */
83inline int_t QProblem::getNAC( ) const
84{
85 return constraints.getNAC( );
86}
87
88
89/*
90 * g e t N I A C
91 */
92inline int_t QProblem::getNIAC( ) const
93{
94 return constraints.getNIAC( );
95}
96
97
98
99/*****************************************************************************
100 * P R O T E C T E D *
101 *****************************************************************************/
102
103
104/*
105 * s e t A
106 */
108{
109 int_t j;
110 int_t nV = getNV( );
111 int_t nC = getNC( );
112
113 if ( nV == 0 )
115
116 if ( A_new == 0 )
118
119 /* Set constraint matrix AND update member AX. */
120 if ( ( freeConstraintMatrix == BT_TRUE ) && ( A != 0 ) )
121 {
122 delete A;
123 A = 0;
124 }
125 A = A_new;
127
128 A->times(1, 1.0, x, nV, 0.0, Ax, nC);
129
131
132 for( j=0; j<nC; ++j )
133 {
134 Ax_u[j] = ubA[j] - Ax[j];
135 Ax_l[j] = Ax[j] - lbA[j];
136 // (ckirches) disable constraints with empty rows
137 if ( isZero( tempC[j] ) == BT_TRUE )
139 }
140
141
142 return SUCCESSFUL_RETURN;
143}
144
145
146/*
147 * s e t A
148 */
149inline returnValue QProblem::setA( const real_t* const A_new )
150{
151 int_t j;
152 int_t nV = getNV( );
153 int_t nC = getNC( );
154 DenseMatrix* dA;
155
156 if ( nV == 0 )
158
159 if ( A_new == 0 )
161
162 /* Set constraint matrix AND update member AX. */
163 if ( ( freeConstraintMatrix == BT_TRUE ) && ( A != 0 ) )
164 {
165 delete A;
166 A = 0;
167 }
168 A = dA = new DenseMatrix(nC, nV, nV, (real_t*) A_new);
170
171 A->times(1, 1.0, x, nV, 0.0, Ax, nC);
172
173 for( j=0; j<nC; ++j )
174 {
175 Ax_u[j] = ubA[j] - Ax[j];
176 Ax_l[j] = Ax[j] - lbA[j];
177 }
178
179 return SUCCESSFUL_RETURN;
180}
181
182
183/*
184 * s e t L B A
185 */
186inline returnValue QProblem::setLBA( const real_t* const lbA_new )
187{
188 uint_t i;
189 uint_t nV = (uint_t)getNV( );
190 uint_t nC = (uint_t)getNC( );
191
192 if ( nV == 0 )
194
195 if ( lbA_new != 0 )
196 {
197 memcpy( lbA,lbA_new,nC*sizeof(real_t) );
198 }
199 else
200 {
201 /* if no lower constraints' bounds are specified, set them to -infinity */
202 for( i=0; i<nC; ++i )
203 lbA[i] = -INFTY;
204 }
205
206 return SUCCESSFUL_RETURN;
207}
208
209
210/*
211 * s e t L B A
212 */
214{
215 int_t nV = getNV( );
216 int_t nC = getNC( );
217
218 if ( nV == 0 )
220
221 if ( ( number >= 0 ) && ( number < nC ) )
222 {
223 lbA[number] = value;
224 return SUCCESSFUL_RETURN;
225 }
226 else
228}
229
230
231/*
232 * s e t U B A
233 */
234inline returnValue QProblem::setUBA( const real_t* const ubA_new )
235{
236 uint_t i;
237 uint_t nV = (uint_t)getNV( );
238 uint_t nC = (uint_t)getNC( );
239
240 if ( nV == 0 )
242
243 if ( ubA_new != 0 )
244 {
245 memcpy( ubA,ubA_new,nC*sizeof(real_t) );
246 }
247 else
248 {
249 /* if no upper constraints' bounds are specified, set them to infinity */
250 for( i=0; i<nC; ++i )
251 ubA[i] = INFTY;
252 }
253
254 return SUCCESSFUL_RETURN;
255}
256
257
258/*
259 * s e t U B A
260 */
262{
263 int_t nV = getNV( );
264 int_t nC = getNC( );
265
266 if ( nV == 0 )
268
269 if ( ( number >= 0 ) && ( number < nC ) )
270 {
271 ubA[number] = value;
272 return SUCCESSFUL_RETURN;
273 }
274 else
276}
277
278
280
281
282/*
283 * end of file
284 */
const real_t INFTY
Definition Constants.hpp:61
returnValue
Defines all symbols for global return values.
Definition MessageHandling.hpp:65
@ RET_QPOBJECT_NOT_SETUP
Definition MessageHandling.hpp:100
@ RET_INVALID_ARGUMENTS
Definition MessageHandling.hpp:71
@ RET_INDEX_OUT_OF_BOUNDS
Definition MessageHandling.hpp:70
@ SUCCESSFUL_RETURN
Definition MessageHandling.hpp:68
#define THROWERROR(retval)
Definition MessageHandling.hpp:456
@ BT_TRUE
Definition Types.hpp:206
@ BT_FALSE
Definition Types.hpp:205
@ ST_DISABLED
Definition Types.hpp:266
int int_t
Definition Types.hpp:180
BEGIN_NAMESPACE_QPOASES typedef double real_t
Definition Types.hpp:171
#define END_NAMESPACE_QPOASES
Definition Types.hpp:110
#define BEGIN_NAMESPACE_QPOASES
Definition Types.hpp:107
BooleanType isZero(real_t x, real_t TOL=ZERO)
Definition Utils.ipp:60
Manages working sets of constraints.
Definition Constraints.hpp:57
int_t getNC() const
Definition Constraints.ipp:47
int_t getNIAC() const
Definition Constraints.ipp:92
int_t getNAC() const
Definition Constraints.ipp:83
int_t getNEC() const
Definition Constraints.ipp:56
Interfaces matrix-vector operations tailored to general dense matrices.
Definition Matrices.hpp:329
Abstract base class for interfacing tailored matrix-vector operations.
Definition Matrices.hpp:60
virtual returnValue times(int_t xN, real_t alpha, const real_t *x, int_t xLD, real_t beta, real_t *y, int_t yLD) const =0
virtual real_t getRowNorm(int_t rNum, int_t type=2) const =0
int_t getNV() const
Definition QProblemB.ipp:64
real_t * x
Definition QProblemB.hpp:983
real_t * Ax_u
Definition QProblem.hpp:1057
Constraints constraints
Definition QProblem.hpp:1047
int_t getNAC() const
Definition QProblem.ipp:83
real_t * tempC
Definition QProblem.hpp:1069
returnValue setUBA(const real_t *const ubA_new)
Definition QProblem.ipp:234
BooleanType freeConstraintMatrix
Definition QProblem.hpp:1041
Matrix * A
Definition QProblem.hpp:1042
returnValue setLBA(const real_t *const lbA_new)
Definition QProblem.ipp:186
int_t getNEC() const
Definition QProblem.ipp:74
real_t * Ax
Definition QProblem.hpp:1053
real_t * Ax_l
Definition QProblem.hpp:1055
real_t * lbA
Definition QProblem.hpp:1044
int_t getNC() const
Definition QProblem.ipp:65
returnValue getConstraints(Constraints &_constraints) const
Definition QProblem.ipp:48
int_t getNIAC() const
Definition QProblem.ipp:92
real_t * ubA
Definition QProblem.hpp:1045
returnValue setA(Matrix *A_new)
Definition QProblem.ipp:107
returnValue setType(int_t i, SubjectToType value)
Definition SubjectTo.ipp:90