本文整理汇总了C++中ExportVariable::getGivenMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ ExportVariable::getGivenMatrix方法的具体用法?C++ ExportVariable::getGivenMatrix怎么用?C++ ExportVariable::getGivenMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExportVariable
的用法示例。
在下文中一共展示了ExportVariable::getGivenMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupObjectiveEvaluation
returnValue ExportGaussNewtonForces::setupObjectiveEvaluation( void )
{
evaluateObjective.setup("evaluateObjective");
int variableObjS;
get(CG_USE_VARIABLE_WEIGHTING_MATRIX, variableObjS);
int forceDiagHessian;
get(CG_FORCE_DIAGONAL_HESSIAN, forceDiagHessian);
diagH = false;
diagHN = false;
unsigned dimHRows = NX + NU;
unsigned dimHCols = NX + NU;
unsigned dimHNRows = NX;
unsigned dimHNCols = NX;
if (objS.isGiven() == true || forceDiagHessian == true)
if (objS.getGivenMatrix().isDiagonal())
{
diagH = true;
dimHCols = 1;
}
if (objSEndTerm.isGiven() == true || forceDiagHessian == true)
if (objSEndTerm.getGivenMatrix().isDiagonal() == true)
{
diagHN = true;
dimHNCols = 1;
}
objHessians.resize(N + 1);
for (unsigned i = 0; i < N; ++i)
{
objHessians[ i ].setup(string("H") + toString(i + 1), dimHRows, dimHCols, REAL, FORCES_PARAMS, false, qpObjPrefix);
}
objHessians[ N ].setup(string("H") + toString(N + 1), dimHNRows, dimHNCols, REAL, FORCES_PARAMS, false, qpObjPrefix);
objGradients.resize(N + 1);
for (unsigned i = 0; i < N; ++i)
{
objGradients[ i ].setup(string("f") + toString(i + 1), NX + NU, 1, REAL, FORCES_PARAMS, false, qpObjPrefix);
}
objGradients[ N ].setup(string("f") + toString(N + 1), NX, 1, REAL, FORCES_PARAMS, false, qpObjPrefix);
//
// 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;
}
//
// Main loop that calculates Hessian and gradients
//
ExportIndex runObj( "runObj" );
ExportForLoop loopObjective( runObj, 0, N );
evaluateObjective.addIndex( runObj );
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);
// Stack the measurement function value
loopObjective.addStatement(
Dy.getRows(runObj * NY, (runObj + 1) * NY) == objValueOut.getTranspose().getRows(0, getNY())
);
loopObjective.addLinebreak( );
// Optionally compute derivatives
unsigned indexX = getNY();
// unsigned indexG = indexX;
ExportVariable tmpObjS, tmpFx, tmpFu;
ExportVariable tmpFxEnd, tmpObjSEndTerm;
tmpObjS.setup("tmpObjS", NY, NY, REAL, ACADO_LOCAL);
if (objS.isGiven() == true)
tmpObjS = objS;
tmpFx.setup("tmpFx", NY, NX, REAL, ACADO_LOCAL);
if (objEvFx.isGiven() == true)
tmpFx = objEvFx;
tmpFu.setup("tmpFu", NY, NU, REAL, ACADO_LOCAL);
if (objEvFu.isGiven() == true)
tmpFu = objEvFu;
//.........这里部分代码省略.........