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();
186 if(
NDX2 > 0 && (NDX2 < NX2 || NDX2 > (
NX1+
NX2)) ) {
193 for(
uint i = 0; i < rhs_.getDim(); i++ ) {
282 for(
uint j = 0; j <= i; j++ ) {
283 new_expr << expr(i,j);
320 if(
NX2 > 0 ||
NXA > 0 ) {
349 std::string tempString;
436 loop->addStatement( std::string(
"if( run > 0 ) {\n") );
441 loop->addStatement( loopTemp2 );
443 loop->addStatement( std::string(
"}\nelse{\n") );
447 loop->addStatement( std::string(
"}\n") );
453 loop->addStatement( tmp_index2 == run*(NX+
NXA) );
463 sensitivitiesImplicitSystem( &loop4, run1, i, j, tmp_index1, tmp_index2, run, Ah, Bh, determinant,
true, 2 );
464 loop->addStatement( loop4 );
471 sensitivitiesImplicitSystem( &loop5, run1, i, j, tmp_index1, tmp_index2, run, Ah, Bh, determinant,
false, 0 );
472 loop->addStatement( loop5 );
507 for( run5 = 0; run5 <
NX; run5++ ) {
513 loop->addStatement( std::string(
"if( run == 0 ) {\n") );
515 for( run5 = 0; run5 <
NXA; run5++ ) {
519 loop->addStatement( std::string(
"}\n") );
525 loop->addStatement( std::string(
"if( run == 0 ) {\n" ) );
531 loop->addStatement( std::string(
"}\n" ) );
532 loop->addStatement( std::string(
"else {\n" ) );
538 loop->addStatement( std::string(
"}\n" ) );
541 loop->addStatement( std::string(
reset_int.
get(0,0) ) +
" = 0;\n" );
547 loop->addStatement(
"}\n" );
556 uint numX = NX*(NX+1)/2.0;
560 zeroM = zeros<double>(1,numX+numU+NX*
NU);
563 zeroM = zeros<double>(1,NX*(NX+
NU)+
NU*
NU);
578 for( run5 = 0; run5 <
numStages; run5++ ) {
586 zeroM = zeros<double>(NX+
NU,NX+
NU);
589 for( run5 = 0; run5 <
numStages; run5++ ) {
597 for( run6 = 0; run6 <
numStages; run6++ ) {
601 loop2->addStatement( diffLoop1 );
611 for( run6 = 0; run6 < NX+
NU; run6++ ) {
620 for( run6 = 0; run6 <
numStages; run6++ ) {
624 loop2->addStatement( diffLoop3 );
632 for( run6 = 0; run6 <
NX; run6++ ) {
635 for( run6 = 0; run6 <
NX; run6++ ) {
639 for( run6 = 0; run6 <
NU; run6++ ) {
651 loop2->addStatement( diffLoop5 );
655 for( run6 = 0; run6 <
NX; run6++ ) {
658 for( run6 = 0; run6 <
NX; run6++ ) {
661 for( run6 = 0; run6 <
NU; run6++ ) {
693 for(
uint index = 0; index <
NX; index++ ) {
702 for(
uint index = 0; index <
NX; index++ ) {
783 for( index3 = 1; index3 <
NX1; index3++ ) {
786 for( index3 = 0; index3 <
NX2; index3++ ) {
795 for( index3 = 1; index3 <
NX2; index3++ ) {
804 for( index3 = 0; index3 <
NX1; index3++ ) {
807 for( index3 = 0; index3 <
NX2; index3++ ) {
820 returnValue SymmetricIRKExport::sensitivitiesImplicitSystem(
ExportStatementBlock*
block,
const ExportIndex& index1,
const ExportIndex& index2,
const ExportIndex& index3,
const ExportIndex& tmp_index1,
const ExportIndex& tmp_index2,
const ExportIndex& stepI,
const ExportVariable& Ah,
const ExportVariable& Bh,
const ExportVariable& det,
bool STATES,
uint number )
828 if( STATES && number == 1 ) {
843 else if( STATES && number == 2 ) {
844 for( i = 0; i <
NX2+
NXA; i++ ) {
866 if( STATES && (number == 1 ||
NX1 == 0) ) {
872 if( STATES && (number == 1 ||
NX1 == 0) ) block->
addStatement( std::string(
"}\n" ) );
875 for( i = 0; i <
NX; i++ ) {
876 if( STATES ) loop2.
addStatement( tmp_index1 == (stepI*(NX+NXA)+i)*(NX+
NU)+index1);
877 else loop2.
addStatement( tmp_index1 == (stepI*(NX+NXA)+i)*(NX+
NU)+NX+index1);
880 for( i = 0; i <
NXA; i++ ) {
881 if( STATES ) loop2.
addStatement( tmp_index1 == (stepI*(NX+NXA)+NX+i)*(NX+
NU)+index1);
882 else loop2.
addStatement( tmp_index1 == (stepI*(NX+NXA)+NX+i)*(NX+
NU)+NX+index1);
890 if( STATES && number == 2 ) {
891 loop3.
addStatement( tmp_index1 == (stepI*(NX+NXA)+index2)*(NX+
NU));
897 loop3.
addStatement( tmp_index1 == (stepI*(NX+NXA)+index2)*(NX+
NU));
898 loop3.
addStatement( tmp_index2 == tmp_index1+NX+index1);
908 block->
addStatement( std::string(
"if( run == 0 ) {\n") );
913 loop4.
addStatement( tmp_index1 == (stepI*(NX+NXA)+NX+index2)*(NX+
NU));
918 loop4.
addStatement( tmp_index1 == (stepI*(NX+NXA)+NX+index2)*(NX+
NU));
919 loop4.
addStatement( tmp_index2 == tmp_index1+NX+index1);
ExportVariable rk_diffsPrev1
virtual returnValue setup()
virtual returnValue setup()
ExportVariable rk_xxx_traj
Expression symmetricDerivative(const Expression &arg1, const Expression &arg2, const Expression &forward_seed, const Expression &backward_seed, Expression *forward_result, Expression *backward_result)
ExportVariable rk_aux_traj
ExportAcadoFunction adjoint_sweep
ExportVariable getRow(const ExportIndex &idx) const
Expression backwardDerivative(const Expression &arg1, const Expression &arg2)
const std::string getNameSolveTransposeReuseFunction()
virtual returnValue propagateImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &_index3, const ExportIndex &tmp_index)
returnValue initializeDDMatrix()
ExportVariable getGlobalExportVariable() const
double getFirstTime() const
virtual returnValue updateImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &tmp_index)
Expression returnLowerTriangular(const Expression &expr)
ExportVariable getTranspose() const
GenericMatrix & appendCols(const GenericMatrix &_arg)
std::vector< Grid > outputGrids
ExportAcadoFunction diffs_rhs
std::vector< ExportAcadoFunction > outputs
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)
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)
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 getElement(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
ExportVariable rk_diffsTemp2
ForwardIRKExport & operator=(const ForwardIRKExport &arg)
#define CLOSE_NAMESPACE_ACADO
virtual returnValue sensitivitiesImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index1, const ExportIndex &tmp_index2, const ExportIndex &stepI, const ExportVariable &Ah, const ExportVariable &Bh, const ExportVariable &det, bool STATES, uint number)
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, 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.
virtual returnValue copy(const ImplicitRungeKuttaExport &arg)
Base class for all variables within the symbolic expressions family.
SymmetricIRKExport(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
virtual returnValue setDifferentialEquation(const Expression &rhs)
ExportAcadoFunction diffs_rhs3
ExportVariable getAuxVariable() const
static std::string fcnPrefix
DVector evaluateDerivedPolynomial(double time)
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
Expression multipleForwardDerivative(const Expression &arg1, const Expression &arg2, const Expression &seed)
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
ExportVariable rk_auxSolver
ExportVariable rk_hess_tmp1
ExportVariable makeRowVector() const
const std::string getNameSolveReuseFunction()
ExportAcadoFunction diffs_sweep
const std::string get(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
virtual returnValue getCode(ExportStatementBlock &code)
Expression & appendRows(const Expression &arg)
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 updateHessianTerm(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2)
returnValue addLinebreak(uint num=1)
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_hess_tmp2
const std::string getNameSolveFunction()
#define BEGIN_NAMESPACE_ACADO
ExportVariable error_code
ExportVariable rk_rhsTemp
returnValue clearStaticCounters()
Allows to export a tailored implicit Runge-Kutta integrator with symmetric second order sensitivity g...
Allows to export a tailored implicit Runge-Kutta integrator with forward sensitivity generation for f...
returnValue addFunction(const ExportFunction &_function)
ExportVariable rk_b_trans
virtual returnValue clear()
virtual returnValue getCode(ExportStatementBlock &code)=0
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
Allows to export code for a block of statements.
Expression getRows(const uint &rowIdx1, const uint &rowIdx2) const
SymmetricIRKExport & operator=(const SymmetricIRKExport &arg)
ExportVariable rk_adj_diffs_tmp
ExportArgument getAddress(const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
virtual ~SymmetricIRKExport()
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)
GenericVector< T > getRow(unsigned _idx) const
ExportFunction & addIndex(const ExportIndex &_index)
#define ACADOERROR(retval)
virtual bool equidistantControlGrid() const
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)
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
std::string getName() const