49 const std::string& _commonHeaderName
118 uint i, j, k, s1, s2;
119 for( i = 0; i <
NX1; i++ ) {
122 for( k = 0; k <
NX1; k++ ) {
124 for( s1 = 0; s1 < j; s1++ ) {
125 for( s2 = 0; s2 <
NX1; s2++ ) {
126 vec(k) = vec(k) +
AA(j,s1)*h*
A11(k,s2)*sens(i*NX1+s2,s1);
131 for( k = 0; k <
NX1; k++ ) {
132 sens(i*NX1+k,j) = sol(k);
136 for( i = 0; i <
NU; i++ ) {
139 for( k = 0; k <
NX1; k++ ) {
141 for( s1 = 0; s1 < j; s1++ ) {
142 for( s2 = 0; s2 <
NX1; s2++ ) {
143 vec(k) = vec(k) +
AA(j,s1)*h*
A11(k,s2)*sens(NX1*NX1+i*NX1+s2,s1);
148 for( k = 0; k <
NX1; k++ ) {
149 sens(NX1*NX1+i*NX1+k,j) = sol(k);
171 DMatrix tmp = zeros<double>(vars, vars);
173 for( i2 = 0; i2 < vars; i2++ ){
174 for( j2 = 0; j2 < vars; j2++ ) {
175 tmp(i2, j2) = mass(i2,j2) -
AA(i1,i1)*h*
jacobian(i2,j2);
179 for( i2 = 0; i2 < vars; i2++ ){
180 for( j2 = 0; j2 < vars; j2++ ) {
181 result(i1*vars+i2, j2) = tmp(i2, j2);
192 if(
NX2 > 0 ||
NXA > 0 ) {
227 if ( (
bool)debugMode == true ) {
236 returnValue DiagonallyImplicitRKExport::sensitivitiesImplicitSystem(
ExportStatementBlock*
block,
const ExportIndex& index1,
const ExportIndex& index2,
const ExportIndex& index3,
const ExportIndex& tmp_index1,
const ExportIndex& tmp_index2,
const ExportVariable& Ah,
const ExportVariable& Bh,
const ExportVariable& det,
bool STATES,
uint number )
244 if( STATES && number == 1 ) {
258 else if( STATES && number == 2 ) {
259 for( i = 0; i <
NX2+
NXA; i++ ) {
286 if( STATES && (number == 1 ||
NX1 == 0) ) {
292 if( STATES && (number == 1 ||
NX1 == 0) ) loop1.
addStatement( std::string(
"}\n" ) );
306 block->
addStatement( std::string(
"if( run == 0 ) {\n") );
421 returnValue DiagonallyImplicitRKExport::sensitivitiesOutputSystem(
ExportStatementBlock*
block,
const ExportIndex& index1,
const ExportIndex& index2,
const ExportIndex& index3,
const ExportIndex& index4,
const ExportIndex& tmp_index1,
const ExportIndex& tmp_index2,
const ExportVariable& Ah,
const ExportVariable& Bh,
bool STATES,
uint number )
426 if( STATES && number == 1 ) {
449 else if( STATES && number == 2 ) {
491 if( !STATES || number != 3 ) {
493 for( i = 0; i <
NX3; i++ ) {
504 if( STATES && number == 3 ) {
544 uint i, j, k, s1, s2;
545 for( i = 0; i <
NX3; i++ ) {
548 for( k = 0; k <
NX3; k++ ) {
550 for( s1 = 0; s1 < j; s1++ ) {
551 for( s2 = 0; s2 <
NX3; s2++ ) {
552 vec(k) = vec(k) +
AA(j,s1)*h*
A33(k,s2)*sens(i*NX3+s2,s1);
557 for( k = 0; k <
NX3; k++ ) {
558 sens(i*NX3+k,j) = sol(k);
585 if ( (
bool)debugMode ==
true && useOMP ) {
592 if(
NX2 > Xmax ) Xmax =
NX2;
593 if(
NX3 > Xmax ) Xmax =
NX3;
596 if(
NX2 > 0 ||
NXA > 0 ) {
virtual returnValue setup()
virtual returnValue solveOutputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index, const ExportVariable &Ah, bool DERIVATIVES=false)
virtual returnValue sensitivitiesOutputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &index4, const ExportIndex &tmp_index1, const ExportIndex &tmp_index2, const ExportVariable &Ah, const ExportVariable &Bh, bool STATES, uint number)
ExportVariable getRow(const ExportIndex &idx) const
double getFirstTime() const
DiagonallyImplicitRKExport(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
virtual returnValue evaluateMatrix(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &tmp_index, const ExportVariable &_rk_A, const ExportVariable &Ah, const ExportVariable &C, bool evaluateB, bool DERIVATIVES)
virtual ExportVariable getGlobalExportVariable(const uint factor) const
Allows to pass back messages to the calling function.
ExportLinearSolver * solver
Block< Derived > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
virtual returnValue setup()
Allows to export code of a for-loop.
string toString(T const &value)
const std::string getNameOutputDiffs() const
ExportVariable getElement(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
ExportVariable rk_diffsTemp2
ForwardIRKExport & operator=(const ForwardIRKExport &arg)
#define CLOSE_NAMESPACE_ACADO
ExportVariable rk_diffsNew3
DiagonallyImplicitRKExport & operator=(const DiagonallyImplicitRKExport &arg)
ExportVariable getSubMatrix(const ExportIndex &rowIdx1, const ExportIndex &rowIdx2, const ExportIndex &colIdx1, const ExportIndex &colIdx2) const
const std::string getNameDiffsRHS() const
Defines a scalar-valued index variable to be used for exporting code.
virtual returnValue evaluateStatesImplicitSystem(ExportStatementBlock *block, const ExportVariable &Ah, const ExportVariable &C, const ExportIndex &stage, const ExportIndex &i, const ExportIndex &j)
virtual ~DiagonallyImplicitRKExport()
Expression jacobian(const Expression &arg1, const Expression &arg2)
static std::string fcnPrefix
DVector evaluateDerivedPolynomial(double time)
virtual DMatrix formMatrix(const DMatrix &mass, const DMatrix &jacobian)
virtual returnValue solveInputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index, const ExportVariable &Ah)
const std::string getNameOutputRHS() const
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
ExportVariable rk_auxSolver
int acadoRoundAway(double x)
const std::string getNameSolveReuseFunction()
const std::string getNameRHS() const
const std::string get(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
virtual returnValue solveImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index, const ExportVariable &Ah, const ExportVariable &C, const ExportVariable &det, bool DERIVATIVES=false)
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 evaluateStatesOutputSystem(ExportStatementBlock *block, const ExportVariable &Ah, const ExportIndex &stage)
unsigned getNumRows() const
ExportVariable rk_diffsNew2
unsigned getNumCols() const
uint getNumIntervals() const
virtual returnValue setup()=0
virtual returnValue evaluateRhsImplicitSystem(ExportStatementBlock *block, const ExportIndex &stage)
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
const std::string getNameSolveFunction()
#define BEGIN_NAMESPACE_ACADO
ExportVariable rk_rhsTemp
virtual returnValue prepareInputSystem(ExportStatementBlock &code)
Allows to export a tailored implicit Runge-Kutta integrator with forward sensitivity generation for f...
ExportVariable rk_diffsTemp3
virtual returnValue clear()
virtual returnValue prepareOutputSystem(ExportStatementBlock &code)
Allows to export code for a block of statements.
virtual returnValue sensitivitiesImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index1, const ExportIndex &tmp_index2, const ExportVariable &Ah, const ExportVariable &Bh, const ExportVariable &det, bool STATES, uint number)
ExportArgument getAddress(const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
GenericMatrix getRows(unsigned _start, unsigned _end) const
returnValue init(const uint newDim, const bool &reuse=true, const bool &unrolling=false)
ExportVariable getCol(const ExportIndex &idx) const
GenericVector< T > getRow(unsigned _idx) const
#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 export a tailored diagonally implicit Runge-Kutta integrator for fast model predictive cont...
std::string getName() const