46 const std::string& _commonHeaderName
109 for( i = 0; i <
outputs.size(); i++ ) {
110 if(
outputs[i].getGlobalExportVariable().getDim() >= max.
getDim() ) {
111 max =
outputs[i].getGlobalExportVariable();
179 if(
NDX2 > 0 && (NDX2 < NX2 || NDX2 > (
NX1+
NX2)) ) {
186 for(
uint i = 0; i < rhs_.getDim(); i++ ) {
198 for(
uint i = 0; i < rhs_.getDim(); i++ ) {
227 bool gradientUpdate = (bool) gradientUp;
230 if( gradientUpdate ) {
242 else if( gradientUpdate ) {
264 for(
uint j = 0; j <= i; j++ ) {
265 new_expr << expr(i,j);
289 bool gradientUpdate = (bool) gradientUp;
302 if(
NX2 > 0 ||
NXA > 0 ) {
311 if( liftMode == 4 ) {
331 std::string tempString;
405 if( liftMode == 1 || liftMode == 4 ) {
412 if( liftMode == 1 ) {
418 if( liftMode == 1 ) {
430 deltaLoop.addStatement( loopTemp1 );
437 for( run5 = 0; run5 <
numStages; run5++ ) {
440 DMatrix zeroV = zeros<double>(1,numStages*
NX);
441 deltaLoop.addStatement(
rk_b_mu.
getCols(run*numStages*NX,(run+1)*numStages*NX) == zeroV );
450 for( run5 = 0; run5 <
numStages; run5++ ) {
453 for( run5 = 0; run5 <
numStages; run5++ ) {
457 lambdaLoop.addStatement( deltaLoop0 );
459 for( run6 = 0; run6 <
NX; run6++ ) {
462 for( run6 = 0; run6 <
numStages; run6++ ) {
466 for( run6 = 0; run6 <
numStages; run6++ ) {
469 lambdaLoop.addStatement( deltaLoop3 );
475 for( run5 = 0; run5 <
numStages; run5++ ) {
485 if( !gradientUpdate ) zeroM = zeros<double>(1,numX+numU+
NX*
NU);
486 else zeroM = zeros<double>(1,numX+numU+
NX*
NU+
NX+
NU);
503 loop->addStatement( std::string(
"if( run > 0 ) {\n") );
508 loop->addStatement( loopTemp1 );
514 loop->addStatement( loopTemp2 );
520 loop->addStatement( loopTemp3 );
522 loop->addStatement( std::string(
"}\nelse{\n") );
526 loop->addStatement( std::string(
"}\n") );
535 if( liftMode == 4 ) {
542 loop->addStatement( loopTemp1 );
554 if( gradientUpdate) {
555 loop->addStatement( std::string(
"if( run > 0 ) {\n") );
557 for( run5 = 0; run5 <
numStages; run5++ ) {
564 deltaLoop2.
addStatement( tmp_index2 == numStages*k_index+tmp_index1 );
569 loop->addStatement( deltaLoop );
571 loop->addStatement( std::string(
"}\nelse{\n") );
573 loop->addStatement( std::string(
"}\n") );
582 else if( liftMode == 1 ) {
593 if( liftMode == 1 ) {
607 else if( liftMode == 4 ) {
611 if( gradientUpdate ) {
620 if( liftMode == 1 ) {
622 for( run5 = 0; run5 <
NX; run5++ ) {
629 for( run5 = 0; run5 <
NX2; run5++ ) {
637 for( run5 = 0; run5 <
NXA; run5++ ) {
645 loop->addStatement( loopTemp );
646 if( gradientUpdate ) {
651 for( run5 = 0; run5 <
NX; run5++ ) {
657 loop->addStatement( std::string(
"if( run == 0 ) {\n") );
659 for( run5 = 0; run5 <
NXA; run5++ ) {
663 loop->addStatement( std::string(
"}\n") );
666 if( liftMode != 1 ) {
680 loop->addStatement(
"}\n" );
704 for( run5 = 0; run5 <
numStages; run5++ ) {
710 for( run5 = 0; run5 <
numStages; run5++ ) {
714 for( run6 = 0; run6 <
numStages; run6++ ) {
727 if( gradientUpdate ) {
728 for( run5 = 0; run5 <
numStages; run5++ ) {
747 for( run5 = 0; run5 <
numStages; run5++ ) {
755 for( run6 = 0; run6 <
numStages; run6++ ) {
759 loop2->addStatement( diffLoop1 );
763 if( gradientUpdate ) {
767 loop2->addStatement( gradLoop );
771 if( !gradientUpdate ) {
835 bool gradientUpdate = (bool) gradientUp;
840 if( gradientUpdate ) diffsDim +=
NX+
NU;
856 if( gradientUpdate ) {
857 if( (
NX+numX+
NX*NU+numU+
NX+NU) >
NX*(
NX+NU) ) {
876 if( liftMode == 1 ) {
892 if( liftMode == 1 ) {
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
ExportVariable rk_diffsPrev1
ExportVariable rk_adj_diffs_tmp
ExportVariable rk_xxx_traj
ExportVariable rk_b_trans
Expression symmetricDerivative(const Expression &arg1, const Expression &arg2, const Expression &forward_seed, const Expression &backward_seed, Expression *forward_result, Expression *backward_result)
Allows to export a tailored lifted implicit Runge-Kutta integrator with forward sensitivity generatio...
virtual returnValue setup()
virtual returnValue updateImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &tmp_index)
ExportVariable rk_Xhat_traj
virtual returnValue allSensitivitiesImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index1, const ExportIndex &tmp_index2, const ExportIndex &tmp_index3, const ExportIndex &k_index, const ExportVariable &Bh, bool update)
ExportVariable getRow(const ExportIndex &idx) const
const std::string getNameSolveTransposeReuseFunction()
SymmetricLiftedIRKExport(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
Allows to export a tailored lifted implicit Runge-Kutta integrator with symmetric second order sensit...
returnValue initializeDDMatrix()
ExportVariable getGlobalExportVariable() const
double getFirstTime() const
ExportVariable getTranspose() const
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
GenericMatrix & appendCols(const GenericMatrix &_arg)
std::vector< Grid > outputGrids
ExportAcadoFunction diffs_rhs
virtual returnValue solveImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index, const ExportIndex &k_index, const ExportVariable &Ah, const ExportVariable &C, const ExportVariable &det, bool DERIVATIVES=false)
std::vector< ExportAcadoFunction > outputs
ExportVariable rk_diffsPrev3
Allows to pass back messages to the calling function.
returnValue initializeCoefficients()
Expression forwardDerivative(const Expression &arg1, const Expression &arg2)
ExportLinearSolver * solver
returnValue addComment(const std::string &_comment)
ExportVariable getAuxVariable() const
Block< Derived > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
std::vector< ExportAcadoFunction > diffs_outputs
ExportVariable rk_diffsPrev2
Allows to export code of a for-loop.
Expression getCols(const uint &colIdx1, const uint &colIdx2) const
string toString(T const &value)
ExportVariable rk_xxx_lin
ExportVariable getElement(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
ExportVariable rk_diffsTemp2
#define CLOSE_NAMESPACE_ACADO
virtual ~SymmetricLiftedIRKExport()
virtual returnValue evaluateRhsSensitivities(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index1, const ExportIndex &tmp_index2)
ExportVariable getSubMatrix(const ExportIndex &rowIdx1, const ExportIndex &rowIdx2, const ExportIndex &colIdx1, const ExportIndex &colIdx2) const
GenericMatrix< double > DMatrix
Defines a scalar-valued index variable to be used for exporting code.
Expression returnLowerTriangular(const Expression &expr)
virtual returnValue copy(const ImplicitRungeKuttaExport &arg)
ExportVariable rk_diff_lam
Base class for all variables within the symbolic expressions family.
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
ExportAcadoFunction diffs_rhs3
virtual returnValue setDifferentialEquation(const Expression &rhs)
DVector evaluateDerivedPolynomial(double time)
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
Expression multipleForwardDerivative(const Expression &arg1, const Expression &arg2, const Expression &seed)
ExportVariable rk_auxSolver
ExportVariable rk_aux_traj
ExportVariable makeRowVector() const
ExportVariable rk_diff_mu
ExportVariable rk_kkk_prev
ExportVariable rk_Khat_traj
Expression & appendRows(const Expression &arg)
virtual returnValue getCode(ExportStatementBlock &code)
Encapsulates all user interaction for setting options, logging data and plotting results.
virtual uint getDim() const
returnValue addStatement(const ExportStatement &_statement)
std::string getFullName() const
returnValue addLinebreak(uint num=1)
virtual returnValue evaluateAllStatesImplicitSystem(ExportStatementBlock *block, const ExportIndex &k_index, const ExportVariable &Ah, const ExportVariable &C, const ExportIndex &stage, const ExportIndex &i, const ExportIndex &tmp_index)
ExportVariable rk_diffsNew2
uint getNumIntervals() const
ExportVariable rk_kkk_delta
returnValue prepareOutputEvaluation(ExportStatementBlock &code)
DifferentialStateDerivative dx
std::string getName() const
ExportVariable getRows(const ExportIndex &idx1, const ExportIndex &idx2) const
returnValue addDeclaration(const ExportVariable &_data, ExportStruct _dataStruct=ACADO_ANY)
virtual returnValue evaluateRhsInexactSensitivities(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index1, const ExportIndex &tmp_index2, const ExportIndex &tmp_index3, const ExportIndex &k_index, const ExportVariable &Ah)
ExportAcadoFunction lin_input
double getLastTime() const
ExportVariable rk_stageValues
ExportVariable rk_delta_full
std::vector< ExportVariable > rk_outputs
#define BEGIN_NAMESPACE_ACADO
ExportVariable error_code
returnValue clearStaticCounters()
ExportAcadoFunction adjoint_sweep
virtual returnValue setup()
returnValue addFunction(const ExportFunction &_function)
virtual returnValue clear()
ExportAcadoFunction forward_sweep
virtual returnValue getCode(ExportStatementBlock &code)=0
ExportVariable rk_adj_traj
Allows to export code for a block of statements.
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
Expression getRows(const uint &rowIdx1, const uint &rowIdx2) const
ExportArgument getAddress(const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
SymmetricLiftedIRKExport & operator=(const SymmetricLiftedIRKExport &arg)
ExportVariable getCol(const ExportIndex &idx) const
returnValue init(const Function &_f, const std::string &_name="acadoFcn", const uint _numX=0, const uint _numXA=0, const uint _numU=0, const uint _numP=0, const uint _numDX=0, const uint _numOD=0)
ExportFunction & addIndex(const ExportIndex &_index)
#define ACADOERROR(retval)
virtual bool equidistantControlGrid() const
ForwardLiftedIRKExport & operator=(const ForwardLiftedIRKExport &arg)
Defines a matrix-valued variable to be used for exporting code.
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
std::string getName() const
ExportAcadoFunction diffs_sweep