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();
181 if(
NDX2 > 0 && (NDX2 < NX2 || NDX2 > (
NX1+
NX2)) ) {
188 for(
uint i = 0; i < rhs_.getDim(); i++ ) {
200 for(
uint i = 0; i < rhs_.getDim(); i++ ) {
228 bool gradientUpdate = (bool) gradientUp;
231 if( gradientUpdate ) {
256 for(
uint j = 0; j <= i; j++ ) {
257 new_expr << expr(i,j);
278 bool gradientUpdate = (bool) gradientUp;
284 ACADOWARNINGTEXT(
RET_INVALID_OPTION,
"The FORWARD_OVER_BACKWARD implementation is only for illustrational purposes, since the SYMMETRIC scheme will always outperform this.");
297 if(
NX2 > 0 ||
NXA > 0 ) {
306 if( liftMode == 4 ) {
326 std::string tempString;
400 if( liftMode == 1 || liftMode == 4 ) {
423 loop->addStatement( std::string(
"if( run > 0 ) {\n") );
428 loop->addStatement( loopTemp2 );
430 loop->addStatement( std::string(
"}\nelse{\n") );
434 loop->addStatement( std::string(
"}\n") );
443 if( liftMode == 1 || liftMode == 4 ) {
450 loop->addStatement( loopTemp1 );
463 loop->addStatement( std::string(
"if( run > 0 ) {\n") );
465 for( run5 = 0; run5 <
numStages; run5++ ) {
473 loop->addStatement( deltaLoop );
474 loop->addStatement( std::string(
"}\nelse{\n") );
476 loop->addStatement( std::string(
"}\n") );
487 if( liftMode == 1 ) {
501 else if( liftMode == 4 ) {
508 for( run5 = 0; run5 <
NX; run5++ ) {
514 for( run5 = 0; run5 <
NX2; run5++ ) {
522 for( run5 = 0; run5 <
NXA; run5++ ) {
530 loop->addStatement( loopTemp );
531 if( gradientUpdate ) {
536 for( run5 = 0; run5 <
NX; run5++ ) {
542 loop->addStatement( std::string(
"if( run == 0 ) {\n") );
544 for( run5 = 0; run5 <
NXA; run5++ ) {
548 loop->addStatement( std::string(
"}\n") );
561 loop->addStatement(
"}\n" );
571 if( !gradientUpdate ) zeroM = zeros<double>(1,NX*(NX+
NU)+
NU*
NU);
572 else zeroM = zeros<double>(1,NX*(NX+
NU)+NU*NU+NX+NU);
587 for( run5 = 0; run5 <
numStages; run5++ ) {
594 for( run5 = 0; run5 <
numStages; run5++ ) {
598 for( run6 = 0; run6 <
numStages; run6++ ) {
611 zeroM = zeros<double>(NX+
NU,NX+
NU);
613 for( run5 = 0; run5 <
numStages; run5++ ) {
618 diffLoop1.
addStatement( tmp_index1 == k_index+i*(NX+NU) );
621 for( run6 = 0; run6 <
numStages; run6++ ) {
625 loop2->addStatement( diffLoop1 );
629 if( gradientUpdate ) {
633 loop2->addStatement( gradLoop );
637 for( run6 = 0; run6 < NX+
NU; run6++ ) {
640 if( gradientUpdate ) {
647 diffLoop3.
addStatement( tmp_index1 == k_index+i*(NX+NU) );
650 for( run6 = 0; run6 <
numStages; run6++ ) {
654 loop2->addStatement( diffLoop3 );
661 for( run6 = 0; run6 <
NX; run6++ ) {
664 for( run6 = 0; run6 <
NX; run6++ ) {
668 for( run6 = 0; run6 <
NU; run6++ ) {
675 diffLoop5.
addStatement( tmp_index1 == k_index+i*(NX+NU) );
680 loop2->addStatement( diffLoop5 );
684 for( run6 = 0; run6 <
NX; run6++ ) {
687 for( run6 = 0; run6 <
NX; run6++ ) {
690 for( run6 = 0; run6 <
NU; run6++ ) {
768 for(
uint index = 0; index <
NX; index++ ) {
777 for(
uint index = 0; index <
NX; index++ ) {
836 for(
uint loop_i = 0; loop_i <
NX; loop_i++ ) {
841 loop43.
addStatement( tmp_index2 == tmp_index1+NX+index1 );
843 for(
uint loop_i = 0; loop_i <
NX; loop_i++ ) {
860 loop32.
addStatement( tmp_index2 == tmp_index1+NX+index1 );
972 bool gradientUpdate = (bool) gradientUp;
994 if( gradientUpdate ) {
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
Allows to export a tailored lifted implicit Runge-Kutta integrator with forward sensitivity generatio...
ExportVariable rk_xxx_traj
ExportVariable getRow(const ExportIndex &idx) const
Expression backwardDerivative(const Expression &arg1, const Expression &arg2)
const std::string getNameSolveTransposeReuseFunction()
returnValue initializeDDMatrix()
ExportVariable getGlobalExportVariable() const
double getFirstTime() const
ExportVariable getTranspose() const
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
GenericMatrix & appendCols(const GenericMatrix &_arg)
ExportVariable rk_adj_traj
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)
ExportVariable getAuxVariable() const
std::vector< ExportAcadoFunction > outputs
ForwardBackwardLiftedIRKExport(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
Allows to pass back messages to the calling function.
GenericMatrix & makeVector()
ExportVariable rk_b_trans
virtual returnValue getCode(ExportStatementBlock &code)
returnValue initializeCoefficients()
Expression forwardDerivative(const Expression &arg1, const Expression &arg2)
ExportLinearSolver * solver
returnValue addComment(const std::string &_comment)
Block< Derived > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
returnValue updateHessianTerm(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2)
std::vector< ExportAcadoFunction > diffs_outputs
ExportVariable rk_diffsPrev2
Allows to export a tailored lifted implicit Runge-Kutta integrator with forward-over-adjoint second o...
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 rk_diffK_local
ExportVariable getElement(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
ExportVariable rk_diffsTemp2
#define CLOSE_NAMESPACE_ACADO
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)
Base class for all variables within the symbolic expressions family.
ExportVariable rk_Xhat_traj
ExportAcadoFunction diffs_rhs3
virtual returnValue updateImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &tmp_index)
DVector evaluateDerivedPolynomial(double time)
virtual returnValue setup()
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
Expression multipleForwardDerivative(const Expression &arg1, const Expression &arg2, const Expression &seed)
ExportVariable rk_auxSolver
ExportVariable makeRowVector() const
const std::string getNameSolveReuseFunction()
ExportVariable rk_Khat_traj
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_hess_tmp1
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
virtual ~ForwardBackwardLiftedIRKExport()
Expression & appendRows(const Expression &arg)
Encapsulates all user interaction for setting options, logging data and plotting results.
virtual returnValue setDifferentialEquation(const Expression &rhs)
virtual uint getDim() const
returnValue addStatement(const ExportStatement &_statement)
std::string getFullName() const
returnValue addLinebreak(uint num=1)
ForwardBackwardLiftedIRKExport & operator=(const ForwardBackwardLiftedIRKExport &arg)
#define ACADOWARNINGTEXT(retval, text)
ExportAcadoFunction diffs_sweep
ExportVariable rk_diffsNew2
uint getNumIntervals() const
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)
ExportAcadoFunction lin_input
double getLastTime() const
ExportVariable rk_stageValues
std::vector< ExportVariable > rk_outputs
#define BEGIN_NAMESPACE_ACADO
ExportVariable error_code
returnValue clearStaticCounters()
ExportVariable rk_adj_diffs_tmp
ExportVariable rk_hess_tmp2
virtual returnValue setup()
returnValue addFunction(const ExportFunction &_function)
ExportAcadoFunction adjoint_sweep
virtual returnValue clear()
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)
ExportAcadoFunction forward_sweep
virtual returnValue getCode(ExportStatementBlock &code)=0
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)
Allows to export code for a block of statements.
Expression getRows(const uint &rowIdx1, const uint &rowIdx2) const
ExportArgument getAddress(const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
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.
returnValue addFunctionCall(const std::string &_fName, const ExportArgument &_argument1=emptyConstExportArgument, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
std::string getName() const