45 const std::string& _commonHeaderName
77 LOG(
LVL_DEBUG ) <<
"Preparing to export NARXExport... " << endl;
97 rk_eta.
setDoc(
"Working array to pass the input values and return the results." );
98 reset_int.
setDoc(
"The internal memory of the integrator can be reset." );
99 rk_index.setDoc(
"Number of the shooting interval." );
101 integrate.
doc(
"Performs the integration and sensitivity propagation for one shooting interval." );
113 fullRhs.
doc(
"Evaluates the right-hand side of the full model." );
142 eyeM = zeros<double>(
NX2,i1*(NX1+
NX2)+NX1);
144 eyeM.
appendCols( zeros<double>(NX2,(delay-i1-1)*(NX1+NX2)+
NU) );
149 for(
uint i1 = 0; i1 <
NX1; i1++ ) {
150 for(
uint i2 = 0; i2 <
NX1; i2++ ) {
153 for(
uint i2 = 0; i2 <
NU; i2++ ) {
160 for(
uint i1 = 0; i1 <
NX3; i1++ ) {
161 for(
uint i2 = 0; i2 <
NX3; i2++ ) {
182 loop->addStatement( std::string(
"if( run > 0 ) {\n") );
194 loop->addStatement( loopTemp1 );
206 loop->addStatement( loopTemp2 );
213 loop->addStatement( loopTemp3 );
215 loop->addStatement( std::string(
"}\n") );
247 loop->addStatement( loop1 );
252 loop->addStatement( std::string(
"if( run == 0 ) {\n" ) );
262 loop->addStatement( std::string(
"}\n" ) );
263 loop->addStatement( std::string(
"else {\n" ) );
270 loop->addStatement( std::string(
"}\n" ) );
275 loop->addStatement(
"}\n" );
286 zeroR = zeros<double>(1, (delay-1)*(NX1+NX2)+
NX3);
292 zeroR = zeros<double>(1,
NX2);
293 for(
uint s2 = 0; s2 < s1; s2++ ) {
297 zeroR = zeros<double>(1, (delay-s1)*(NX1+NX2)+
NX3);
311 zeroR = zeros<double>(1,
NX3);
312 loop3.
addStatement(
rk_eta.
getCols( i*NX+NX+s*(NX1+NX2)*NX+NX1*NX+delay*(NX1+NX2),i*NX+NX+s*(NX1+NX2)*NX+NX1*NX+NX ) == zeroR );
330 for( i = 1; i <
delay; i++ ) {
335 for( i = 0; i <
NX1; i++ ) {
337 for( j = 1; j <
NX1; j++ ) {
342 for( j = 0; j <
NU; j++ ) {
468 for( i = 0; i <
delay; i++ ) {
469 if( s < (delay-1) ) {
483 for( i = 0; i <
delay; i++ ) {
495 for( i = 0; i <
delay; i++ ) {
523 for( i = 0; i <
delay; i++ ) {
524 if( s < (delay-1) ) {
541 for( i = 0; i <
delay; i++ ) {
563 for( i = 0; i <
delay; i++ ) {
619 for(
uint i = 0; i <
NX2; i++ ) {
624 for(
uint j = 0; j < n; j++ ) {
625 sum = sum + _parms(i,j+1)*
x(j);
628 uint indexParms = n+1;
629 for(
uint j = 1; j < _delay; j++ ) {
690 for( i = 0; i < _rhs.getDim(); i++ ) {
700 DMatrix dependencyMat = _rhs.getDependencyPattern( x );
702 for( i = n; i <
NX; i++ ) {
710 f_large << _rhs + A3_large*
x;
730 for(
uint i = index; i < n; i++ ) {
732 result = result +
parms(num,base)*
x(i);
738 result = result + tmp*
x(i);
753 const std::string &_commonHeaderName)
755 return new NARXExport(_userInteraction, _commonHeaderName);
ExportVariable rk_diffsPrev1
#define LOG(level)
Just define a handy macro for getting the logger.
Lowest level, the debug level.
virtual returnValue copy(const DiscreteTimeExport &arg)
returnValue updateImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &tmp_index)
ExportVariable getRow(const ExportIndex &idx) const
Allows to setup and evaluate output functions based on SymbolicExpressions.
GenericMatrix & appendCols(const GenericMatrix &_arg)
virtual returnValue updateOutputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &tmp_index)
ExportAcadoFunction diffs_rhs
returnValue propagateInputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index)
ExportVariable rk_diffsPrev3
Allows to pass back messages to the calling function.
returnValue setNARXmodel(const uint _delay, const DMatrix &_parms)
Expression forwardDerivative(const Expression &arg1, const Expression &arg2)
Block< Derived > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
ExportVariable rk_diffsPrev2
DMatrix expandOutputMatrix(const DMatrix &A3)
Allows to export code of a for-loop.
GenericMatrix & appendRows(const GenericMatrix &_arg)
const std::string getNameOutputDiffs() const
#define CLOSE_NAMESPACE_ACADO
ExportVariable rk_diffsNew3
ExportVariable getSubMatrix(const ExportIndex &rowIdx1, const ExportIndex &rowIdx2, const ExportIndex &colIdx1, const ExportIndex &colIdx2) const
Defines a scalar-valued index variable to be used for exporting code.
Base class for all variables within the symbolic expressions family.
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
virtual returnValue setDoc(const std::string &_doc)
ExportAcadoFunction diffs_rhs3
virtual ExportFunction & doc(const std::string &_doc)
returnValue prepareFullRhs()
const std::string getNameOutputRHS() const
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
int acadoRoundAway(double x)
NARXExport(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
const std::string getNameRHS() const
Allows to export a tailored discrete-time 'integrator' for fast model predictive control.
ExportVariable rk_diffsTemp3
Encapsulates all user interaction for setting options, logging data and plotting results.
virtual returnValue propagateOutputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index)
Allows to export code of an arbitrary function.
returnValue addStatement(const ExportStatement &_statement)
returnValue setModel(const std::string &_rhs, const std::string &_diffs_rhs)
unsigned getNumRows() const
returnValue addLinebreak(uint num=1)
virtual returnValue setup()
Allows to export a tailored integrator for fast model predictive control.
ExportFunction & setReturnValue(const ExportVariable &_functionReturnValue, bool _returnAsPointer=false)
ExportVariable rk_diffsNew2
unsigned getNumCols() const
virtual returnValue setDifferentialEquation(const Expression &rhs)
uint getNumIntervals() const
Allows to export a tailored polynomial NARX integrator for fast model predictive control.
GenericVector< T > sumRow() const
DifferentialStateDerivative dx
std::string getName() const
ExportVariable getRows(const ExportIndex &idx1, const ExportIndex &idx2) const
ExportAcadoFunction lin_input
IntegratorExport * createNARXExport(UserInteraction *_userInteraction, const std::string &_commonHeaderName)
#define BEGIN_NAMESPACE_ACADO
ExportVariable error_code
returnValue clearStaticCounters()
ExportVariable rk_diffsNew1
virtual returnValue clear()
Allows to export code for a block of statements.
returnValue formNARXpolynomial(const uint num, const uint order, uint &base, const uint index, IntermediateState &result)
returnValue propagateImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index)
ExportArgument getAddress(const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
virtual returnValue setLinearOutput(const DMatrix &M3, const DMatrix &A3, const Expression &rhs)
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)
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) 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)
std::string getName() const
returnValue updateInputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &tmp_index)