本文整理汇总了C++中Bounds::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ Bounds::getType方法的具体用法?C++ Bounds::getType怎么用?C++ Bounds::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bounds
的用法示例。
在下文中一共展示了Bounds::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expand
Bounds::Ptr expand(const Bounds &bounds) const {
Bounds::Ptr pBounds;
switch (bounds.getType()) {
case Bounds::TYPE_PLANE:
pBounds = expand(dynamic_cast<const BoundingPlane&>(bounds));
break;
case Bounds::TYPE_SPHERE:
pBounds = expand(dynamic_cast<const BoundingSphere&>(bounds));
break;
case Bounds::TYPE_CYLINDER:
pBounds = expand(dynamic_cast<const BoundingCylinder&>(bounds));
break;
case Bounds::TYPE_BOX:
pBounds = expand(dynamic_cast<const BoundingBox&>(bounds));
break;
case Bounds::TYPE_CONVEX_MESH:
pBounds = expand(dynamic_cast<const BoundingConvexMesh&>(bounds));
break;
default:
break;
}
return pBounds;
}
示例2: setupAuxiliaryQP
//.........这里部分代码省略.........
else
{
if ( H != 0 )
return THROWERROR( RET_NO_HESSIAN_SPECIFIED );
}
/* 3) Setup QP gradient. */
if ( setupAuxiliaryQPgradient( ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );
/* II) SETUP WORKING SETS AND MATRIX FACTORISATIONS: */
/* 1) Make a copy of current bounds/constraints ... */
Bounds oldBounds = bounds;
Constraints oldConstraints = constraints;
/* we're trying to find an active set with positive definite null
* space Hessian twice:
* - first for the current active set including all equalities
* - second after moving all inactive variables to a bound
* (depending on Options). This creates an empty null space and
* is guaranteed to succeed. Thus this loop will exit after n_try=1.
*/
int n_try;
for (n_try = 0; n_try < 2; ++n_try) {
if (n_try > 0) {
// the current active set leaves an indefinite null space Hessian
// move all inactive variables to a bound, creating an empty null space
for (int ii = 0; ii < nV; ++ii)
if (oldBounds.getStatus (ii) == ST_INACTIVE)
oldBounds.setStatus (ii, options.initialStatusBounds);
}
/* ... reset them ... */
bounds.init( nV );
constraints.init( nC );
/* ... and set them up afresh. */
if ( setupSubjectToType(lb_new,ub_new,lbA_new,ubA_new ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );
if ( bounds.setupAllFree( ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );
if ( constraints.setupAllInactive( ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );
/* 2) Setup TQ factorisation. */
if ( setupTQfactorisation( ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );
// check for equalities that have become bounds ...
for (int ii = 0; ii < nC; ++ii) {
if (oldConstraints.getType (ii) == ST_EQUALITY && constraints.getType (ii) == ST_BOUNDED) {
if (oldConstraints.getStatus (ii) == ST_LOWER && y[nV+ii] < 0.0)
oldConstraints.setStatus (ii, ST_UPPER);
else if (oldConstraints.getStatus (ii) == ST_UPPER && y[nV+ii] > 0.0)
oldConstraints.setStatus (ii, ST_LOWER);
}
}
// ... and do the same also for the bounds!
for (int ii = 0; ii < nV; ++ii) {
if (oldBounds.getType(ii) == ST_EQUALITY
&& bounds.getType(ii) == ST_BOUNDED) {
if (oldBounds.getStatus(ii) == ST_LOWER && y[ii] < 0.0)
oldBounds.setStatus(ii, ST_UPPER);
else if (oldBounds.getStatus(ii) == ST_UPPER && y[ii] > 0.0)
oldBounds.setStatus(ii, ST_LOWER);
}
}
/* 3) Setup old working sets afresh (updating TQ factorisation). */
if ( setupAuxiliaryWorkingSet( &oldBounds,&oldConstraints,BT_TRUE ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );
/* Factorise projected Hessian
* this now handles all special cases (no active bounds/constraints, no nullspace) */
returnvalue = computeProjectedCholesky( );
/* leave the loop if decomposition was successful, i.e. we have
* found an active set with positive definite null space Hessian */
if ( returnvalue == SUCCESSFUL_RETURN )
break;
}
/* adjust lb/ub if we changed the old active set in the second try
*/
if (n_try > 0) {
// as per setupAuxiliaryQPbounds assumptions ... oh the troubles
for (int ii = 0; ii < nC; ++ii)
Ax_l[ii] = Ax_u[ii] = Ax[ii];
setupAuxiliaryQPbounds (&bounds, &constraints, BT_FALSE);
}
status = QPS_AUXILIARYQPSOLVED;
return SUCCESSFUL_RETURN;
}