98 if( (
bSeed != 0) & (hessian == 0) ){
146 for( run2 = 0; run2 <
nx; run2++ ){
152 Dx( 0, run2 ) = J[0];
153 fseed[y_index[run2]] = 0.0;
164 for( run1 = 0; run1 <
nx; run1++ ){
165 Hx( run2, run1 ) = H[y_index[run1]];
167 for( run1 = nx; run1 < nx+
na; run1++ ){
168 Hxa( run2, run1-nx ) = H[y_index[run1]];
170 for( run1 = nx+na; run1 < nx+na+
np; run1++ ){
171 Hp( run2, run1-nx-na ) = H[y_index[run1]];
173 for( run1 = nx+na+np; run1 < nx+na+np+
nu; run1++ ){
174 Hu( run2, run1-nx-na-np ) = H[y_index[run1]];
176 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ){
177 Hw( run2, run1-nx-na-np-nu ) = H[y_index[run1]];
185 if( nx > 0 ) hessian->
setDense( N-1, N-1, Hx );
186 if(
na > 0 ) hessian->
setDense( N-1, 2*N-1, Hxa );
187 if(
np > 0 ) hessian->
setDense( N-1, 3*N-1, Hp );
188 if(
nu > 0 ) hessian->
setDense( N-1, 4*N-1, Hu );
189 if(
nw > 0 ) hessian->
setDense( N-1, 5*N-1, Hw );
198 for( run2 = nx; run2 < nx+
na; run2++ ){
204 Dxa( 0, run2-nx ) = J[0];
205 fseed[y_index[run2]] = 0.0;
216 for( run1 = 0; run1 <
nx; run1++ ){
217 Hx( run2-nx, run1 ) = H[y_index[run1]];
219 for( run1 = nx; run1 < nx+
na; run1++ ){
220 Hxa( run2-nx, run1-nx ) = H[y_index[run1]];
222 for( run1 = nx+na; run1 < nx+na+
np; run1++ ){
223 Hp( run2-nx, run1-nx-na ) = H[y_index[run1]];
225 for( run1 = nx+na+np; run1 < nx+na+np+
nu; run1++ ){
226 Hu( run2-nx, run1-nx-na-np ) = H[y_index[run1]];
228 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ){
229 Hw( run2-nx, run1-nx-na-np-nu ) = H[y_index[run1]];
237 if( nx > 0 ) hessian->
setDense( 2*N-1, N-1, Hx );
238 if( na > 0 ) hessian->
setDense( 2*N-1, 2*N-1, Hxa );
239 if(
np > 0 ) hessian->
setDense( 2*N-1, 3*N-1, Hp );
240 if(
nu > 0 ) hessian->
setDense( 2*N-1, 4*N-1, Hu );
241 if(
nw > 0 ) hessian->
setDense( 2*N-1, 5*N-1, Hw );
250 for( run2 = nx+na; run2 < nx+na+
np; run2++ ){
256 Dp( 0, run2-nx-na ) = J[0];
257 fseed[y_index[run2]] = 0.0;
268 for( run1 = 0; run1 <
nx; run1++ ){
269 Hx( run2-nx-na, run1 ) = H[y_index[run1]];
271 for( run1 = nx; run1 < nx+
na; run1++ ){
272 Hxa( run2-nx-na, run1-nx ) = H[y_index[run1]];
274 for( run1 = nx+na; run1 < nx+na+
np; run1++ ){
275 Hp( run2-nx-na, run1-nx-na ) = H[y_index[run1]];
277 for( run1 = nx+na+np; run1 < nx+na+np+
nu; run1++ ){
278 Hu( run2-nx-na, run1-nx-na-np ) = H[y_index[run1]];
280 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ){
281 Hw( run2-nx-na, run1-nx-na-np-nu ) = H[y_index[run1]];
289 if( nx > 0 ) hessian->
setDense( 3*N-1, N-1, Hx );
290 if( na > 0 ) hessian->
setDense( 3*N-1, 2*N-1, Hxa );
291 if( np > 0 ) hessian->
setDense( 3*N-1, 3*N-1, Hp );
292 if(
nu > 0 ) hessian->
setDense( 3*N-1, 4*N-1, Hu );
293 if(
nw > 0 ) hessian->
setDense( 3*N-1, 5*N-1, Hw );
303 for( run2 = nx+na+np; run2 < nx+na+np+
nu; run2++ ){
309 Du( 0, run2-nx-na-np ) = J[0];
310 fseed[y_index[run2]] = 0.0;
321 for( run1 = 0; run1 <
nx; run1++ ){
322 Hx( run2-nx-na-np, run1 ) = H[y_index[run1]];
324 for( run1 = nx; run1 < nx+
na; run1++ ){
325 Hxa( run2-nx-na-np, run1-nx ) = H[y_index[run1]];
327 for( run1 = nx+na; run1 < nx+na+
np; run1++ ){
328 Hp( run2-nx-na-np, run1-nx-na ) = H[y_index[run1]];
330 for( run1 = nx+na+np; run1 < nx+na+np+
nu; run1++ ){
331 Hu( run2-nx-na-np, run1-nx-na-np ) = H[y_index[run1]];
333 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ){
334 Hw( run2-nx-na-np, run1-nx-na-np-nu ) = H[y_index[run1]];
342 if( nx > 0 ) hessian->
setDense( 4*N-1, N-1, Hx );
343 if( na > 0 ) hessian->
setDense( 4*N-1, 2*N-1, Hxa );
344 if( np > 0 ) hessian->
setDense( 4*N-1, 3*N-1, Hp );
345 if( nu > 0 ) hessian->
setDense( 4*N-1, 4*N-1, Hu );
346 if(
nw > 0 ) hessian->
setDense( 4*N-1, 5*N-1, Hw );
356 for( run2 = nx+na+np+nu; run2 < nx+na+np+nu+
nw; run2++ ){
362 Dw( 0, run2-nx-na-np-nu ) = J[0];
363 fseed[y_index[run2]] = 0.0;
374 for( run1 = 0; run1 <
nx; run1++ ){
375 Hx( run2-nx-na-np-nu, run1 ) = H[y_index[run1]];
377 for( run1 = nx; run1 < nx+
na; run1++ ){
378 Hxa( run2-nx-na-np-nu, run1-nx ) = H[y_index[run1]];
380 for( run1 = nx+na; run1 < nx+na+
np; run1++ ){
381 Hp( run2-nx-na-np-nu, run1-nx-na ) = H[y_index[run1]];
383 for( run1 = nx+na+np; run1 < nx+na+np+
nu; run1++ ){
384 Hu( run2-nx-na-np-nu, run1-nx-na-np ) = H[y_index[run1]];
386 for( run1 = nx+na+np+nu; run1 < nx+na+np+nu+
nw; run1++ ){
387 Hw( run2-nx-na-np-nu, run1-nx-na-np-nu ) = H[y_index[run1]];
395 if( nx > 0 ) hessian->
setDense( 5*N-1, N-1, Hx );
396 if( na > 0 ) hessian->
setDense( 5*N-1, 2*N-1, Hxa );
397 if( np > 0 ) hessian->
setDense( 5*N-1, 3*N-1, Hp );
398 if( nu > 0 ) hessian->
setDense( 5*N-1, 4*N-1, Hu );
399 if( nw > 0 ) hessian->
setDense( 5*N-1, 5*N-1, Hw );
Data class for storing generic optimization variables.
returnValue init(const OCPiterate &x)
Implements a very rudimentary block sparse matrix class.
Base class for all kind of objective function terms within optimal control problems.
Allows to setup and evaluate a general function based on SymbolicExpressions.
void init(unsigned _nRows=0, unsigned _nCols=0)
returnValue evaluateSensitivities(BlockMatrix *hessian)
returnValue setDense(uint rowIdx, uint colIdx, const DMatrix &value)
Stores and evaluates Mayer terms within optimal control problems.
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.
returnValue evaluate(const OCPiterate &x)
uint getLastIndex() const
returnValue AD_backward2(int number, double *seed1, double *seed2, double *df, double *ddf)
#define CLOSE_NAMESPACE_ACADO
Base class for all variables within the symbolic expressions family.
returnValue getSubBlock(uint rowIdx, uint colIdx, DMatrix &value) const
returnValue init(uint _nRows, uint _nCols)
void rhs(const real_t *x, real_t *f)
returnValue AD_backward(const DVector &seed, EvaluationPoint &df, const int &number=0)
DVector AD_forward(const EvaluationPoint &x, const int &number=0)
uint getNumPoints() const
MayerTerm & operator=(const MayerTerm &rhs)
#define BEGIN_NAMESPACE_ACADO
int getNumberOfVariables() const
ObjectiveElement & operator=(const ObjectiveElement &rhs)
GenericVector< T > getRow(unsigned _idx) const
#define ACADOERROR(retval)