本文整理汇总了C++中nox::abstract::Group::computeX方法的典型用法代码示例。如果您正苦于以下问题:C++ Group::computeX方法的具体用法?C++ Group::computeX怎么用?C++ Group::computeX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nox::abstract::Group
的用法示例。
在下文中一共展示了Group::computeX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
NOX::Solver::TensorBased::implementGlobalStrategy(NOX::Abstract::Group& newGrp,
double& in_stepSize,
const NOX::Solver::Generic& s)
{
bool ok;
counter.incrementNumLineSearches();
isNewtonDirection = false;
NOX::Abstract::Vector& searchDirection = *tensorVecPtr;
if ((counter.getNumLineSearches() == 1) || (lsType == Newton))
{
isNewtonDirection = true;
searchDirection = *newtonVecPtr;
}
// Do line search and compute new soln.
if ((lsType != Dual) || (isNewtonDirection))
ok = performLinesearch(newGrp, in_stepSize, searchDirection, s);
else if (lsType == Dual)
{
double fTensor = 0.0;
double fNew = 0.0;
double tensorStep = 1.0;
bool isTensorDescent = false;
const Abstract::Group& oldGrp = s.getPreviousSolutionGroup();
double fprime = slopeObj.computeSlope(searchDirection, oldGrp);
// Backtrack along tensor direction if it is descent direction.
if (fprime < 0)
{
ok = performLinesearch(newGrp, in_stepSize, searchDirection, s);
assert(ok);
fTensor = 0.5 * newGrp.getNormF() * newGrp.getNormF();
tensorStep = in_stepSize;
isTensorDescent = true;
}
// Backtrack along the Newton direction.
ok = performLinesearch(newGrp, in_stepSize, *newtonVecPtr, s);
fNew = 0.5 * newGrp.getNormF() * newGrp.getNormF();
// If backtracking on the tensor step produced a better step, then use it.
if (isTensorDescent && (fTensor <= fNew))
{
newGrp.computeX(oldGrp, *tensorVecPtr, tensorStep);
newGrp.computeF();
}
}
return ok;
}
示例2:
bool NOX::LineSearch::Polynomial::
updateGrp(NOX::Abstract::Group& newGrp,
const NOX::Abstract::Group& oldGrp,
const NOX::Abstract::Vector& dir,
double step) const
{
newGrp.computeX(oldGrp, dir, step);
NOX::Abstract::Group::ReturnType status = newGrp.computeF();
if (status != NOX::Abstract::Group::Ok)
return false;
return true;
}
示例3: while
bool NOX::LineSearch::Backtrack::
compute(NOX::Abstract::Group& grp, double& step,
const NOX::Abstract::Vector& dir,
const NOX::Solver::Generic& s)
{
const Abstract::Group& oldGrp = s.getPreviousSolutionGroup();
double oldF = meritFunctionPtr->computef(oldGrp);
double newF;
bool isFailed = false;
step = defaultStep;
grp.computeX(oldGrp, dir, step);
NOX::Abstract::Group::ReturnType rtype;
rtype = grp.computeF();
if (rtype != NOX::Abstract::Group::Ok)
{
utils->err() << "NOX::LineSearch::BackTrack::compute - Unable to compute F"
<< std::endl;
throw "NOX Error";
}
newF = meritFunctionPtr->computef(grp);
int nIters = 1;
if (utils->isPrintType(Utils::InnerIteration))
{
utils->out() << "\n" << Utils::fill(72) << "\n"
<< "-- Backtrack Line Search -- \n";
}
NOX::StatusTest::FiniteValue checkNAN;
while ( ((newF >= oldF) || (checkNAN.finiteNumberTest(newF) !=0))
&& (!isFailed))
{
if (utils->isPrintType(Utils::InnerIteration))
{
utils->out() << std::setw(3) << nIters << ":";
utils->out() << " step = " << utils->sciformat(step);
utils->out() << " old f = " << utils->sciformat(oldF);
utils->out() << " new f = " << utils->sciformat(newF);
utils->out() << std::endl;
}
nIters ++;
step = step * reductionFactor;
if ((step < minStep) || (nIters > maxIters))
{
isFailed = true;
step = recoveryStep;
}
grp.computeX(oldGrp, dir, step);
rtype = grp.computeF();
if (rtype != NOX::Abstract::Group::Ok)
{
utils->err() << "NOX::LineSearch::BackTrack::compute - Unable to compute F" << std::endl;
throw "NOX Error";
}
newF = meritFunctionPtr->computef(grp);
}
if (utils->isPrintType(Utils::InnerIteration))
{
utils->out() << std::setw(3) << nIters << ":";
utils->out() << " step = " << utils->sciformat(step);
utils->out() << " old f = " << utils->sciformat(oldF);
utils->out() << " new f = " << utils->sciformat(newF);
if (isFailed)
utils->out() << " (USING RECOVERY STEP!)" << std::endl;
else
utils->out() << " (STEP ACCEPTED!)" << std::endl;
utils->out() << Utils::fill(72) << "\n" << std::endl;
}
return (!isFailed);
}