本文整理汇总了C++中ExportVariable::makeRowVector方法的典型用法代码示例。如果您正苦于以下问题:C++ ExportVariable::makeRowVector方法的具体用法?C++ ExportVariable::makeRowVector怎么用?C++ ExportVariable::makeRowVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExportVariable
的用法示例。
在下文中一共展示了ExportVariable::makeRowVector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupObjectiveEvaluation
returnValue ExportExactHessianQpDunes::setupObjectiveEvaluation( void )
{
evaluateObjective.setup("evaluateObjective");
//
// A loop the evaluates objective and corresponding gradients
//
ExportIndex runObj( "runObj" );
ExportForLoop loopObjective( runObj, 0, N );
evaluateObjective.addIndex( runObj );
// Interface variable to qpDUNES
qpH.setup("qpH", N * (NX + NU) * (NX + NU) + NX * NX, 1, REAL, ACADO_WORKSPACE); // --> to be used only after regularization to pass to qpDUNES
qpg.setup("qpG", N * (NX + NU) + NX, 1, REAL, ACADO_WORKSPACE);
// LM regularization preparation
ExportVariable evLmX = zeros<double>(NX, NX);
ExportVariable evLmU = zeros<double>(NU, NU);
if (levenbergMarquardt > 0.0)
{
DMatrix lmX = eye<double>( NX );
lmX *= levenbergMarquardt;
DMatrix lmU = eye<double>( NU );
lmU *= levenbergMarquardt;
evLmX = lmX;
evLmU = lmU;
}
ExportVariable stagef;
stagef.setup("stagef", NX + NU, 1, REAL, ACADO_LOCAL);
ExportVariable stageH;
stageH.setup("stageH", NX + NU, NX + NU, REAL, ACADO_LOCAL);
if( evaluateStageCost.getFunctionDim() > 0 ) {
loopObjective.addStatement( objValueIn.getCols(0, getNX()) == x.getRow( runObj ) );
loopObjective.addStatement( objValueIn.getCols(NX, NX + NU) == u.getRow( runObj ) );
loopObjective.addStatement( objValueIn.getCols(NX + NU, NX + NU + NOD) == od.getRow( runObj ) );
loopObjective.addLinebreak( );
// Evaluate the objective function
loopObjective.addFunctionCall(evaluateStageCost, objValueIn, objValueOut);
loopObjective.addLinebreak( );
ExportVariable tmpFxx, tmpFxu, tmpFuu;
tmpFxx.setup("tmpFxx", NX, NX, REAL, ACADO_LOCAL);
tmpFxu.setup("tmpFxu", NX, NU, REAL, ACADO_LOCAL);
tmpFuu.setup("tmpFuu", NU, NU, REAL, ACADO_LOCAL);
setStageH.setup("addObjTerm", tmpFxx, tmpFxu, tmpFuu, stageH);
setStageH.addStatement( stageH.getSubMatrix(0,NX,0,NX) += tmpFxx + evLmX );
setStageH.addStatement( stageH.getSubMatrix(0,NX,NX,NX+NU) += tmpFxu );
setStageH.addStatement( stageH.getSubMatrix(NX,NX+NU,0,NX) += tmpFxu.getTranspose() );
setStageH.addStatement( stageH.getSubMatrix(NX,NX+NU,NX,NX+NU) += tmpFuu + evLmU );
loopObjective.addFunctionCall(
setStageH, objValueOut.getAddress(0, 1+NX+NU), objValueOut.getAddress(0, 1+NX+NU+NX*NX),
objValueOut.getAddress(0, 1+NX+NU+NX*(NX+NU)), objS.getAddress(runObj*(NX+NU), 0) );
ExportVariable tmpDF;
tmpDF.setup("tmpDF", NX+NU, 1, REAL, ACADO_LOCAL);
setStagef.setup("addObjLinearTerm", tmpDF, stagef);
setStagef.addStatement( stagef == tmpDF.getRows(0,NX+NU) );
loopObjective.addFunctionCall(
setStagef, objValueOut.getAddress(0, 1), qpg.getAddress(runObj * (NX+NU)) );
loopObjective.addLinebreak( );
}
else {
if(levenbergMarquardt > 0.0) {
setStageH.setup("addObjTerm", stageH);
setStageH.addStatement( stageH.getSubMatrix(0,NX,0,NX) += evLmX );
setStageH.addStatement( stageH.getSubMatrix(NX,NX+NU,NX,NX+NU) += evLmU );
loopObjective.addFunctionCall( setStageH, objS.getAddress(runObj*(NX+NU), 0) );
}
DMatrix D(NX+NU,1); D.setAll(0);
loopObjective.addStatement( qpg.getRows(runObj*(NX+NU), runObj*(NX+NU)+NX+NU) == D );
}
evaluateObjective.addStatement( loopObjective );
//
// Evaluate the quadratic Mayer term
//
if( evaluateTerminalCost.getFunctionDim() > 0 ) {
evaluateObjective.addStatement( objValueIn.getCols(0, NX) == x.getRow( N ) );
evaluateObjective.addStatement( objValueIn.getCols(NX, NX + NOD) == od.getRow( N ) );
// Evaluate the objective function, last node.
evaluateObjective.addFunctionCall(evaluateTerminalCost, objValueIn, objValueOut);
evaluateObjective.addLinebreak( );
evaluateObjective.addStatement( objSEndTerm.makeRowVector() == objValueOut.getCols(1+NX,1+NX+NX*NX) + evLmX.makeRowVector() );
//.........这里部分代码省略.........