本文整理汇总了C++中Objective::getLSQEndTerms方法的典型用法代码示例。如果您正苦于以下问题:C++ Objective::getLSQEndTerms方法的具体用法?C++ Objective::getLSQEndTerms怎么用?C++ Objective::getLSQEndTerms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objective
的用法示例。
在下文中一共展示了Objective::getLSQEndTerms方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setObjective
returnValue ExportNLPSolver::setObjective(const Objective& _objective)
{
int variableObjS;
get(CG_USE_VARIABLE_WEIGHTING_MATRIX, variableObjS);
// Temporary variables
ExportVariable objSTemp, objSEndTermTemp;
////////////////////////////////////////////////////////////////////////////
//
// Setup arrival cost calc variables
//
////////////////////////////////////////////////////////////////////////////
int useArrivalCost;
get(CG_USE_ARRIVAL_COST, useArrivalCost);
if ( useArrivalCost )
{
SAC.setup("SAC", NX, NX, REAL, ACADO_VARIABLES);
SAC.setDoc("Arrival cost term: inverse of the covariance matrix.");
xAC.setup("xAC", NX, 1, REAL, ACADO_VARIABLES);
xAC.setDoc("Arrival cost term: a priori state estimate.");
DxAC.setup("DxAC", NX, 1, REAL, ACADO_WORKSPACE);
}
////////////////////////////////////////////////////////////////////////////
//
// Check first if we are dealing with external functions
//
////////////////////////////////////////////////////////////////////////////
vector<String> lsqExternFunctions;
vector<ExportVariable> lsqExternMatrices;
_objective.getLSQTerms(lsqExternMatrices, lsqExternFunctions);
vector<String> lsqExternEndTermFunctions;
vector<ExportVariable> lsqExternEndTermMatrices;
_objective.getLSQEndTerms(lsqExternEndTermMatrices, lsqExternEndTermFunctions);
if (lsqExternMatrices.size() > 0 || lsqExternEndTermMatrices.size() > 0)
{
if (lsqExternMatrices.size() != lsqExternEndTermMatrices.size())
return ACADOERROR( RET_INVALID_ARGUMENTS );
if (lsqExternMatrices.size() > 1 || lsqExternEndTermMatrices.size() > 1)
return ACADOERROR( RET_INVALID_ARGUMENTS );
objSTemp = lsqExternMatrices[ 0 ];
objSTemp.setDataStruct( ACADO_VARIABLES );
objSEndTermTemp = lsqExternEndTermMatrices[ 0 ];
objSEndTermTemp.setDataStruct( ACADO_VARIABLES );
if (objSTemp.getGivenMatrix().isSquare() == BT_FALSE ||
objSEndTermTemp.getGivenMatrix().isSquare() == BT_FALSE)
return ACADOERROR( RET_INVALID_ARGUMENTS );
setNY( objSTemp.getNumRows() );
setNYN( objSEndTermTemp.getNumRows() );
if (variableObjS == YES)
{
objS.setup("W", N * NY, NY, REAL, ACADO_VARIABLES);
}
else
{
objS.setup("W", NY, NY, REAL, ACADO_VARIABLES);
}
objSEndTerm = CasADi::deepcopy( objSEndTermTemp );
objSEndTerm.setName( "WN" );
evaluateExternLSQ = lsqExternFunctions[ 0 ];
evaluateExternLSQEndTerm = lsqExternEndTermFunctions[ 0 ];
// ExportVariable objEvFx, objEvFu, objEvFxEnd; // aliasing
objEvFx.setup("evFx", NY, NX, REAL, ACADO_WORKSPACE);
objEvFu.setup("evFx", NY, NU, REAL, ACADO_WORKSPACE);
objEvFxEnd.setup("evFx", NYN, NX, REAL, ACADO_WORKSPACE);
Q1.setup("Q1", NX * N, NX, REAL, ACADO_WORKSPACE);
Q2.setup("Q2", NX * N, NY, REAL, ACADO_WORKSPACE);
R1.setup("R1", NU * N, NU, REAL, ACADO_WORKSPACE);
R2.setup("R2", NU * N, NY, REAL, ACADO_WORKSPACE);
QN1.setup("QN1", NX, NX, REAL, ACADO_WORKSPACE);
QN2.setup("QN2", NX, NYN, REAL, ACADO_WORKSPACE);
objValueIn.setup("objValueIn", 1, NX + 0 + NU + NP, REAL, ACADO_WORKSPACE);
objValueOut.setup("objValueOut", 1,
NY < NYN ? NYN * (1 + NX + NU): NY * (1 + NX + NU), REAL, ACADO_WORKSPACE);
externObjective = BT_TRUE;
setupResidualVariables();
return SUCCESSFUL_RETURN;
}
//.........这里部分代码省略.........