40 const std::string& _commonHeaderName
135 code <<
"#ifdef __cplusplus\n";
136 code <<
"extern \"C\"{\n";
138 code <<
"int " << moduleName <<
"_hpmpc_wrapper(real_t* A, real_t* B, real_t* d, real_t* Q, real_t* Qf, real_t* S, real_t* R, real_t* q, real_t* qf, real_t* r, real_t* lb, real_t* ub, real_t* C, real_t* D, real_t* lbg, real_t* ubg, real_t* CN, real_t* x, real_t* u, real_t* lambda, real_t* mu, int* nIt);\n";
139 code <<
"#ifdef __cplusplus\n";
146 code <<
"#define NX " <<
toString(
NX ) <<
"\n";
147 code <<
"#define NU " <<
toString(
NU ) <<
"\n";
148 code <<
"#define NW " <<
toString(
NU ) <<
"\n";
149 code <<
"#define NY " <<
toString(
NY ) <<
"\n";
150 code <<
"#define NN " <<
toString(
N ) <<
"\n";
152 code <<
"#include <hpmpc/c_interface.h>\n\n";
156 code.
addStatement(
"/******************************************************************************/\n" );
160 code.
addStatement(
"/******************************************************************************/\n" );
214 return (
N + 1) *
NX +
N *
NU;
286 unsigned indexX =
getNY();
364 tmpFxCall, tmpFuCall, objSCall,
431 qq ==
Q2 *
Dy.
getRows(index * NY, (index + 1) * NY)
443 rr ==
R2 *
Dy.
getRows(index * NY, (index + 1) * NY)
454 for (
unsigned blk = 0; blk <
N; ++blk)
465 for (
unsigned blk = 0; blk <
N; ++blk)
479 for (
unsigned blk = 0; blk <
N; ++blk)
534 for (
unsigned node = 0; node <
N; ++node)
538 lbValues.
append( lbUInf );
544 ubValues.
append( ubUInf );
552 for (
unsigned node = 1; node < N + 1; ++node)
556 lbValues.
append( lbXInf );
562 ubValues.
append( ubXInf );
595 for (
unsigned i = 0; i <
N; ++i)
598 for (
unsigned i = 0; i <
N; ++i)
639 for (
unsigned i = 0; i <
N; ++i)
687 derOffset = derOffset + dimPacH *
NX;
707 for (
unsigned i = 0, intRowOffset = 0, dim = 0; i < N + 1; ++i)
713 string(
"Evaluating constraint on node: #" ) +
toString( i )
766 setStagePac.
setup(
"setStagePac", offsetPac, indPac, tLbAValues, tUbAValues);
769 << (
qpLbA.
getRows(offsetPac, offsetPac + dimPacH) == tLbAValues -
pacEvH.
getRows(indPac * dimPacH, indPac * dimPacH + dimPacH))
770 << (
qpUbA.
getRows(offsetPac, offsetPac + dimPacH) == tUbAValues -
pacEvH.
getRows(indPac * dimPacH, indPac * dimPacH + dimPacH));
777 unsigned offsetEval = 0;
778 unsigned offsetPoc = 0;
779 for (
unsigned i = 0; i <
N; ++i)
799 << (tPocA.getSubMatrix(0, dim, 0, NX) ==
pocEvHx.
getSubMatrix(offsetPoc, offsetPoc + dim, 0, NX))
800 << (tPocA.getSubMatrix(0, dim, NX, NX + NU) ==
pocEvHu.
getSubMatrix(offsetPoc, offsetPoc + dim, 0, NU))
804 evUbAValues.
getRows(offsetEval, offsetEval + dim) -
pocEvH.
getRows(offsetPoc, offsetPoc + dim));
819 evUbAValues.
getRows(offsetEval, offsetEval + dim) -
pocEvH.
getRows(offsetPoc, offsetPoc + dim));
831 x0.
setDoc(
"Current state feedback vector." );
860 retSim.
setDoc(
"Status of the integration module. =0: OK, otherwise the error code.");
875 returnValueFeedbackPhase.
setDoc(
"Status code of the HPMPC QP solver." );
877 feedback.
doc(
"Feedback/estimation step of the RTI scheme." );
895 feedback <<
"static real_t qpWork[ HPMPC_RIC_MHE_IF_DP_WORK_SPACE ];\n";
911 for (
unsigned i = 0; i <
N; ++i)
936 << returnValueFeedbackPhase.
getFullName() <<
" = " << moduleName <<
"_hpmpc_wrapper(" 981 << returnValueFeedbackPhase.
getFullName() <<
" = " <<
"c_order_riccati_mhe_if('d', 2, " 1047 getKKT.
doc(
"Get the KKT tolerance of the current iterate." );
1048 kkt.
setDoc(
"The KKT tolerance value." );
1075 ubLoop << kkt.
getFullName() <<
"+= fabs( " <<
qpUb.
get(index, 0) <<
" * " <<
qpMu.
get(index + N * NU + N * NX, 0) <<
");\n";
1102 string outFile = folderName +
"/" + moduleName +
"_hpmpc_interface.c";
1106 int maxNumQPiterations;
1110 if ( maxNumQPiterations <= 0 )
1121 int useSinglePrecision;
ExportFunction preparation
ExportFunction setStagePac
ExportFunction setObjQN1QN2
ExportVariable conValueOut
ExportVariable getRow(const ExportIndex &idx) const
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
ExportFunction shiftStates
ExportVariable getTranspose() const
bool initialStateFixed() const
virtual returnValue setup()
ExportVariable & setup(const std::string &_name, uint _nRows=1, uint _nCols=1, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string())
bool isGiven(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
ExportFunction setObjR1R2
Allows to pass back messages to the calling function.
ExportVariable conValueIn
DVector getUpperBounds(uint pointIdx) const
std::vector< DVector > pocLbStack
returnValue addComment(const std::string &_comment)
ExportVariable objEvFxEnd
const DMatrix & getGivenMatrix() const
Allows to export code of a for-loop.
string toString(T const &value)
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
#define CLOSE_NAMESPACE_ACADO
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 export of NLP/OCP solvers.
ExportAcadoFunction evaluateStageCost
ExportFunction evaluateObjective
Defines a matrix-valued variable that can be passed as argument to exported functions.
ExportVariable evLbValues
ExportAcadoFunction evaluateTerminalCost
ExportFunction & setup(const std::string &_name="defaultFunctionName", 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 setDoc(const std::string &_doc)
virtual returnValue setupInitialization()
std::string commonHeaderName
virtual returnValue setupQPInterface()
Interface generator for the HPMPC QP solver.
ExportFunction modelSimulation
virtual ExportFunction & doc(const std::string &_doc)
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
ExportFunction getObjective
ExportFunction evaluateConstraints
ExportVariable makeRowVector() const
virtual returnValue setupObjectiveEvaluation(void)
ExportVariable objValueIn
ExportFunction initializeNodes
double levenbergMarquardt
const std::string get(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
unsigned getNumQPvars() const
virtual returnValue setupEvaluation()
virtual returnValue setupSimulation(void)
std::vector< unsigned > qpConDim
ExportVariable evUbValues
std::vector< std::shared_ptr< ExportAcadoFunction > > evaluatePointConstraints
Encapsulates all user interaction for setting options, logging data and plotting results.
virtual uint getDim() const
ExportFunction shiftControls
returnValue addStatement(const ExportStatement &_statement)
virtual bool isGiven() const
std::string getFullName() const
returnValue addLinebreak(uint num=1)
virtual returnValue setupConstraintsEvaluation(void)
ExportAcadoFunction evaluatePathConstraints
ExportGaussNewtonHpmpc(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
ExportFunction setObjQ1Q2
GenericVector & append(const GenericVector &_arg)
virtual returnValue setupVariables()
ExportFunction & setReturnValue(const ExportVariable &_functionReturnValue, bool _returnAsPointer=false)
virtual ExportFunction & acquire(ExportIndex &obj)
ExportFunction & addVariable(const ExportVariable &_var)
void setAll(const T &_value)
ExportVariable objSEndTerm
std::string getName() const
ExportVariable getRows(const ExportIndex &idx1, const ExportIndex &idx2) const
returnValue addDeclaration(const ExportVariable &_data, ExportStruct _dataStruct=ACADO_ANY)
returnValue setupAuxiliaryFunctions()
virtual ExportFunction & release(const ExportIndex &obj)
DVector getLowerBounds(uint pointIdx) const
#define BEGIN_NAMESPACE_ACADO
returnValue addFunction(const ExportFunction &_function)
std::vector< DVector > pocUbStack
std::shared_ptr< ExportHpmpcInterface > qpInterface
Allows to export code for a block of statements.
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
ExportFunction initialize
ExportArgument getAddress(const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
ExportVariable objValueOut
virtual returnValue setupMultiplicationRoutines()
ExportFunction & addIndex(const ExportIndex &_index)
virtual returnValue getCode(ExportStatementBlock &code)
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)
ExportVariable makeColVector() const
const std::string getAddressString(bool withDataStruct=true) const