90 for( run1 = 0; run1 <=
T; run1++ ){
95 z[0].
setZ( run1, iter );
98 for( run2 = 0; run2 < nc; run2++ ){
99 resL( run2, 0 ) =
lb[run1][run2] - result(run2);
100 resU( run2, 0 ) =
ub[run1][run2] - result(run2);
138 for( run3 = 0; run3 <
N; run3++ )
151 for( run1 = 0; run1 < nBDirs; run1++ )
155 if(
nx > 0 ) Dx .
setRow( run1,
JJ[0].getX () );
156 if(
na > 0 ) Dxa.
setRow( run1,
JJ[0].getXA() );
157 if(
np > 0 ) Dp .
setRow( run1,
JJ[0].getP () );
158 if(
nu > 0 ) Du .
setRow( run1,
JJ[0].getU () );
159 if(
nw > 0 ) Dw .
setRow( run1,
JJ[0].getW () );
201 for( run3 = 0; run3 <
N; run3++ ){
212 double *bseed1 =
new double[nc];
213 double *bseed2 =
new double[nc];
214 double *
R =
new double[nc];
216 double *
H =
new double[fcn[0].getNumberOfVariables() +1];
217 double *fseed =
new double[fcn[0].getNumberOfVariables() +1];
219 for( run1 = 0; run1 < nc; run1++ ){
220 bseed1[run1] = seed(run1,0);
224 for( run1 = 0; run1 < fcn[0].getNumberOfVariables()+1; run1++ )
239 for( run2 = 0; run2 <
nx; run2++ ){
244 fcn[0].AD_forward( run3, fseed, R );
245 for( run1 = 0; run1 < nc; run1++ )
246 Dx( run1, run2 ) = R[run1];
247 fseed[y_index[0][run2]] = 0.0;
251 for( run1 = 0; run1 <= fcn[0].getNumberOfVariables(); run1++ ){
256 fcn[0].AD_backward2( run3, bseed1, bseed2, J, H );
258 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2, run1 ) = -H[y_index[0][run1]];
259 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2, run1-nx ) = -H[y_index[0][run1]];
260 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2, run1-nx-na ) = -H[y_index[0][run1]];
261 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2, run1-nx-na-np ) = -H[y_index[0][run1]];
262 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2, run1-nx-na-np-nu ) = -H[y_index[0][run1]];
269 if( nx > 0 ) hessian.
addDense( run3, run3, Hx );
270 if(
na > 0 ) hessian.
addDense( run3, N + run3, Hxa );
271 if(
np > 0 ) hessian.
addDense( run3, 2*N + run3, Hp );
272 if(
nu > 0 ) hessian.
addDense( run3, 3*N + run3, Hu );
273 if(
nw > 0 ) hessian.
addDense( run3, 4*N + run3, Hw );
282 for( run2 = nx; run2 < nx+
na; run2++ ){
287 fcn[0].AD_forward( run3, fseed, R );
288 for( run1 = 0; run1 < nc; run1++ )
289 Dxa( run1, run2-nx ) = R[run1];
290 fseed[y_index[0][run2]] = 0.0;
294 for( run1 = 0; run1 <= fcn[0].getNumberOfVariables(); run1++ ){
299 fcn[0].AD_backward2( run3, bseed1, bseed2, J, H );
301 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2-nx, run1 ) = -H[y_index[0][run1]];
302 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2-nx, run1-nx ) = -H[y_index[0][run1]];
303 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2-nx, run1-nx-na ) = -H[y_index[0][run1]];
304 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2-nx, run1-nx-na-np ) = -H[y_index[0][run1]];
305 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2-nx, run1-nx-na-np-nu ) = -H[y_index[0][run1]];
312 if( nx > 0 ) hessian.
addDense( N+run3, run3, Hx );
313 if( na > 0 ) hessian.
addDense( N+run3, N + run3, Hxa );
314 if(
np > 0 ) hessian.
addDense( N+run3, 2*N + run3, Hp );
315 if(
nu > 0 ) hessian.
addDense( N+run3, 3*N + run3, Hu );
316 if(
nw > 0 ) hessian.
addDense( N+run3, 4*N + run3, Hw );
325 for( run2 = nx+na; run2 < nx+na+
np; run2++ ){
330 fcn[0].AD_forward( run3, fseed, R );
331 for( run1 = 0; run1 < nc; run1++ )
332 Dp( run1, run2-nx-na ) = R[run1];
333 fseed[y_index[0][run2]] = 0.0;
337 for( run1 = 0; run1 <= fcn[0].getNumberOfVariables(); run1++ ){
342 fcn[0].AD_backward2( run3, bseed1, bseed2, J, H );
344 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2-nx-na, run1 ) = -H[y_index[0][run1]];
345 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2-nx-na, run1-nx ) = -H[y_index[0][run1]];
346 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2-nx-na, run1-nx-na ) = -H[y_index[0][run1]];
347 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2-nx-na, run1-nx-na-np ) = -H[y_index[0][run1]];
348 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2-nx-na, run1-nx-na-np-nu ) = -H[y_index[0][run1]];
355 if( nx > 0 ) hessian.
addDense( 2*N+run3, run3, Hx );
356 if( na > 0 ) hessian.
addDense( 2*N+run3, N + run3, Hxa );
357 if( np > 0 ) hessian.
addDense( 2*N+run3, 2*N + run3, Hp );
358 if(
nu > 0 ) hessian.
addDense( 2*N+run3, 3*N + run3, Hu );
359 if(
nw > 0 ) hessian.
addDense( 2*N+run3, 4*N + run3, Hw );
369 for( run2 = nx+na+np; run2 < nx+na+np+
nu; run2++ ){
374 fcn[0].AD_forward( run3, fseed, R );
375 for( run1 = 0; run1 < nc; run1++ )
376 Du( run1, run2-nx-na-np ) = R[run1];
377 fseed[y_index[0][run2]] = 0.0;
381 for( run1 = 0; run1 <= fcn[0].getNumberOfVariables(); run1++ ){
386 fcn[0].AD_backward2( run3, bseed1, bseed2, J, H );
388 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2-nx-na-np, run1 ) = -H[y_index[0][run1]];
389 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2-nx-na-np, run1-nx ) = -H[y_index[0][run1]];
390 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2-nx-na-np, run1-nx-na ) = -H[y_index[0][run1]];
391 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2-nx-na-np, run1-nx-na-np ) = -H[y_index[0][run1]];
392 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2-nx-na-np, run1-nx-na-np-nu ) = -H[y_index[0][run1]];
399 if( nx > 0 ) hessian.
addDense( 3*N+run3, run3, Hx );
400 if( na > 0 ) hessian.
addDense( 3*N+run3, N + run3, Hxa );
401 if( np > 0 ) hessian.
addDense( 3*N+run3, 2*N + run3, Hp );
402 if( nu > 0 ) hessian.
addDense( 3*N+run3, 3*N + run3, Hu );
403 if(
nw > 0 ) hessian.
addDense( 3*N+run3, 4*N + run3, Hw );
412 for( run2 = nx+na+np+nu; run2 < nx+na+np+nu+
nw; run2++ ){
417 fcn[0].AD_forward( run3, fseed, R );
418 for( run1 = 0; run1 < nc; run1++ )
419 Dw( run1, run2-nx-na-np-nu ) = R[run1];
420 fseed[y_index[0][run2]] = 0.0;
424 for( run1 = 0; run1 <= fcn[0].getNumberOfVariables(); run1++ ){
429 fcn[0].AD_backward2( run3, bseed1, bseed2, J, H );
431 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2-nx-na-np-nu, run1 ) = -H[y_index[0][run1]];
432 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2-nx-na-np-nu, run1-nx ) = -H[y_index[0][run1]];
433 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2-nx-na-np-nu, run1-nx-na ) = -H[y_index[0][run1]];
434 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2-nx-na-np-nu, run1-nx-na-np ) = -H[y_index[0][run1]];
435 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2-nx-na-np-nu, run1-nx-na-np-nu ) = -H[y_index[0][run1]];
442 if( nx > 0 ) hessian.
addDense( 4*N+run3, run3, Hx );
443 if( na > 0 ) hessian.
addDense( 4*N+run3, N + run3, Hxa );
444 if( np > 0 ) hessian.
addDense( 4*N+run3, 2*N + run3, Hp );
445 if( nu > 0 ) hessian.
addDense( 4*N+run3, 3*N + run3, Hu );
446 if( nw > 0 ) hessian.
addDense( 4*N+run3, 4*N + run3, Hw );
Data class for storing generic optimization variables.
Implements a very rudimentary block sparse matrix class.
returnValue evaluateSensitivities()
USING_NAMESPACE_ACADO typedef TaylorVariable< Interval > T
ConstraintElement & operator=(const ConstraintElement &rhs)
void init(unsigned _nRows=0, unsigned _nCols=0)
returnValue setDense(uint rowIdx, uint colIdx, const DMatrix &value)
Allows to pass back messages to the calling function.
DVector evaluate(const EvaluationPoint &x, const int &number=0)
returnValue setZ(const uint &idx, const OCPiterate &iter)
Allows to conveniently handle (one-dimensional) grids consisting of time points.
uint getLastIndex() const
#define CLOSE_NAMESPACE_ACADO
Stores and evaluates path constraints within optimal control problems.
returnValue getSubBlock(uint rowIdx, uint colIdx, DMatrix &value) const
Base class for all kind of constraints (except for bounds) within optimal control problems...
returnValue init(uint _nRows, uint _nCols)
GenericMatrix & setRow(unsigned _idx, const GenericVector< T > &_values)
void rhs(const real_t *x, real_t *f)
returnValue evaluate(const OCPiterate &iter)
PathConstraint & operator=(const PathConstraint &rhs)
uint getNumPoints() const
virtual ~PathConstraint()
#define BEGIN_NAMESPACE_ACADO
returnValue addDense(uint rowIdx, uint colIdx, const DMatrix &value)
int getNumberOfVariables() const
GenericVector< T > getRow(unsigned _idx) const
#define ACADOERROR(retval)