82 const int nc =
getNC();
90 for( run1 = 0; run1 < nc; run1++ ){
91 resL( run1, 0 ) =
lb[0][run1];
92 resU( run1, 0 ) =
ub[0][run1];
98 for( run2 = 0; run2 <=
T; run2++ ){
100 z[run2].
setZ( run2, iter );
103 for( run1 = 0; run1 < nc; run1++ ){
104 resL( run1, 0 ) -= result(run1);
105 resU( run1, 0 ) -= result(run1);
159 for( run3 = 0; run3 <
N; run3++ )
164 for( run1 = 0; run1 < nBDirs; run1++ )
176 if(
nx > 0 ) Dx .
setRow( run1,
JJ[run3].getX () );
177 if(
na > 0 ) Dxa.
setRow( run1,
JJ[run3].getXA() );
178 if(
np > 0 ) Dp .
setRow( run1,
JJ[run3].getP () );
179 if(
nu > 0 ) Du .
setRow( run1,
JJ[run3].getU () );
180 if(
nw > 0 ) Dw .
setRow( run1,
JJ[run3].getW () );
235 int run1, run2, run3;
237 const int nc =
getNC();
242 for( run3 = 0; run3 <
N; run3++ ){
249 for( run3 = 0; run3 <
N; run3++ ){
251 double *bseed1 =
new double[nc];
252 double *bseed2 =
new double[nc];
253 double *
R =
new double[nc];
256 double *
H1 =
new double[fcn[run3].getNumberOfVariables() +1];
257 double *fseed1 =
new double[fcn[run3].getNumberOfVariables() +1];
259 for( run1 = 0; run1 < nc; run1++ ){
260 bseed1[run1] = seed(run1,0);
263 for( run1 = 0; run1 < fcn[run3].getNumberOfVariables()+1; run1++ )
279 for( run2 = 0; run2 <
nx; run2++ ){
283 fseed1[
y_index[0][run2]] = 1.0;
284 fcn[run3].AD_forward( 0, fseed1, R );
285 for( run1 = 0; run1 < nc; run1++ )
286 Dx( run1, run2 ) = R[run1];
287 fseed1[y_index[0][run2]] = 0.0;
292 for( run1 = 0; run1 <= fcn[run3].getNumberOfVariables(); run1++ ){
297 fcn[run3].AD_backward2( 0, bseed1, bseed2, J1, H1 );
299 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2, run1 ) = -H1[y_index[0][run1]];
300 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2, run1-nx ) = -H1[y_index[0][run1]];
301 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2, run1-nx-na ) = -H1[y_index[0][run1]];
302 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2, run1-nx-na-np ) = -H1[y_index[0][run1]];
303 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2, run1-nx-na-np-nu ) = -H1[y_index[0][run1]];
310 if( nx > 0 ) hessian.
addDense( run3, run3, Hx );
311 if(
na > 0 ) hessian.
addDense( run3, N + run3, Hxa );
312 if(
np > 0 ) hessian.
addDense( run3, 2*N + run3, Hp );
313 if(
nu > 0 ) hessian.
addDense( run3, 3*N + run3, Hu );
314 if(
nw > 0 ) hessian.
addDense( run3, 4*N + run3, Hw );
325 for( run2 = nx; run2 < nx+
na; run2++ ){
329 fseed1[
y_index[0][run2]] = 1.0;
330 fcn[run3].AD_forward( 0, fseed1, R );
331 for( run1 = 0; run1 < nc; run1++ )
332 Dxa( run1, run2-nx ) = R[run1];
333 fseed1[y_index[0][run2]] = 0.0;
337 for( run1 = 0; run1 <= fcn[run3].getNumberOfVariables(); run1++ ){
342 fcn[run3].AD_backward2( 0, bseed1, bseed2, J1, H1 );
344 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2-nx, run1 ) = -H1[y_index[0][run1]];
345 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2-nx, run1-nx ) = -H1[y_index[0][run1]];
346 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2-nx, run1-nx-na ) = -H1[y_index[0][run1]];
347 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2-nx, run1-nx-na-np ) = -H1[y_index[0][run1]];
348 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2-nx, run1-nx-na-np-nu ) = -H1[y_index[0][run1]];
355 if( nx > 0 ) hessian.
addDense( N+run3, run3, Hx );
356 if( na > 0 ) hessian.
addDense( N+run3, N + run3, Hxa );
357 if(
np > 0 ) hessian.
addDense( N+run3, 2*N + run3, Hp );
358 if(
nu > 0 ) hessian.
addDense( N+run3, 3*N + run3, Hu );
359 if(
nw > 0 ) hessian.
addDense( N+run3, 4*N + run3, Hw );
371 for( run2 = nx+na; run2 < nx+na+
np; run2++ ){
375 fseed1[
y_index[0][run2]] = 1.0;
376 fcn[run3].AD_forward( 0, fseed1, R );
377 for( run1 = 0; run1 < nc; run1++ )
378 Dp( run1, run2-nx-na ) = R[run1];
379 fseed1[y_index[0][run2]] = 0.0;
383 for( run1 = 0; run1 <= fcn[run3].getNumberOfVariables(); run1++ ){
388 fcn[run3].AD_backward2( 0, bseed1, bseed2, J1, H1 );
390 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2-nx-na, run1 ) = -H1[y_index[0][run1]];
391 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2-nx-na, run1-nx ) = -H1[y_index[0][run1]];
392 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2-nx-na, run1-nx-na ) = -H1[y_index[0][run1]];
393 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2-nx-na, run1-nx-na-np ) = -H1[y_index[0][run1]];
394 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2-nx-na, run1-nx-na-np-nu ) = -H1[y_index[0][run1]];
399 if( nx > 0 ) hessian.
addDense( 2*N+run3, run3, Hx );
400 if( na > 0 ) hessian.
addDense( 2*N+run3, N + run3, Hxa );
401 if( np > 0 ) hessian.
addDense( 2*N+run3, 2*N + run3, Hp );
402 if(
nu > 0 ) hessian.
addDense( 2*N+run3, 3*N + run3, Hu );
403 if(
nw > 0 ) hessian.
addDense( 2*N+run3, 4*N + run3, Hw );
414 for( run2 = nx+na+np; run2 < nx+na+np+
nu; run2++ ){
418 fseed1[
y_index[0][run2]] = 1.0;
419 fcn[run3].AD_forward( 0, fseed1, R );
420 for( run1 = 0; run1 < nc; run1++ )
421 Du( run1, run2-nx-na-np ) = R[run1];
422 fseed1[y_index[0][run2]] = 0.0;
426 for( run1 = 0; run1 <= fcn[run3].getNumberOfVariables(); run1++ ){
431 fcn[run3].AD_backward2( 0, bseed1, bseed2, J1, H1 );
433 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2-nx-na-np, run1 ) = -H1[y_index[0][run1]];
434 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2-nx-na-np, run1-nx ) = -H1[y_index[0][run1]];
435 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2-nx-na-np, run1-nx-na ) = -H1[y_index[0][run1]];
436 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2-nx-na-np, run1-nx-na-np ) = -H1[y_index[0][run1]];
437 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2-nx-na-np, run1-nx-na-np-nu ) = -H1[y_index[0][run1]];
444 if( nx > 0 ) hessian.
addDense( 3*N+run3, run3, Hx );
445 if( na > 0 ) hessian.
addDense( 3*N+run3, N + run3, Hxa );
446 if( np > 0 ) hessian.
addDense( 3*N+run3, 2*N + run3, Hp );
447 if( nu > 0 ) hessian.
addDense( 3*N+run3, 3*N + run3, Hu );
448 if(
nw > 0 ) hessian.
addDense( 3*N+run3, 4*N + run3, Hw );
459 for( run2 = nx+na+np+nu; run2 < nx+na+np+nu+
nw; run2++ ){
463 fseed1[
y_index[0][run2]] = 1.0;
464 fcn[run3].AD_forward( 0, fseed1, R );
465 for( run1 = 0; run1 < nc; run1++ )
466 Dw( run1, run2-nx-na-np-nu ) = R[run1];
467 fseed1[y_index[0][run2]] = 0.0;
471 for( run1 = 0; run1 <= fcn[run3].getNumberOfVariables(); run1++ ){
476 fcn[run3].AD_backward2( 0, bseed1, bseed2, J1, H1 );
478 for( run1 = 0 ; run1 <
nx ; run1++ ) Hx ( run2-nx-na-np-nu, run1 ) = -H1[y_index[0][run1]];
479 for( run1 = nx ; run1 < nx+
na ; run1++ ) Hxa( run2-nx-na-np-nu, run1-nx ) = -H1[y_index[0][run1]];
480 for( run1 = nx+na ; run1 < nx+na+
np ; run1++ ) Hp ( run2-nx-na-np-nu, run1-nx-na ) = -H1[y_index[0][run1]];
481 for( run1 = nx+na+np ; run1 < nx+na+np+
nu ; run1++ ) Hu ( run2-nx-na-np-nu, run1-nx-na-np ) = -H1[y_index[0][run1]];
482 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ) Hw ( run2-nx-na-np-nu, run1-nx-na-np-nu ) = -H1[y_index[0][run1]];
489 if( nx > 0 ) hessian.
addDense( 4*N+run3, run3, Hx );
490 if( na > 0 ) hessian.
addDense( 4*N+run3, N + run3, Hxa );
491 if( np > 0 ) hessian.
addDense( 4*N+run3, 2*N + run3, Hp );
492 if( nu > 0 ) hessian.
addDense( 4*N+run3, 3*N + run3, Hu );
493 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.
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)
CoupledPathConstraint & operator=(const CoupledPathConstraint &rhs)
Allows to conveniently handle (one-dimensional) grids consisting of time points.
uint getLastIndex() const
#define CLOSE_NAMESPACE_ACADO
returnValue getSubBlock(uint rowIdx, uint colIdx, DMatrix &value) const
virtual ~CoupledPathConstraint()
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)
Stores and evaluates coupled path constraints within optimal control problems.
returnValue evaluate(const OCPiterate &iter)
void rhs(const real_t *x, real_t *f)
unsigned getNumRows() const
uint getNumPoints() const
returnValue evaluateSensitivities()
#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)